kbuild: A couple of Kbuild fixes/improvements
cover kbuild: A couple of Kbuild fixes/improvements
I sent those some time ago, but nobody seems to have merged them. Sam? They are all 2.6.32 canidated.
Some build system patches that accumulated in my tree:
- Fix mcount handling
- Fix gold linker support
- Add some gcc 4.5 support
One will address the problem Dave A. reported some time ago.
-Andi
PATCH 1/5 kbuild: Fix ld-option Makefile macro to really work
Needed for the next patch
--- scripts/Kbuild.include | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
scripts/Kbuild.include +3 -2
@@ -83,11 +83,12 @@ TMPOUT := $(if $(KBUILD_EXTMOD),$(firstw # is automatically cleaned up. try-run = $(shell set -e; \ TMP="$(TMPOUT).$$$$.tmp"; \ + TMPO="$(TMPOUT).$$$$.o"; \ if ($(1)) >/dev/null 2>&1; \ then echo "$(2)"; \ else echo "$(3)"; \ fi; \ - rm -f "$$TMP") + rm -f "$$TMP" "$$TMPO") # as-option # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
@@ -133,7 +134,7 @@ cc-ifversion = $(shell [ $(call cc-versi # ld-option # Usage: ldflags += $(call ld-option, -Wl$(comma)--hash-style=both) ld-option = $(call try-run,\ - $(CC) $(1) -nostdlib -xc /dev/null -o "$$TMP",$(1),$(2)) + $(CC) /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) ######
PATCH 3/5 kbuild: Echo the record_mcount command
In reply to Andi KleenI had some problems with record_mcount in the Makefile and it was hard to track down. Echo it by default to make it easier to diagnose.
--- scripts/Makefile.build | 1 + 1 file changed, 1 insertion(+)
scripts/Makefile.build +1 -0
@@ -216,6 +216,7 @@ define rule_cc_o_c $(call echo-cmd,checksrc) $(cmd_checksrc) \ $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ $(cmd_modversions) \ + $(call echo-cmd,record_mcount) \ $(cmd_record_mcount) \ scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ $(dot-target).tmp; \
PATCH 5/5 kbuild: Set -fconserve-stack option for gcc 4.5
In reply to Andi KleenThe upcomming gcc 4.5 has a new -fconserve-stack option that tells the inliner to take stack frame size in account. Set it if the compiler supports it.
--- Makefile | 3 +++ 1 file changed, 3 insertions(+)
Makefile +3 -0
@@ -575,6 +575,9 @@ KBUILD_CFLAGS += $(call cc-option,-fno-s # revert to pre-gcc-4.4 behaviour of .eh_frame KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm) +# conserve stack if available +KBUILD_CFLAGS += $(call cc-option,-fconserve-stack) + # Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments # But warn user when we do so warn-assign = \
PATCH 2/5 kbuild: Check if linker supports the -X option
In reply to Andi KleenThe new alternative `gold' linker in recent binutils doesn't support the -X option. This breaks allyesconfig builds that have CONFIG_STRIP_ASM_SYMS enabled. Check if the linker really supports the option using ld-option.
This requires fixes in earlier patches.
--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
@@ -599,7 +599,7 @@ LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) ifeq ($(CONFIG_STRIP_ASM_SYMS),y) -LDFLAGS_vmlinux += -X +LDFLAGS_vmlinux += $(call ld-option, -X,) endif # Default kernel image to build when no specific target is given.
PATCH 4/5 kbuild: Fail build if recordmcount.pl fails
In reply to Andi KleenWhen this script fails the build should fail too. Otherwise there are mysterious build failures later.
--- scripts/Makefile.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.build +1 -1
@@ -206,7 +206,7 @@ cmd_modversions = \ endif ifdef CONFIG_FTRACE_MCOUNT_RECORD -cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ +cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ "$(if $(CONFIG_64BIT),64,32)" \ "$(OBJDUMP)" "$(OBJCOPY)" "$(CC)" "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ "$(if $(part-of-module),1,0)" "$(@)";
Re: [PATCH] [5/5] kbuild: Set -fconserve-stack option for gcc 4.5
In reply to Andi KleenQuoted 16 lines · On Mon, 14 Sep 2009 22:18:11 +0200 (CEST) Andi Kleen <[email protected]>…
The upcomming gcc 4.5 has a new -fconserve-stack option that tells the inliner to take stack frame size in account. Set it if the compiler supports it.
Signed-off-by Andi Kleen <[email protected]>--- Makefile | 3 +++ 1 file changed, 3 insertions(+)Index: linux-2.6.31-rc3-ak/Makefile
===================================================================
Makefile KBUILD_CFLAGS += $(call cc-option,-fno-s · line 579
Quoted 5 lines
Makefile +2
-0@@ -575,6 +575,9 @@ KBUILD_CFLAGS += $(call cc-option,-fno-s # revert to pre-gcc-4.4 behaviour of .eh_frame KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm) +# conserve stack if available +KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)
Do we have any info about what effects this option has upon the generated code? Text size changes, runtime stack usage changes, etc?
Quoted 2 lines · Andi Kleen
I sent those some time ago, but nobody seems to have merged them. Sam?
Then I should have them queued somewhere...
Last months has been busy (again) so not much time for Linux stuff. Will find time to prepare some of my pending stuff for merge - hopefully before the weekend.
Thanks for the resend - let's see if andrew or I merge them first.
Sam
Re: [PATCH] [1/5] kbuild: Fix ld-option Makefile macro to really work
In reply to Andi KleenQuoted 28 lines · Andi Kleen
Needed for the next patch
Signed-off-by Andi Kleen <[email protected]>--- scripts/Kbuild.include | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)Index: linux-2.6.31-rc1-ak/scripts/Kbuild.include
===================================================================scripts/Kbuild.include +2
-1@@ -83,11 +83,12 @@ TMPOUT := $(if $(KBUILD_EXTMOD),$(firstw # is automatically cleaned up. try-run = $(shell set -e; \ TMP="$(TMPOUT).$$$$.tmp"; \ + TMPO="$(TMPOUT).$$$$.o"; \ if ($(1)) >/dev/null 2>&1; \ then echo "$(2)"; \ else echo "$(3)"; \ fi; \ - rm -f "$$TMP") + rm -f "$$TMP" "$$TMPO") # as-option # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
scripts/Kbuild.include cc-ifversion = $(shell [ $(call cc-versi · line 139
Quoted 7 lines
scripts/Kbuild.include +1
-1@@ -133,7 +134,7 @@ cc-ifversion = $(shell [ $(call cc-versi # ld-option # Usage: ldflags += $(call ld-option, -Wl$(comma)--hash-style=both) ld-option = $(call try-run,\ - $(CC) $(1) -nostdlib -xc /dev/null -o "$$TMP",$(1),$(2)) + $(CC) /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) ######
So now we pass the option direct to the linker rather than via gcc -wl. I assume this breaks the other 8 uses of ld-option in the kernel?
Or does ld understand the -wl,... syntax?
Sam
Quoted 11 lines · On Mon, 14 Sep 2009 23:43:47 +0200 Sam Ravnborg <[email protected]> wrote:
Quoted 2 lines · Andi Kleen
I sent those some time ago, but nobody seems to have merged them. Sam?
Then I should have them queued somewhere...
Last months has been busy (again) so not much time for Linux stuff. Will find time to prepare some of my pending stuff for merge - hopefully before the weekend.Thanks for the resend - let's see if andrew or I merge them first.
Well, I'd prefer not to merge kbuild stuff as long as you're showing signs of life.
I'll now hose these:
gitignore-usr-initramfs_datacpiobz2-and-usr-initramfs_datacpiolzma.patch kernel-hacking-move-strip_asm_syms-from-general.patch kbuild-add-static-to-prototypes.patch
ctags-usability-fix.patch checkincludespl-close-file-as-soon-as-were-done-with-it.patch checkincludespl-provide-usage-helper.patch checkincludespl-add-option-to-remove-duplicates-in-place.patch markup_oops-use-modinfo-to-avoid-confusion-with-underscored-module-names.patch kbuild-generate-modulesbuiltin.patch kbuild-rebuild-fix-for-makefilemodbuiltin.patch kconfig-cross_compile-option.patch kbuild-fix-cc1-options-check-to-ensure-we-do-not-use-fpic-when-compiling.patch gconfig-disable-typeahead-find-search-in-treeviews.patch kbuild-fix-ld-option-makefile-macro-to-really-work.patch kbuild-check-if-linker-supports-the-x-option.patch kbuild-echo-the-record_mcount-command.patch kbuild-fail-build-if-recordmcountpl-fails.patch kbuild-set-fconserve-stack-option-for-gcc-45.patch
at you :)
Re: [PATCH] [1/5] kbuild: Fix ld-option Makefile macro to really work
In reply to Sam RavnborgQuoted 4 lines
So now we pass the option direct to the linker rather than via gcc -wl. I assume this breaks the other 8 uses of ld-option in the kernel?
Or does ld understand the -wl,... syntax?
It does not. But -X is passed directly to the linker, not via gcc, so it needs to probe ld directly
The right fix is probably an new macro that works with ld (and ideally rename this one which is confusingly named) I'll send an updated patch.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.
Re: [PATCH] [1/5] kbuild: Fix ld-option Makefile macro to really work
Quoted 11 lines · Andi Kleen
Quoted 4 lines
So now we pass the option direct to the linker rather than via gcc -wl. I assume this breaks the other 8 uses of ld-option in the kernel?
Or does ld understand the -wl,... syntax?
It does not. But -X is passed directly to the linker, not via gcc, so it needs to probe ld directly
The right fix is probably an new macro that works with ld (and ideally rename this one which is confusingly named) I'll send an updated patch.
Thanks.
Please do remember to update the documentation
in Documentation/kbuild/makefiles.txt.
Sam
Re: [PATCH] [5/5] kbuild: Set -fconserve-stack option for gcc 4.5
In reply to Andrew MortonQuoted 22 lines · Andrew Morton
Quoted 19 lines · On Mon, 14 Sep 2009 22:18:11 +0200 (CEST) Andi Kleen <[email protected]>…
The upcomming gcc 4.5 has a new -fconserve-stack option that tells the inliner to take stack frame size in account. Set it if the compiler supports it.
Signed-off-by Andi Kleen <[email protected]>--- Makefile | 3 +++ 1 file changed, 3 insertions(+)Index: linux-2.6.31-rc3-ak/Makefile
===================================================================Makefile +0
-0@@ -575,6 +575,9 @@ KBUILD_CFLAGS += $(call cc-option,-fno-s # revert to pre-gcc-4.4 behaviour of .eh_frame KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm)
Quoted 5 lines
Makefile KBUILD_CFLAGS += $(call cc-option,-fno-s · line 579
Quoted 2 lines
Makefile +2
-0+# conserve stack if available +KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)Do we have any info about what effects this option has upon the generated code? Text size changes, runtime stack usage changes, etc?
I merged this despite the relevant questions above was not answered. But maybe we should wait until Andi gets back with numbers?
Sam
Re: [PATCH] [5/5] kbuild: Set -fconserve-stack option for gcc 4.5
Quoted 23 lines · Sam Ravnborg
Quoted 22 lines · Andrew Morton
Quoted 19 lines · On Mon, 14 Sep 2009 22:18:11 +0200 (CEST) Andi Kleen <[email protected]>…
The upcomming gcc 4.5 has a new -fconserve-stack option that tells the inliner to take stack frame size in account. Set it if the compiler supports it.
Signed-off-by Andi Kleen <[email protected]>--- Makefile | 3 +++ 1 file changed, 3 insertions(+)Index: linux-2.6.31-rc3-ak/Makefile
===================================================================Makefile +0
-0@@ -575,6 +575,9 @@ KBUILD_CFLAGS += $(call cc-option,-fno-s # revert to pre-gcc-4.4 behaviour of .eh_frame KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm)
Quoted 8 lines
Quoted 5 lines
Makefile KBUILD_CFLAGS += $(call cc-option,-fno-s · line 579
Quoted 2 lines
Makefile +2
-0+# conserve stack if available +KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)Do we have any info about what effects this option has upon the generated code? Text size changes, runtime stack usage changes, etc?
I merged this despite the relevant questions above was not answered. But maybe we should wait until Andi gets back with numbers?
It only changes some inlining decisions, nothing dramatic. The main value is in avoiding surprises in the future when the gcc inlining algorithms change again or long term when everyone uses gcc 4.5 the current manual hacks to avoid this could be dropped.
Here's some quick data for 64bit with a slightly older gcc snapshot:
text data bss dec hex filename
8288629 1399680 1512012 11200321 aae741 vmlinux-45-no-conserve
8298155 1403776 1512012 11213943 ab1c77 vmlinux-45-with-conserve
Only a few hundred bytes difference in text size, at the cost of a 4k larger data segment (I suspect that's because of the 4K padding)
At least the top stack users don't really change significantly (I suspect because most of the inline problems have been handled manually already)
If I do statistics over all stack users there's about 4K less stack used over all functions. Not dramatic.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.