All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaud Lacombe <lacombar@gmail.com>
To: Nicolas Pitre <nico@fluxnic.net>
Cc: linux-kbuild@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] Kbuild: allow code re-use across different directories
Date: Wed, 7 Sep 2011 16:52:15 -0400	[thread overview]
Message-ID: <CACqU3MUiie5Zv+FwFkXcY7yZ1-wgCB7xVpHn36WaV7EpecU4Cw@mail.gmail.com> (raw)
In-Reply-To: <alpine.LFD.2.00.1109071554480.20358@xanadu.home>

Hi,

On Wed, Sep 7, 2011 at 3:59 PM, Nicolas Pitre <nico@fluxnic.net> wrote:
> On Wed, 7 Sep 2011, Arnaud Lacombe wrote:
>
>> Hi,
>>
>> On Wed, Sep 7, 2011 at 3:07 PM, Nicolas Pitre <nico@fluxnic.net> 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:

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
$(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

WARNING: multiple messages have this Message-ID (diff)
From: lacombar@gmail.com (Arnaud Lacombe)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC] Kbuild: allow code re-use across different directories
Date: Wed, 7 Sep 2011 16:52:15 -0400	[thread overview]
Message-ID: <CACqU3MUiie5Zv+FwFkXcY7yZ1-wgCB7xVpHn36WaV7EpecU4Cw@mail.gmail.com> (raw)
In-Reply-To: <alpine.LFD.2.00.1109071554480.20358@xanadu.home>

Hi,

On Wed, Sep 7, 2011 at 3:59 PM, Nicolas Pitre <nico@fluxnic.net> wrote:
> On Wed, 7 Sep 2011, Arnaud Lacombe wrote:
>
>> Hi,
>>
>> On Wed, Sep 7, 2011 at 3:07 PM, Nicolas Pitre <nico@fluxnic.net> 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:

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
$(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

  reply	other threads:[~2011-09-07 20:52 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-20  0:37 [RFC] Kbuild: allow code re-use across different directories Arnaud Lacombe
2011-08-20  0:37 ` Arnaud Lacombe
2011-08-22  8:42 ` Cong Wang
2011-08-22  8:42   ` Cong Wang
2011-08-30  0:31 ` Arnaud Lacombe
2011-08-30  0:31   ` Arnaud Lacombe
2011-08-30  4:32   ` Nicolas Pitre
2011-08-30  4:32     ` Nicolas Pitre
2011-08-30  4:36     ` Arnaud Lacombe
2011-08-30  4:36       ` Arnaud Lacombe
2011-09-07 19:07 ` Nicolas Pitre
2011-09-07 19:07   ` Nicolas Pitre
2011-09-07 19:34   ` Arnaud Lacombe
2011-09-07 19:34     ` Arnaud Lacombe
2011-09-07 19:59     ` Nicolas Pitre
2011-09-07 19:59       ` Nicolas Pitre
2011-09-07 20:52       ` Arnaud Lacombe [this message]
2011-09-07 20:52         ` Arnaud Lacombe
2011-09-08  4:50       ` Arnaud Lacombe
2011-09-08  4:50         ` Arnaud Lacombe
2011-09-08 20:33         ` Nicolas Pitre
2011-09-08 20:33           ` Nicolas Pitre
2011-09-09  1:22           ` Arnaud Lacombe
2011-09-09  1:22             ` Arnaud Lacombe
2011-09-09 12:32             ` Michal Marek
2011-09-09 12:32               ` Michal Marek
2011-09-09 16:16               ` Arnaud Lacombe
2011-09-09 16:16                 ` Arnaud Lacombe
2011-09-08 18:24 ` Arnaud Lacombe
2011-09-09 12:30 ` Michal Marek
2011-09-09 12:30   ` Michal Marek
2011-09-13 21:13   ` Arnaud Lacombe
2011-09-13 21:13     ` Arnaud Lacombe
2011-09-14  1:48     ` Michal Marek
2011-09-14  1:48       ` Michal Marek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACqU3MUiie5Zv+FwFkXcY7yZ1-wgCB7xVpHn36WaV7EpecU4Cw@mail.gmail.com \
    --to=lacombar@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nico@fluxnic.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.