Skip to contentSkip to conversation

kbuild: A couple of Kbuild fixes/improvements

PATCH New Andi Kleen 1 participant 6 messages Aug 5, 2009 Kbuild

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

cover kbuild: A couple of Kbuild fixes/improvements

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 earlier today.

-Andi

author
#1 lore raw

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
Index: linux-2.6.31-rc1-ak/scripts/Kbuild.include
===================================================================
@@ -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))
 
 ######
 
author
#2 lore raw

PATCH 2/5 kbuild: Check if linker supports the -X option

In reply to Andi Kleen

The 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
Index: linux-2.6.31-rc1-ak/Makefile
===================================================================
@@ -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.
author
#3 lore raw

PATCH 3/5 kbuild: Echo the record_mcount command

In reply to Andi Kleen

I 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
Index: linux-2.6.31-rc1-ak/scripts/Makefile.build
===================================================================
@@ -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;  \
author
#4 lore raw

PATCH 4/5 kbuild: Fail build if recordmcount.pl fails

In reply to Andi Kleen

When 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
Index: linux-2.6.31-rc1-ak/scripts/Makefile.build
===================================================================
@@ -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)" "$(@)";
author
#5 lore raw

PATCH 5/5 kbuild: Set -fconserve-stack option for gcc 4.5

In reply to Andi Kleen

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.

---
 Makefile |    3 +++
 1 file changed, 3 insertions(+)
Makefile +3 -0
Index: linux-2.6.31-rc3-ak/Makefile
===================================================================
@@ -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 = \