From patchwork Wed Sep 7 19:59:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 1128352 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p87Jxnkg000596 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 7 Sep 2011 20:00:09 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1R1OHY-00019R-74; Wed, 07 Sep 2011 19:59:36 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1R1OHX-00015z-NQ; Wed, 07 Sep 2011 19:59:35 +0000 Received: from relais.videotron.ca ([24.201.245.36]) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1R1OHT-00015e-IA for linux-arm-kernel@lists.infradead.org; Wed, 07 Sep 2011 19:59:32 +0000 MIME-version: 1.0 Content-type: multipart/mixed; boundary="Boundary_(ID_got58KR3yrK+YG3bmNRXBw)" Received: from xanadu.home ([66.130.28.92]) by VL-VM-MR006.ip.videotron.ca (Oracle Communications Messaging Exchange Server 7u4-22.01 64bit (built Apr 21 2011)) with ESMTP id <0LR600DO64V66ZG0@VL-VM-MR006.ip.videotron.ca> for linux-arm-kernel@lists.infradead.org; Wed, 07 Sep 2011 15:59:30 -0400 (EDT) Date: Wed, 07 Sep 2011 15:59:30 -0400 (EDT) From: Nicolas Pitre To: Arnaud Lacombe Subject: Re: [RFC] Kbuild: allow code re-use across different directories In-reply-to: Message-id: References: <1313800642-32418-1-git-send-email-lacombar@gmail.com> User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110907_155931_681082_D568B369 X-CRM114-Status: GOOD ( 25.59 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [24.201.245.36 listed in list.dnswl.org] Cc: lkml , linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 07 Sep 2011 20:00:09 +0000 (UTC) On Wed, 7 Sep 2011, Arnaud Lacombe wrote: > Hi, > > On Wed, Sep 7, 2011 at 3:07 PM, Nicolas Pitre wrote: > > On Fri, 19 Aug 2011, Arnaud Lacombe wrote: > > > >> Hi folks, > >> > >> The attached patch modify Kbuild to allow to directly re-use code in multiple > >> directory without having to go through a copy. Technically, it changes Kbuild to > >> use by default the VPATH feature of GNU make and provides accessors for Makefile > >> to change it indirectly. > >> > >> Considering: > >> > >> arch/foo/lib: > >> fancy.c > >> > >> We want to be able to build it with -DPANTS=32 in the kernel, but the > >> bootloader requires -DPANTS_SIZE=30. > >> > >> Currently we would do, either: > >> > >> arch/foo/lib/Makefile > >> LDFLAGS_fancy.o := -DPANTS=32 > >> obj-y += fancy.o > >> > >> and, either: > >> > >> arch/foo/boot/Makefile: > >> LDFLAGS_fancy.o := -DPANTS=30 > >> obj-y += fancy.o > >> $(obj)/fancy.c: $(srctree)/arch/foo/lib/fancy.c > >>       $(call cmd,shipped) > >> > >> or > >> > >> arch/foo/boot/Makefile: > >> LDFLAGS_fancy.o := -DPANTS=30 > >> obj-y += fancy.o > >> $(obj)/fancy.o: $(srctree)/arch/foo/lib/fancy.c > >>       $(call cmd,cc_c_o) > >> > >> The former implies an extra copy of the source file, the latter expose Kbuild > >> internal function. > >> > >> With the attached patch, we would do: > >> > >> arch/foo/boot/Makefile: > >> LDFLAGS_fancy.o := -DPANTS=30 > >> obj-y += fancy.o > >> vpath-y += $(srctree)/arch/foo/lib > >> > >> and let GNU make do the job. > >> > >> Comments welcome, > > > > It doesn't work.  Whatever I do to arch/arm/boot/compressed/Makefile > > (which admittedly looks a bit hairy and could benefit from a shave) in > > order to remove the $(call cmd,shipped) used with lib1funcs.S, I always > > end up with: > > > > make[2]: *** No rule to make target `arch/arm/boot/compressed/lib1funcs.S', needed by `arch/arm/boot/compressed/lib1funcs.o'.  Stop. > > > What was the exact change you made which triggered this ? In its simplest expression (not caring about the now undefined lib1funcs variable): Nicolas diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index 0c74a6fab9..b34ed80977 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -70,6 +70,10 @@ ifeq ($(CONFIG_ARCH_SHMOBILE),y) OBJS += head-shmobile.o endif +# For __aeabi_uidivmod +OBJS += lib1funcs.o +vpath-y += $(srctree)/arch/arm/lib + # # We now have a PIC decompressor implementation. Decompressors running # from RAM should not define ZTEXTADDR. Decompressors running directly @@ -120,12 +124,6 @@ LDFLAGS_vmlinux += -X # Next argument is a linker script LDFLAGS_vmlinux += -T -# For __aeabi_uidivmod -lib1funcs = $(obj)/lib1funcs.o - -$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S FORCE - $(call cmd,shipped) - # We need to prevent any GOTOFF relocs being used with references # to symbols in the .bss section since we cannot relocate them # independently from the rest at run time. This can be achieved by