Skip to contentSkip to conversation

Fix linking modules against crtsavres.o

PATCH In review Bernhard Reutner-Fischer 3 participants 4 messages Oct 9, 2008 – Oct 16, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix linking modules against crtsavres.o

Hi,

[ http://bugzilla.kernel.org/show_bug.cgi?id=11143 has it all]

targeting ppc(32), e.g. 405 (!fp), previously i 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.

The attached patch (same as attached to abovementioned bug) fixes this. I'm asking the ppc maintainers or you, Sam, to consider something to that effect for inclusing in the stable series.
thanks,

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.

arch/powerpc/Makefile renamed from ../x/linux-2.6.26.5.old/arch/powerpc/Makefile +1 -1
diff -rup ../../x/linux-2.6.26.5.old/arch/powerpc/Makefile linux-2.6.26.5/arch/powerpc/Makefile
@@ -97,7 +97,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)
Makefile renamed from ../x/linux-2.6.26.5.old/Makefile +2 -1
diff -rup ../../x/linux-2.6.26.5.old/Makefile linux-2.6.26.5/Makefile
@@ -318,6 +318,7 @@ MODFLAGS	= -DMODULE
 CFLAGS_MODULE   = $(MODFLAGS)
 AFLAGS_MODULE   = $(MODFLAGS)
 LDFLAGS_MODULE  =
+LDFLAGS_MODULE_PREREQ  =
 CFLAGS_KERNEL	=
 AFLAGS_KERNEL	=
 
@@ -342,7 +343,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 LDFLAGS_MODULE_PREREQ CHECK CHECKFLAGS
 
 export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
 export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
scripts/Makefile.modpost renamed from ../x/linux-2.6.26.5.old/scripts/Makefile.modpost +9 -2
diff -rup ../../x/linux-2.6.26.5.old/scripts/Makefile.modpost linux-2.6.26.5/scripts/Makefile.modpost
@@ -122,14 +122,21 @@ 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
+	$(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
#1 lore raw
Quoted 17 lines · Bernhard Reutner-Fischer

Hi,

[ http://bugzilla.kernel.org/show_bug.cgi?id=11143 has it all]

targeting ppc(32), e.g. 405 (!fp), previously i 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.

Quoted 4 lines

The attached patch (same as attached to abovementioned bug) fixes this. I'm asking the ppc maintainers or you, Sam, to consider something to that effect for inclusing in the stable series.
thanks,

This patch solves the problem for me. Without it building modules before the kernel proper fails to find crtsavres.o when linking.

Ben, Paul or Sam, could you please look at this and make comment if it is the right approach?

I also agree that this should be back ported to the stable series

(Note: for some reason this patch did *not* show up in patchwork).

Cheers,
g.

Quoted 80 lines

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.

diff -rup ../../x/linux-2.6.26.5.old/arch/powerpc/Makefile linux-2.6.26.5/arch/powerpc/Makefile

arch/powerpc/Makefile renamed from ../x/linux-2.6.26.5.old/arch/powerpc/Makefile +1 -1
@@ -97,7 +97,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 -rup ../../x/linux-2.6.26.5.old/Makefile linux-2.6.26.5/Makefile

Makefile renamed from ../x/linux-2.6.26.5.old/Makefile +2 -1
@@ -318,6 +318,7 @@ MODFLAGS	= -DMODULE
 CFLAGS_MODULE   = $(MODFLAGS)
 AFLAGS_MODULE   = $(MODFLAGS)
 LDFLAGS_MODULE  =
+LDFLAGS_MODULE_PREREQ  =
 CFLAGS_KERNEL	=
 AFLAGS_KERNEL	=
 
@@ -342,7 +343,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 LDFLAGS_MODULE_PREREQ CHECK CHECKFLAGS
 
 export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
 export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE

diff -rup ../../x/linux-2.6.26.5.old/scripts/Makefile.modpost linux-2.6.26.5/scripts/Makefile.modpost

scripts/Makefile.modpost renamed from ../x/linux-2.6.26.5.old/scripts/Makefile.modpost +9 -2
@@ -122,14 +122,21 @@ 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
+	$(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
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

#2 lore raw
Quoted 27 lines · Grant Likely
Quoted 18 lines · Bernhard Reutner-Fischer

Hi,

[ http://bugzilla.kernel.org/show_bug.cgi?id=11143 has it all]

targeting ppc(32), e.g. 405 (!fp), previously i 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.

Quoted 4 lines

The attached patch (same as attached to abovementioned bug) fixes this. I'm asking the ppc maintainers or you, Sam, to consider something to that effect for inclusing in the stable series.
thanks,

This patch solves the problem for me. Without it building modules before the kernel proper fails to find crtsavres.o when linking.

Quoted 6 lines

Ben, Paul or Sam, could you please look at this and make comment if it is the right approach?

I also agree that this should be back ported to the stable series

(Note: for some reason this patch did *not* show up in patchwork).

because it was sent as an attachment.

- k

#3 lore raw
Quoted 11 lines · Kumar Gala
Quoted 8 lines · Grant Likely
Quoted 3 lines · Bernhard Reutner-Fischer

Hi,

[ http://bugzilla.kernel.org/show_bug.cgi?id=11143 has it all]

This patch solves the problem for me. Without it building modules before the kernel proper fails to find crtsavres.o when linking.

I did not install the .o nor it's prerequisites so only fixed building modules in tree. For building external modules these LDFLAGS_MODULE_PREREQ would need to be installed too, as noted by Olaf in the bug. I do not need them to be installed myself, so please take care of it if you have time to do so.

Quoted 8 lines
Quoted 6 lines

Ben, Paul or Sam, could you please look at this and make comment if it is the right approach?

I also agree that this should be back ported to the stable series

(Note: for some reason this patch did *not* show up in patchwork).

because it was sent as an attachment.

Indeed. Sorry for that..