* [patch] powerpc: build modules outside the kernel tree fails, if it was built using O=
@ 2009-09-24 11:28 Yuri Frolov
2009-09-25 1:12 ` Benjamin Herrenschmidt
2009-09-25 19:45 ` Sam Ravnborg
0 siblings, 2 replies; 9+ messages in thread
From: Yuri Frolov @ 2009-09-24 11:28 UTC (permalink / raw)
To: linuxppc-dev; +Cc: rep.dot.nop, linux-kbuild
Hello,
here is a corresponding bug: http://bugzilla.kernel.org/show_bug.cgi?id=11143
This patch should correctly export crtsavres.o in order to make O= option working.
Please, consider to apply.
Fix linking modules against crtsavres.o
Previously we got
CC drivers/char/hw_random/rng-core.mod.o
LD [M] drivers/char/hw_random/rng-core.ko
/there/src/buildroot.git.ppc/build_powerpc_nofpu/staging_dir/usr/bin/powerpc-linux-uclibc-ld: arch/powerpc/lib/crtsavres.o: No such file: No such file or directory
* Makefile (LDFLAGS_MODULE_PREREQ): New variable to hold prerequisite
files for modules.
* arch/powerpc/Makefile: add crtsavres.o to LDFLAGS_MODULE_PREREQ.
* scripts/Makefile.modpost (cmd_as_o_S): Copy from Makefile.build.
(cmd_ld_ko_o): Also link LDFLAGS_MODULE_PREREQ.
Provide rule to build objects from assembler.
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off by: Yuri Frolov <yfrolov@ru.mvista.com>
Makefile | 2 ++
arch/powerpc/Makefile | 2 +-
scripts/Makefile.modpost | 12 ++++++++++--
3 files changed, 13 insertions(+), 3 deletions(-)
diff -urpN -X linux-2.6/Documentation/dontdiff linux-2.6/arch/powerpc/Makefile linux-2.6-powerpc-crtsavres/arch/powerpc/Makefile
--- linux-2.6/arch/powerpc/Makefile 2009-09-17 20:04:31.000000000 +0400
+++ linux-2.6-powerpc-crtsavres/arch/powerpc/Makefile 2009-09-23 22:08:03.000000000 +0400
@@ -93,7 +93,7 @@ else
KBUILD_CFLAGS += $(call cc-option,-mtune=power4)
endif
else
-LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
+LDFLAGS_MODULE_PREREQ += arch/powerpc/lib/crtsavres.o
endif
ifeq ($(CONFIG_TUNE_CELL),y)
diff -urpN -X linux-2.6/Documentation/dontdiff linux-2.6/Makefile linux-2.6-powerpc-crtsavres/Makefile
--- linux-2.6/Makefile 2009-09-17 20:04:30.000000000 +0400
+++ linux-2.6-powerpc-crtsavres/Makefile 2009-09-23 21:41:16.000000000 +0400
@@ -326,6 +326,7 @@ MODFLAGS = -DMODULE
CFLAGS_MODULE = $(MODFLAGS)
AFLAGS_MODULE = $(MODFLAGS)
LDFLAGS_MODULE = -T $(srctree)/scripts/module-common.lds
+LDFLAGS_MODULE_PREREQ =
CFLAGS_KERNEL =
AFLAGS_KERNEL =
CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
@@ -355,6 +356,7 @@ export VERSION PATCHLEVEL SUBLEVEL KERNE
export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE
export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
+export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE LDFLAGS_MODULE_PREREQ CHECK CHECKFLAGS
export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV
diff -urpN -X linux-2.6/Documentation/dontdiff linux-2.6/scripts/Makefile.modpost linux-2.6-powerpc-crtsavres/scripts/Makefile.modpost
--- linux-2.6/scripts/Makefile.modpost 2009-09-17 20:04:42.000000000 +0400
+++ linux-2.6-powerpc-crtsavres/scripts/Makefile.modpost 2009-09-23 22:15:00.000000000 +0400
@@ -122,14 +122,22 @@ quiet_cmd_cc_o_c = CC $@
cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \
-c -o $@ $<
-$(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE
+quiet_cmd_as_o_S = AS $(quiet_modtag) $@
+cmd_as_o_S = $(CC) $(a_flags) $(AFLAGS_MODULE) -c -o $@ $<
+
+$(LDFLAGS_MODULE_PREREQ): %.o: %.S FORCE
+ $(Q)mkdir -p $(dir $@)
+ $(call if_changed_dep,as_o_S)
+
+$(modules:.ko=.mod.o): %.mod.o: %.mod.c $(LDFLAGS_MODULE_PREREQ) FORCE
$(call if_changed_dep,cc_o_c)
targets += $(modules:.ko=.mod.o)
# Step 6), final link of the modules
quiet_cmd_ld_ko_o = LD [M] $@
- cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \
+ cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(LDFLAGS_MODULE_PREREQ) \
+ $(LDFLAGS_MODULE) -o $@ \
$(filter-out FORCE,$^)
$(modules): %.ko :%.o %.mod.o FORCE
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [patch] powerpc: build modules outside the kernel tree fails, if it was built using O= 2009-09-24 11:28 [patch] powerpc: build modules outside the kernel tree fails, if it was built using O= Yuri Frolov @ 2009-09-25 1:12 ` Benjamin Herrenschmidt 2009-09-25 4:39 ` Sam Ravnborg 2009-09-25 19:45 ` Sam Ravnborg 1 sibling, 1 reply; 9+ messages in thread From: Benjamin Herrenschmidt @ 2009-09-25 1:12 UTC (permalink / raw) To: Yuri Frolov; +Cc: rep.dot.nop, linuxppc-dev, Sam Ravnborg, linux-kbuild On Thu, 2009-09-24 at 15:28 +0400, Yuri Frolov wrote: > Hello, > > here is a corresponding bug: http://bugzilla.kernel.org/show_bug.cgi?id=11143 > This patch should correctly export crtsavres.o in order to make O= option working. > Please, consider to apply. > > > Fix linking modules against crtsavres.o Hi ! This is the same patch you already posted as " [PATCH] Fix linking modules against crtsavres.o " Or it's an update ? I've asked Sam to review it already since it affects the main kernel makefiles, waiting for his answer. Cheers, Ben. > Previously we got > CC drivers/char/hw_random/rng-core.mod.o > LD [M] drivers/char/hw_random/rng-core.ko > /there/src/buildroot.git.ppc/build_powerpc_nofpu/staging_dir/usr/bin/powerpc-linux-uclibc-ld: arch/powerpc/lib/crtsavres.o: No such file: No such file or directory > > * Makefile (LDFLAGS_MODULE_PREREQ): New variable to hold prerequisite > files for modules. > * arch/powerpc/Makefile: add crtsavres.o to LDFLAGS_MODULE_PREREQ. > * scripts/Makefile.modpost (cmd_as_o_S): Copy from Makefile.build. > (cmd_ld_ko_o): Also link LDFLAGS_MODULE_PREREQ. > Provide rule to build objects from assembler. > > Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> > Signed-off by: Yuri Frolov <yfrolov@ru.mvista.com> > > Makefile | 2 ++ > arch/powerpc/Makefile | 2 +- > scripts/Makefile.modpost | 12 ++++++++++-- > 3 files changed, 13 insertions(+), 3 deletions(-) > > diff -urpN -X linux-2.6/Documentation/dontdiff linux-2.6/arch/powerpc/Makefile linux-2.6-powerpc-crtsavres/arch/powerpc/Makefile > --- linux-2.6/arch/powerpc/Makefile 2009-09-17 20:04:31.000000000 +0400 > +++ linux-2.6-powerpc-crtsavres/arch/powerpc/Makefile 2009-09-23 22:08:03.000000000 +0400 > @@ -93,7 +93,7 @@ else > KBUILD_CFLAGS += $(call cc-option,-mtune=power4) > endif > else > -LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o > +LDFLAGS_MODULE_PREREQ += arch/powerpc/lib/crtsavres.o > endif > > ifeq ($(CONFIG_TUNE_CELL),y) > diff -urpN -X linux-2.6/Documentation/dontdiff linux-2.6/Makefile linux-2.6-powerpc-crtsavres/Makefile > --- linux-2.6/Makefile 2009-09-17 20:04:30.000000000 +0400 > +++ linux-2.6-powerpc-crtsavres/Makefile 2009-09-23 21:41:16.000000000 +0400 > @@ -326,6 +326,7 @@ MODFLAGS = -DMODULE > CFLAGS_MODULE = $(MODFLAGS) > AFLAGS_MODULE = $(MODFLAGS) > LDFLAGS_MODULE = -T $(srctree)/scripts/module-common.lds > +LDFLAGS_MODULE_PREREQ = > CFLAGS_KERNEL = > AFLAGS_KERNEL = > CFLAGS_GCOV = -fprofile-arcs -ftest-coverage > @@ -355,6 +356,7 @@ export VERSION PATCHLEVEL SUBLEVEL KERNE > export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC > export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE > export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS > +export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE LDFLAGS_MODULE_PREREQ CHECK CHECKFLAGS > > export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS > export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV > diff -urpN -X linux-2.6/Documentation/dontdiff linux-2.6/scripts/Makefile.modpost linux-2.6-powerpc-crtsavres/scripts/Makefile.modpost > --- linux-2.6/scripts/Makefile.modpost 2009-09-17 20:04:42.000000000 +0400 > +++ linux-2.6-powerpc-crtsavres/scripts/Makefile.modpost 2009-09-23 22:15:00.000000000 +0400 > @@ -122,14 +122,22 @@ quiet_cmd_cc_o_c = CC $@ > cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \ > -c -o $@ $< > > -$(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE > +quiet_cmd_as_o_S = AS $(quiet_modtag) $@ > +cmd_as_o_S = $(CC) $(a_flags) $(AFLAGS_MODULE) -c -o $@ $< > + > +$(LDFLAGS_MODULE_PREREQ): %.o: %.S FORCE > + $(Q)mkdir -p $(dir $@) > + $(call if_changed_dep,as_o_S) > + > +$(modules:.ko=.mod.o): %.mod.o: %.mod.c $(LDFLAGS_MODULE_PREREQ) FORCE > $(call if_changed_dep,cc_o_c) > > targets += $(modules:.ko=.mod.o) > > # Step 6), final link of the modules > quiet_cmd_ld_ko_o = LD [M] $@ > - cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \ > + cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(LDFLAGS_MODULE_PREREQ) \ > + $(LDFLAGS_MODULE) -o $@ \ > $(filter-out FORCE,$^) > > $(modules): %.ko :%.o %.mod.o FORCE > _______________________________________________ > Linuxppc-dev mailing list > Linuxppc-dev@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/linuxppc-dev ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] powerpc: build modules outside the kernel tree fails, if it was built using O= 2009-09-25 1:12 ` Benjamin Herrenschmidt @ 2009-09-25 4:39 ` Sam Ravnborg 2009-09-25 9:39 ` Yuri Frolov 0 siblings, 1 reply; 9+ messages in thread From: Sam Ravnborg @ 2009-09-25 4:39 UTC (permalink / raw) To: Benjamin Herrenschmidt Cc: linuxppc-dev, linux-kbuild, Yuri Frolov, rep.dot.nop On Fri, Sep 25, 2009 at 11:12:21AM +1000, Benjamin Herrenschmidt wrote: > On Thu, 2009-09-24 at 15:28 +0400, Yuri Frolov wrote: > > Hello, > > > > here is a corresponding bug: http://bugzilla.kernel.org/show_bug.cgi?id=11143 > > This patch should correctly export crtsavres.o in order to make O= option working. > > Please, consider to apply. > > > > > > Fix linking modules against crtsavres.o > > Hi ! > > This is the same patch you already posted as " > > > [PATCH] Fix linking modules against > crtsavres.o > " > > Or it's an update ? > > I've asked Sam to review it already since it affects the main kernel > makefiles, waiting for his answer. Saw the duplicates. Will get back to it tonight (morning here now). Sam ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] powerpc: build modules outside the kernel tree fails, if it was built using O= 2009-09-25 4:39 ` Sam Ravnborg @ 2009-09-25 9:39 ` Yuri Frolov 0 siblings, 0 replies; 9+ messages in thread From: Yuri Frolov @ 2009-09-25 9:39 UTC (permalink / raw) To: Sam Ravnborg; +Cc: linux-kbuild, linuxppc-dev, rep.dot.nop On 09/25/2009 08:39 AM, Sam Ravnborg wrote: > On Fri, Sep 25, 2009 at 11:12:21AM +1000, Benjamin Herrenschmidt wrote: >> On Thu, 2009-09-24 at 15:28 +0400, Yuri Frolov wrote: >>> Hello, >>> >>> here is a corresponding bug: http://bugzilla.kernel.org/show_bug.cgi?id=11143 >>> This patch should correctly export crtsavres.o in order to make O= option working. >>> Please, consider to apply. >>> >>> >>> Fix linking modules against crtsavres.o >> Hi ! >> >> This is the same patch you already posted as " >> >> >> [PATCH] Fix linking modules against >> crtsavres.o >> " >> >> Or it's an update ? It's the same, sorry for not mentioning it. The previous letter contains attachment crap, so I sent the letter with patch in-lined. >> >> I've asked Sam to review it already since it affects the main kernel >> makefiles, waiting for his answer. > Saw the duplicates. Will get back to it tonight (morning here now). > > Sam Ok, thank you. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] powerpc: build modules outside the kernel tree fails, if it was built using O= 2009-09-24 11:28 [patch] powerpc: build modules outside the kernel tree fails, if it was built using O= Yuri Frolov 2009-09-25 1:12 ` Benjamin Herrenschmidt @ 2009-09-25 19:45 ` Sam Ravnborg 2009-09-25 21:57 ` Benjamin Herrenschmidt 2009-09-26 12:45 ` Yuri Frolov 1 sibling, 2 replies; 9+ messages in thread From: Sam Ravnborg @ 2009-09-25 19:45 UTC (permalink / raw) To: Yuri Frolov; +Cc: rep.dot.nop, linuxppc-dev, linux-kbuild On Thu, Sep 24, 2009 at 03:28:11PM +0400, Yuri Frolov wrote: > Hello, > > here is a corresponding bug: http://bugzilla.kernel.org/show_bug.cgi?id=11143 > This patch should correctly export crtsavres.o in order to make O= option working. > Please, consider to apply. Hi Yuri. I like the way you do the extra link in Makefile.modpost. But you need to redo some parts as per comments below. > > > Fix linking modules against crtsavres.o Please elaborate more on what this commit does. > > Previously we got > CC drivers/char/hw_random/rng-core.mod.o > LD [M] drivers/char/hw_random/rng-core.ko > /there/src/buildroot.git.ppc/build_powerpc_nofpu/staging_dir/usr/bin/powerpc-linux-uclibc-ld: arch/powerpc/lib/crtsavres.o: No such file: No such file or directory Always good to include error messages. > * Makefile (LDFLAGS_MODULE_PREREQ): New variable to hold prerequisite > files for modules. > * arch/powerpc/Makefile: add crtsavres.o to LDFLAGS_MODULE_PREREQ. > * scripts/Makefile.modpost (cmd_as_o_S): Copy from Makefile.build. > (cmd_ld_ko_o): Also link LDFLAGS_MODULE_PREREQ. > Provide rule to build objects from assembler. But this GNUism can go - we do not use it in the kernel. > > Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> > Signed-off by: Yuri Frolov <yfrolov@ru.mvista.com> > > Makefile | 2 ++ > arch/powerpc/Makefile | 2 +- > scripts/Makefile.modpost | 12 ++++++++++-- > 3 files changed, 13 insertions(+), 3 deletions(-) > > diff -urpN -X linux-2.6/Documentation/dontdiff linux-2.6/arch/powerpc/Makefile linux-2.6-powerpc-crtsavres/arch/powerpc/Makefile > --- linux-2.6/arch/powerpc/Makefile 2009-09-17 20:04:31.000000000 +0400 > +++ linux-2.6-powerpc-crtsavres/arch/powerpc/Makefile 2009-09-23 22:08:03.000000000 +0400 > @@ -93,7 +93,7 @@ else > KBUILD_CFLAGS += $(call cc-option,-mtune=power4) > endif > else > -LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o > +LDFLAGS_MODULE_PREREQ += arch/powerpc/lib/crtsavres.o > endif The naming sucks. How about: KBUILD_MODULE_LINK_SOURCE This would tell the reader that this is source to be linked on a module. And this is an arch specific thing so no need to preset it in top-level Makefile. But it is mandatory to include a description in Documentation/kbuild/kbuild.txt > --- linux-2.6/scripts/Makefile.modpost 2009-09-17 20:04:42.000000000 +0400 > +++ linux-2.6-powerpc-crtsavres/scripts/Makefile.modpost 2009-09-23 22:15:00.000000000 +0400 > @@ -122,14 +122,22 @@ quiet_cmd_cc_o_c = CC $@ > cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \ > -c -o $@ $< > > -$(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE > +quiet_cmd_as_o_S = AS $(quiet_modtag) $@ > +cmd_as_o_S = $(CC) $(a_flags) $(AFLAGS_MODULE) -c -o $@ $< Align this so cmd_as_o_S is under each other - as we do for cmd_cc_o_c > + > +$(LDFLAGS_MODULE_PREREQ): %.o: %.S FORCE > + $(Q)mkdir -p $(dir $@) > + $(call if_changed_dep,as_o_S) Good catch with the mkdir - needed for O= builds. I think we shall wrap this in ifdef KBUILD_MODULE_LINK_SOURCE ... endif So we do not have an empty rule when it is not defined. Please fix up these things and resubmit. Thanks, Sam ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] powerpc: build modules outside the kernel tree fails, if it was built using O= 2009-09-25 19:45 ` Sam Ravnborg @ 2009-09-25 21:57 ` Benjamin Herrenschmidt 2009-09-25 22:01 ` Sam Ravnborg 2009-09-26 12:45 ` Yuri Frolov 1 sibling, 1 reply; 9+ messages in thread From: Benjamin Herrenschmidt @ 2009-09-25 21:57 UTC (permalink / raw) To: Sam Ravnborg; +Cc: rep.dot.nop, Yuri Frolov, linuxppc-dev, linux-kbuild On Fri, 2009-09-25 at 21:45 +0200, Sam Ravnborg wrote: > On Thu, Sep 24, 2009 at 03:28:11PM +0400, Yuri Frolov wrote: > > Hello, > > > > here is a corresponding bug: http://bugzilla.kernel.org/show_bug.cgi?id=11143 > > This patch should correctly export crtsavres.o in order to make O= option working. > > Please, consider to apply. > > Hi Yuri. > > I like the way you do the extra link in Makefile.modpost. > But you need to redo some parts as per comments below. > > > > Fix linking modules against crtsavres.o > > Please elaborate more on what this commit does. It's a support file that needs to be linked against every module (aka libgcc like) and thus needs to be built before any module. Cheers, Ben. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] powerpc: build modules outside the kernel tree fails, if it was built using O= 2009-09-25 21:57 ` Benjamin Herrenschmidt @ 2009-09-25 22:01 ` Sam Ravnborg 0 siblings, 0 replies; 9+ messages in thread From: Sam Ravnborg @ 2009-09-25 22:01 UTC (permalink / raw) To: Benjamin Herrenschmidt Cc: rep.dot.nop, Yuri Frolov, linuxppc-dev, linux-kbuild On Sat, Sep 26, 2009 at 07:57:32AM +1000, Benjamin Herrenschmidt wrote: > On Fri, 2009-09-25 at 21:45 +0200, Sam Ravnborg wrote: > > On Thu, Sep 24, 2009 at 03:28:11PM +0400, Yuri Frolov wrote: > > > Hello, > > > > > > here is a corresponding bug: http://bugzilla.kernel.org/show_bug.cgi?id=11143 > > > This patch should correctly export crtsavres.o in order to make O= option working. > > > Please, consider to apply. > > > > Hi Yuri. > > > > I like the way you do the extra link in Makefile.modpost. > > But you need to redo some parts as per comments below. > > > > > > > Fix linking modules against crtsavres.o > > > > Please elaborate more on what this commit does. > > It's a support file that needs to be linked against every module > (aka libgcc like) and thus needs to be built before any module. Yes. My point was that the next version of the changelog should include this information - as well as kbuild.txt. Sam ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] powerpc: build modules outside the kernel tree fails, if it was built using O= 2009-09-25 19:45 ` Sam Ravnborg 2009-09-25 21:57 ` Benjamin Herrenschmidt @ 2009-09-26 12:45 ` Yuri Frolov 2009-09-30 13:50 ` Yuri Frolov 1 sibling, 1 reply; 9+ messages in thread From: Yuri Frolov @ 2009-09-26 12:45 UTC (permalink / raw) To: Sam Ravnborg; +Cc: rep.dot.nop, linuxppc-dev, linux-kbuild Hello, here is a fixed version. Compile and export arch/powerpc/lib/crtsavres.o in order to fix the "arch/powerpc/lib/crtsavres.o not found" error when "O=" option is employed for external module compilation. crtsavres.o is a support file, containing save/restore code from gcc, simplified down for powerpc architecture needs. This file needs to be linked against every module and thus to be built before any module. Documentation/kbuild/kbuild.txt | 8 ++++++++ Makefile | 2 +- arch/powerpc/Makefile | 2 +- scripts/Makefile.modpost | 14 ++++++++++++-- 4 files changed, 22 insertions(+), 4 deletions(-) diff -urpN -X linux-2.6/Documentation/dontdiff linux-2.6/arch/powerpc/Makefile linux-2.6-powerpc-crtsavres/arch/powerpc/Makefile --- linux-2.6/arch/powerpc/Makefile 2009-09-17 20:04:31.000000000 +0400 +++ linux-2.6-powerpc-crtsavres/arch/powerpc/Makefile 2009-09-26 13:35:32.000000000 +0400 @@ -93,7 +93,7 @@ else KBUILD_CFLAGS += $(call cc-option,-mtune=power4) endif else -LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o +KBUILD_MODULE_LINK_SOURCE += arch/powerpc/lib/crtsavres.o endif ifeq ($(CONFIG_TUNE_CELL),y) diff -urpN -X linux-2.6/Documentation/dontdiff linux-2.6/Documentation/kbuild/kbuild.txt linux-2.6-powerpc-crtsavres/Documentation/kbuild/kbuild.txt --- linux-2.6/Documentation/kbuild/kbuild.txt 2009-09-17 20:04:30.000000000 +0400 +++ linux-2.6-powerpc-crtsavres/Documentation/kbuild/kbuild.txt 2009-09-26 16:03:50.000000000 +0400 @@ -132,3 +132,11 @@ For tags/TAGS/cscope targets, you can sp to be included in the databases, separated by blank space. E.g.: $ make ALLSOURCE_ARCHS="x86 mips arm" tags + +KBUILD_MODULE_LINK_SOURCE +-------------------------------------------------- +Compile and export arch/powerpc/lib/crtsavres.o +when "O=" option is employed for powerpc external module compilation. +This file needs to be linked against every module and thus to be built +before any module. + diff -urpN -X linux-2.6/Documentation/dontdiff linux-2.6/Makefile linux-2.6-powerpc-crtsavres/Makefile --- linux-2.6/Makefile 2009-09-17 20:04:30.000000000 +0400 +++ linux-2.6-powerpc-crtsavres/Makefile 2009-09-26 14:23:27.000000000 +0400 @@ -354,7 +354,7 @@ KERNELVERSION = $(VERSION).$(PATCHLEVEL) export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE -export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS +export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS KBUILD_MODULE_LINK_SOURCE export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV diff -urpN -X linux-2.6/Documentation/dontdiff linux-2.6/scripts/Makefile.modpost linux-2.6-powerpc-crtsavres/scripts/Makefile.modpost --- linux-2.6/scripts/Makefile.modpost 2009-09-17 20:04:42.000000000 +0400 +++ linux-2.6-powerpc-crtsavres/scripts/Makefile.modpost 2009-09-26 14:34:28.000000000 +0400 @@ -122,14 +122,24 @@ quiet_cmd_cc_o_c = CC $@ cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \ -c -o $@ $< -$(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE +quiet_cmd_as_o_S = AS $(quiet_modtag) $@ + cmd_as_o_S = $(CC) $(a_flags) $(AFLAGS_MODULE) -c -o $@ $< + +ifdef KBUILD_MODULE_LINK_SOURCE +$(KBUILD_MODULE_LINK_SOURCE): %.o: %.S FORCE + $(Q)mkdir -p $(dir $@) + $(call if_changed_dep,as_o_S) +endif + +$(modules:.ko=.mod.o): %.mod.o: %.mod.c $(KBUILD_MODULE_LINK_SOURCE) FORCE $(call if_changed_dep,cc_o_c) targets += $(modules:.ko=.mod.o) # Step 6), final link of the modules quiet_cmd_ld_ko_o = LD [M] $@ - cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \ + cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(KBUILD_MODULE_LINK_SOURCE) \ + $(LDFLAGS_MODULE) -o $@ \ $(filter-out FORCE,$^) $(modules): %.ko :%.o %.mod.o FORCE On 09/25/2009 11:45 PM, Sam Ravnborg wrote: > On Thu, Sep 24, 2009 at 03:28:11PM +0400, Yuri Frolov wrote: >> Hello, >> >> here is a corresponding bug: http://bugzilla.kernel.org/show_bug.cgi?id=11143 >> This patch should correctly export crtsavres.o in order to make O= option working. >> Please, consider to apply. > > Hi Yuri. > > I like the way you do the extra link in Makefile.modpost. > But you need to redo some parts as per comments below. > >> >> Fix linking modules against crtsavres.o > > Please elaborate more on what this commit does. > >> Previously we got >> CC drivers/char/hw_random/rng-core.mod.o >> LD [M] drivers/char/hw_random/rng-core.ko >> /there/src/buildroot.git.ppc/build_powerpc_nofpu/staging_dir/usr/bin/powerpc-linux-uclibc-ld: arch/powerpc/lib/crtsavres.o: No such file: No such file or directory > > Always good to include error messages. > >> * Makefile (LDFLAGS_MODULE_PREREQ): New variable to hold prerequisite >> files for modules. >> * arch/powerpc/Makefile: add crtsavres.o to LDFLAGS_MODULE_PREREQ. >> * scripts/Makefile.modpost (cmd_as_o_S): Copy from Makefile.build. >> (cmd_ld_ko_o): Also link LDFLAGS_MODULE_PREREQ. >> Provide rule to build objects from assembler. > But this GNUism can go - we do not use it in the kernel. > >> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> >> Signed-off by: Yuri Frolov <yfrolov@ru.mvista.com> >> >> Makefile | 2 ++ >> arch/powerpc/Makefile | 2 +- >> scripts/Makefile.modpost | 12 ++++++++++-- >> 3 files changed, 13 insertions(+), 3 deletions(-) >> >> diff -urpN -X linux-2.6/Documentation/dontdiff linux-2.6/arch/powerpc/Makefile linux-2.6-powerpc-crtsavres/arch/powerpc/Makefile >> --- linux-2.6/arch/powerpc/Makefile 2009-09-17 20:04:31.000000000 +0400 >> +++ linux-2.6-powerpc-crtsavres/arch/powerpc/Makefile 2009-09-23 22:08:03.000000000 +0400 >> @@ -93,7 +93,7 @@ else >> KBUILD_CFLAGS += $(call cc-option,-mtune=power4) >> endif >> else >> -LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o >> +LDFLAGS_MODULE_PREREQ += arch/powerpc/lib/crtsavres.o >> endif > > The naming sucks. > How about: > > KBUILD_MODULE_LINK_SOURCE > > This would tell the reader that this is source to be linked on a module. > > And this is an arch specific thing so no need to preset it in top-level > Makefile. > But it is mandatory to include a description in Documentation/kbuild/kbuild.txt > > >> --- linux-2.6/scripts/Makefile.modpost 2009-09-17 20:04:42.000000000 +0400 >> +++ linux-2.6-powerpc-crtsavres/scripts/Makefile.modpost 2009-09-23 22:15:00.000000000 +0400 >> @@ -122,14 +122,22 @@ quiet_cmd_cc_o_c = CC $@ >> cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \ >> -c -o $@ $< >> >> -$(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE >> +quiet_cmd_as_o_S = AS $(quiet_modtag) $@ >> +cmd_as_o_S = $(CC) $(a_flags) $(AFLAGS_MODULE) -c -o $@ $< > > Align this so cmd_as_o_S is under each other - as we do for cmd_cc_o_c > > >> + >> +$(LDFLAGS_MODULE_PREREQ): %.o: %.S FORCE >> + $(Q)mkdir -p $(dir $@) >> + $(call if_changed_dep,as_o_S) > Good catch with the mkdir - needed for O= builds. > I think we shall wrap this in > ifdef KBUILD_MODULE_LINK_SOURCE > ... > endif > > So we do not have an empty rule when it is not defined. > > Please fix up these things and resubmit. > > Thanks, > Sam ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] powerpc: build modules outside the kernel tree fails, if it was built using O= 2009-09-26 12:45 ` Yuri Frolov @ 2009-09-30 13:50 ` Yuri Frolov 0 siblings, 0 replies; 9+ messages in thread From: Yuri Frolov @ 2009-09-30 13:50 UTC (permalink / raw) To: Sam Ravnborg; +Cc: rep.dot.nop, linuxppc-dev, linux-kbuild Hello, Any news yet? Any sort of correction needed? Thank you, Yuri On 09/26/2009 04:45 PM, Yuri Frolov wrote: > Hello, here is a fixed version. > > Compile and export arch/powerpc/lib/crtsavres.o in order to fix the > "arch/powerpc/lib/crtsavres.o not found" error when "O=" option > is employed for external module compilation. > crtsavres.o is a support file, containing save/restore code from gcc, > simplified down for powerpc architecture needs. > This file needs to be linked against every module and thus to be built > before any module. > > Documentation/kbuild/kbuild.txt | 8 ++++++++ > Makefile | 2 +- > arch/powerpc/Makefile | 2 +- > scripts/Makefile.modpost | 14 ++++++++++++-- > 4 files changed, 22 insertions(+), 4 deletions(-) > > diff -urpN -X linux-2.6/Documentation/dontdiff linux-2.6/arch/powerpc/Makefile linux-2.6-powerpc-crtsavres/arch/powerpc/Makefile > --- linux-2.6/arch/powerpc/Makefile 2009-09-17 20:04:31.000000000 +0400 > +++ linux-2.6-powerpc-crtsavres/arch/powerpc/Makefile 2009-09-26 13:35:32.000000000 +0400 > @@ -93,7 +93,7 @@ else > KBUILD_CFLAGS += $(call cc-option,-mtune=power4) > endif > else > -LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o > +KBUILD_MODULE_LINK_SOURCE += arch/powerpc/lib/crtsavres.o > endif > > ifeq ($(CONFIG_TUNE_CELL),y) > diff -urpN -X linux-2.6/Documentation/dontdiff linux-2.6/Documentation/kbuild/kbuild.txt linux-2.6-powerpc-crtsavres/Documentation/kbuild/kbuild.txt > --- linux-2.6/Documentation/kbuild/kbuild.txt 2009-09-17 20:04:30.000000000 +0400 > +++ linux-2.6-powerpc-crtsavres/Documentation/kbuild/kbuild.txt 2009-09-26 16:03:50.000000000 +0400 > @@ -132,3 +132,11 @@ For tags/TAGS/cscope targets, you can sp > to be included in the databases, separated by blank space. E.g.: > > $ make ALLSOURCE_ARCHS="x86 mips arm" tags > + > +KBUILD_MODULE_LINK_SOURCE > +-------------------------------------------------- > +Compile and export arch/powerpc/lib/crtsavres.o > +when "O=" option is employed for powerpc external module compilation. > +This file needs to be linked against every module and thus to be built > +before any module. > + > diff -urpN -X linux-2.6/Documentation/dontdiff linux-2.6/Makefile linux-2.6-powerpc-crtsavres/Makefile > --- linux-2.6/Makefile 2009-09-17 20:04:30.000000000 +0400 > +++ linux-2.6-powerpc-crtsavres/Makefile 2009-09-26 14:23:27.000000000 +0400 > @@ -354,7 +354,7 @@ KERNELVERSION = $(VERSION).$(PATCHLEVEL) > export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION > export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC > export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE > -export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS > +export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS KBUILD_MODULE_LINK_SOURCE > > export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS > export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV > diff -urpN -X linux-2.6/Documentation/dontdiff linux-2.6/scripts/Makefile.modpost linux-2.6-powerpc-crtsavres/scripts/Makefile.modpost > --- linux-2.6/scripts/Makefile.modpost 2009-09-17 20:04:42.000000000 +0400 > +++ linux-2.6-powerpc-crtsavres/scripts/Makefile.modpost 2009-09-26 14:34:28.000000000 +0400 > @@ -122,14 +122,24 @@ quiet_cmd_cc_o_c = CC $@ > cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \ > -c -o $@ $< > > -$(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE > +quiet_cmd_as_o_S = AS $(quiet_modtag) $@ > + cmd_as_o_S = $(CC) $(a_flags) $(AFLAGS_MODULE) -c -o $@ $< > + > +ifdef KBUILD_MODULE_LINK_SOURCE > +$(KBUILD_MODULE_LINK_SOURCE): %.o: %.S FORCE > + $(Q)mkdir -p $(dir $@) > + $(call if_changed_dep,as_o_S) > +endif > + > +$(modules:.ko=.mod.o): %.mod.o: %.mod.c $(KBUILD_MODULE_LINK_SOURCE) FORCE > $(call if_changed_dep,cc_o_c) > > targets += $(modules:.ko=.mod.o) > > # Step 6), final link of the modules > quiet_cmd_ld_ko_o = LD [M] $@ > - cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \ > + cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(KBUILD_MODULE_LINK_SOURCE) \ > + $(LDFLAGS_MODULE) -o $@ \ > $(filter-out FORCE,$^) > > $(modules): %.ko :%.o %.mod.o FORCE > > On 09/25/2009 11:45 PM, Sam Ravnborg wrote: >> On Thu, Sep 24, 2009 at 03:28:11PM +0400, Yuri Frolov wrote: >>> Hello, >>> >>> here is a corresponding bug: http://bugzilla.kernel.org/show_bug.cgi?id=11143 >>> This patch should correctly export crtsavres.o in order to make O= option working. >>> Please, consider to apply. >> Hi Yuri. >> >> I like the way you do the extra link in Makefile.modpost. >> But you need to redo some parts as per comments below. >> >>> Fix linking modules against crtsavres.o >> Please elaborate more on what this commit does. >> >>> Previously we got >>> CC drivers/char/hw_random/rng-core.mod.o >>> LD [M] drivers/char/hw_random/rng-core.ko >>> /there/src/buildroot.git.ppc/build_powerpc_nofpu/staging_dir/usr/bin/powerpc-linux-uclibc-ld: arch/powerpc/lib/crtsavres.o: No such file: No such file or directory >> Always good to include error messages. >> >>> * Makefile (LDFLAGS_MODULE_PREREQ): New variable to hold prerequisite >>> files for modules. >>> * arch/powerpc/Makefile: add crtsavres.o to LDFLAGS_MODULE_PREREQ. >>> * scripts/Makefile.modpost (cmd_as_o_S): Copy from Makefile.build. >>> (cmd_ld_ko_o): Also link LDFLAGS_MODULE_PREREQ. >>> Provide rule to build objects from assembler. >> But this GNUism can go - we do not use it in the kernel. >> >>> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> >>> Signed-off by: Yuri Frolov <yfrolov@ru.mvista.com> >>> >>> Makefile | 2 ++ >>> arch/powerpc/Makefile | 2 +- >>> scripts/Makefile.modpost | 12 ++++++++++-- >>> 3 files changed, 13 insertions(+), 3 deletions(-) >>> >>> diff -urpN -X linux-2.6/Documentation/dontdiff linux-2.6/arch/powerpc/Makefile linux-2.6-powerpc-crtsavres/arch/powerpc/Makefile >>> --- linux-2.6/arch/powerpc/Makefile 2009-09-17 20:04:31.000000000 +0400 >>> +++ linux-2.6-powerpc-crtsavres/arch/powerpc/Makefile 2009-09-23 22:08:03.000000000 +0400 >>> @@ -93,7 +93,7 @@ else >>> KBUILD_CFLAGS += $(call cc-option,-mtune=power4) >>> endif >>> else >>> -LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o >>> +LDFLAGS_MODULE_PREREQ += arch/powerpc/lib/crtsavres.o >>> endif >> The naming sucks. >> How about: >> >> KBUILD_MODULE_LINK_SOURCE >> >> This would tell the reader that this is source to be linked on a module. >> >> And this is an arch specific thing so no need to preset it in top-level >> Makefile. >> But it is mandatory to include a description in Documentation/kbuild/kbuild.txt >> >> >>> --- linux-2.6/scripts/Makefile.modpost 2009-09-17 20:04:42.000000000 +0400 >>> +++ linux-2.6-powerpc-crtsavres/scripts/Makefile.modpost 2009-09-23 22:15:00.000000000 +0400 >>> @@ -122,14 +122,22 @@ quiet_cmd_cc_o_c = CC $@ >>> cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \ >>> -c -o $@ $< >>> >>> -$(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE >>> +quiet_cmd_as_o_S = AS $(quiet_modtag) $@ >>> +cmd_as_o_S = $(CC) $(a_flags) $(AFLAGS_MODULE) -c -o $@ $< >> Align this so cmd_as_o_S is under each other - as we do for cmd_cc_o_c >> >> >>> + >>> +$(LDFLAGS_MODULE_PREREQ): %.o: %.S FORCE >>> + $(Q)mkdir -p $(dir $@) >>> + $(call if_changed_dep,as_o_S) >> Good catch with the mkdir - needed for O= builds. >> I think we shall wrap this in >> ifdef KBUILD_MODULE_LINK_SOURCE >> ... >> endif >> >> So we do not have an empty rule when it is not defined. >> >> Please fix up these things and resubmit. >> >> Thanks, >> Sam > ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-09-30 13:50 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-09-24 11:28 [patch] powerpc: build modules outside the kernel tree fails, if it was built using O= Yuri Frolov 2009-09-25 1:12 ` Benjamin Herrenschmidt 2009-09-25 4:39 ` Sam Ravnborg 2009-09-25 9:39 ` Yuri Frolov 2009-09-25 19:45 ` Sam Ravnborg 2009-09-25 21:57 ` Benjamin Herrenschmidt 2009-09-25 22:01 ` Sam Ravnborg 2009-09-26 12:45 ` Yuri Frolov 2009-09-30 13:50 ` Yuri Frolov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).