Skip to contentSkip to conversation

Allow overriding of CC in powerpc kernel build

PATCH David Gibson 1 participant 1 message Nov 9, 2009 PowerPC

lore
Share & tools
lore
#0 lore raw

arch/powerpc/Makefile uses make 'override' directives to add -m32 or -m64 depending on config to the CC variable, and matching options to the AS, LD and AR variables to correctly use a biarch compiler.

Unfortunately this doesn't work as intended if you actually attempt to set CC from the make command line. They correctly augment the given CC variable in the top-level make instance, but at least some of the second-level make invocations don't include arch/powerpc/Makefile, so the command line override is used directly, and we attempt to compile without the correct -m64 or similar option.

This patch alters the way we set up the biarch flags so that CC can be overriden from the command line as expected (this is useful when using ccontrol as a compiler wrapper). The approach is based roughly on the way x86 handles the analagous problem for i386/x86_64 biarch compilers, with some additional hacks to make the VDSO compilation work.

arch/powerpc/Makefile +4 -4
Index: linux-a2/arch/powerpc/Makefile
===================================================================
@@ -57,10 +57,10 @@ endif
 UTS_MACHINE := $(OLDARCH)
 
 ifeq ($(HAS_BIARCH),y)
-override AS	+= -a$(CONFIG_WORD_SIZE)
-override LD	+= -m elf$(CONFIG_WORD_SIZE)ppc
-override CC	+= -m$(CONFIG_WORD_SIZE)
-override AR	:= GNUTARGET=elf$(CONFIG_WORD_SIZE)-powerpc $(AR)
+	KBUILD_AFLAGS += -m$(CONFIG_WORD_SIZE)
+	KBUILD_CFLAGS += -m$(CONFIG_WORD_SIZE)
+	LDFLAGS := -m elf$(CONFIG_WORD_SIZE)ppc
+	override AR	:= GNUTARGET=elf$(CONFIG_WORD_SIZE)-powerpc $(AR)
 endif
 
 LDFLAGS_vmlinux-yy := -Bstatic
arch/powerpc/kernel/vdso32/Makefile +5 -2
Index: linux-a2/arch/powerpc/kernel/vdso32/Makefile
===================================================================
@@ -40,10 +40,13 @@ $(obj-vdso32): %.o: %.S
 	$(call if_changed_dep,vdso32as)
 
 # actual build commands
+biarch	:= $(call cc-option, -m32)
+c_flags_32 = $(filter-out -m64,$(c_flags)) $(biarch)
+a_flags_32 = $(filter-out -m64,$(a_flags)) $(biarch)
 quiet_cmd_vdso32ld = VDSO32L $@
-      cmd_vdso32ld = $(CROSS32CC) $(c_flags) -Wl,-T $^ -o $@
+      cmd_vdso32ld = $(CROSS32CC) $(c_flags_32) -Wl,-T $^ -o $@
 quiet_cmd_vdso32as = VDSO32A $@
-      cmd_vdso32as = $(CROSS32CC) $(a_flags) -c -o $@ $<
+      cmd_vdso32as = $(CROSS32CC) $(a_flags_32) -c -o $@ $<
 
 # install commands for the unstripped file
 quiet_cmd_vdso_install = INSTALL $@
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson