From patchwork Wed Sep 7 20:52:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnaud Lacombe X-Patchwork-Id: 1128502 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 p87KqYWg021493 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 7 Sep 2011 20:52:56 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1R1P6a-0001mw-Ve; Wed, 07 Sep 2011 20:52:21 +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 1R1P6a-0002R8-Gr; Wed, 07 Sep 2011 20:52:20 +0000 Received: from mail-yx0-f177.google.com ([209.85.213.177]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1R1P6X-0002Qn-Fv for linux-arm-kernel@lists.infradead.org; Wed, 07 Sep 2011 20:52:18 +0000 Received: by yxi11 with SMTP id 11so44900yxi.36 for ; Wed, 07 Sep 2011 13:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=zf+6NVHVN7QtC90PXN6iNbU8V15ID2zcRJQCCB/VqSE=; b=xhmJSFFFz4nTO6f/JeBDWHeWtTVG3gpQmXvV3AI8wI2uFlFQ7PlTfpCXfw9y1NwpYy ccxGt5S8ZEKATOB8FbCcroKknUXrEtsoPBKEbxGYriwGpl8+CRK8VJJyQ2GB6QfH8JtG n9RGdqZc16m53H6Y9EnqTYxgp6tgCrMGP1UT8= MIME-Version: 1.0 Received: by 10.231.6.164 with SMTP id 36mr3685366ibz.82.1315428735708; Wed, 07 Sep 2011 13:52:15 -0700 (PDT) Received: by 10.142.232.15 with HTTP; Wed, 7 Sep 2011 13:52:15 -0700 (PDT) In-Reply-To: References: <1313800642-32418-1-git-send-email-lacombar@gmail.com> Date: Wed, 7 Sep 2011 16:52:15 -0400 Message-ID: Subject: Re: [RFC] Kbuild: allow code re-use across different directories From: Arnaud Lacombe To: Nicolas Pitre X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110907_165217_649912_47BE4DB3 X-CRM114-Status: GOOD ( 23.75 ) X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.213.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (lacombar[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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:52:56 +0000 (UTC) X-MIME-Autoconverted: from quoted-printable to 8bit by demeter2.kernel.org id p87KqYWg021493 Hi, On Wed, Sep 7, 2011 at 3:59 PM, Nicolas Pitre wrote: > 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): > > 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 > that look correct to me, however, the error you get: make[2]: *** No rule to make target `arch/arm/boot/compressed/lib1funcs.S', needed by `arch/arm/boot/compressed/lib1funcs.o'. Stop. seem odd to me. I just re-tried on x86 with: $(obj)/early_serial_console.o $(obj)/piggy.o FORCE $(call if_changed,ld) @: and `checksum_32.o' gets built just fine from `$(srctree)/arch/x86/lib/checksum_32.S'. I guess I'll ends up building an arm toolchain tonight and see closer. - Arnaud diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index 09664ef..65c89f7 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -23,7 +23,9 @@ LDFLAGS_vmlinux := -T hostprogs-y := mkpiggy -$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o $(obj)/string.o $(obj)/cmdline.o $(obj)/early_serial_console.o $(obj)/piggy.o FORCE +vpath-y += $(srctree)/arch/x86/lib + +$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/checksum_32.o $(obj)/head_$(BITS).o $(obj)/misc.o $(obj)/string.o $(obj)/cmdline.o