From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.avm.de (mail.avm.de [212.42.244.94]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43F0713D260; Fri, 20 Sep 2024 10:39:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.42.244.94 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726828772; cv=none; b=o7L9iIUvYklUhJFoKGxEovOL9+TeWTemueD+a3d/gMY97KirYwqn6dBsM4/RiOc1AiLbMnf3I0j3S3NeNPmttmJNB5yPDL1hEh+rx9NPkZ2+Gb8I5DeN8LI7iviVOxye+gw6J5DZFn29P8ripg3YB7Q5ZfL0ysonOCYrMNKB5GE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726828772; c=relaxed/simple; bh=OIe2GSv2Nfd/MQZ2AtqPDcSJ3q3aTvXHIIeHRnCJNLU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=oA0JPFVNGW6tsFS+755m/bQ16pi2wlbKPiivWn5DC9fJMfGXd7sAeWkqYycOeofKeXi4DJXcVBcJSMvm8MNyrf918c9kQt0zwt9SGRidp5CC/xCqrS90xU7C1YvKVAul2kJ4Zyj8NPaR0oL5jxm9CRmlq0Ekb/2e+it5ObcvsrA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=avm.de; spf=pass smtp.mailfrom=avm.de; dkim=pass (1024-bit key) header.d=avm.de header.i=@avm.de header.b=rgzwXYcZ; arc=none smtp.client-ip=212.42.244.94 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=avm.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=avm.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=avm.de header.i=@avm.de header.b="rgzwXYcZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=avm.de; s=mail; t=1726828760; bh=OIe2GSv2Nfd/MQZ2AtqPDcSJ3q3aTvXHIIeHRnCJNLU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rgzwXYcZ0AJ0Sp+jvqhjpKR69G2bNSNs4Qd+ONgqbgV/TsCxtGayBMf12oUfAwVZn E4k+bJSrMa3mGI15Hn/WSh2/WqDEpIgVhgnypQECW37vaVrIh6RURlzrB1fzk2h843 /v0sZU1MObxQmuQ03v09Ybp+VYoVWPPbGNerJtlw= Received: from mail-auth.avm.de (dovecot-mx-01.avm.de [212.42.244.71]) by mail.avm.de (Postfix) with ESMTPS; Fri, 20 Sep 2024 12:39:20 +0200 (CEST) Received: from l-nschier-nb (unknown [83.68.141.146]) by mail-auth.avm.de (Postfix) with ESMTPSA id 5F3AE80885; Fri, 20 Sep 2024 12:39:20 +0200 (CEST) Date: Fri, 20 Sep 2024 12:39:19 +0200 From: Nicolas Schier To: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org, Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier Subject: Re: [PATCH 00/23] kbuild: support building external modules in a separate build directory Message-ID: References: <20240917141725.466514-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> X-purgate-ID: 149429::1726828760-D2D3900A-31840275/0/0 X-purgate-type: clean X-purgate-size: 3366 X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean On Tue, Sep 17, 2024 at 11:16:28PM +0900, Masahiro Yamada wrote: > > There has been a long-standing request to support building external > modules in a separate build directory. Thanks a lot, you are making several of my colleages very happy with your patch set! > The first half is cleanups of documents and Makefiles. > > The last part adds KBUILD_EXTMOD_OUTPUT (MO=). > This is too big changes, and too late for the current MW. > (I did not test kselftest at all.) > I hope people test this and may uncover some issues. I'm not through all the patches in detail yet, just one observation beforehand: $ make KBUILD_OUTPUT=build allnoconfig $ ./scripts/config --file build/.config --enable modules --enable accessibility $ make KBUILD_OUTPUT=build olddefconfig $ make KBUILD_OUTPUT=build $ make KBUILD_OUTPUT=build CONFIG_SPEAKUP=m MO=/tmp/build M=~+/drivers/accessibility/speakup modules /home/nschier/src/kbuild-review/drivers/accessibility/speakup/genmap.c:23:10: fatal error: mapdata.h: No such file or directory 23 | #include "mapdata.h" | ^~~~~~~~~~~ compilation terminated. make[3]: *** [/home/nschier/src/kbuild-review/scripts/Makefile.host:133: genmap.o] Error 1 make[3]: *** Waiting for unfinished jobs.... make[2]: *** [/home/nschier/src/kbuild-review/Makefile:1971: .] Error 2 make[1]: *** [/home/nschier/src/kbuild-review/Makefile:251: __sub-make] Error 2 make: *** [Makefile:251: __sub-make] Error 2 [exit code 2] If I add "EXTRA_CFLAGS=-I${MO} and EXTRA_HOSTCFLAGS=-I${MO}" to the module build command, it works as expected. Patching this into kbuild works for me, too, but I haven't checked whether it breaks some other scenarios: diff --git a/scripts/Makefile.host b/scripts/Makefile.host index e01c13a588dd..056c7da2776f 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host @@ -97,10 +97,13 @@ hostrust_flags = --out-dir $(dir $@) --emit=dep-info=$(depfile) \ $(HOSTRUSTFLAGS_$(target-stem)) # $(objtree)/$(obj) for including generated headers from checkin source files -ifeq ($(KBUILD_EXTMOD),) ifdef building_out_of_srctree +ifeq ($(KBUILD_EXTMOD),) hostc_flags += -I $(objtree)/$(obj) hostcxx_flags += -I $(objtree)/$(obj) +else +hostc_flags += -I $(CURDIR) +hostcxx_flags += -I $(CURDIR) endif endif diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 1bdd77f42289..428a9eb74381 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -190,11 +190,15 @@ endif # $(src) for including checkin headers from generated source files # $(obj) for including generated headers from checkin source files -ifeq ($(KBUILD_EXTMOD),) ifdef building_out_of_srctree +ifeq ($(KBUILD_EXTMOD),) _c_flags += $(addprefix -I, $(src) $(obj)) _a_flags += $(addprefix -I, $(src) $(obj)) _cpp_flags += $(addprefix -I, $(src) $(obj)) +else +_c_flags += $(addprefix -I, $(src) $(obj) $(CURDIR)) +_a_flags += $(addprefix -I, $(src) $(obj) $(CURDIR)) +_cpp_flags += $(addprefix -I, $(src) $(obj) $(CURDIR)) endif endif Is '-I$(MO)' in CFLAGS/HOSTCFLAGS is something we should support by default, or should this be added to the external module's Makefile by the respective developers themselves? Kind regards, Nicolas