Skip to contentSkip to conversation

using cc-option in arch/ppc64/boot/Makefile

DISCUSSION Hollis Blanchard 2 participants 5 messages Oct 14, 2004 – Oct 18, 2004 Kbuild

lore
Share & tools
lore
#0 lore raw

Hi Sam, I would like to use "cc-option-yn" in arch/ppc64/boot/Makefile.

All recent 64-bit gcc/binutils can produce 32-bit code by passing -m32 (or similar) to them. arch/ppc64/boot/zImage is actually a 32-bit executable, and the Makefile still requires a separate 32-bit cross-compiler to build it (in addition to the 64-bit cross-compiler used for the vmlinux). To decide if $(CC) can handle -m32, I'd like to use cc-option-yn (as in arch/ppc64/Makefile).

I've tried moving the cc-option stuff out of the top-level Makefile into something that can be included from arch/ppc64/boot/Makefile, but so far the right magic has escaped me. Any ideas?

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#1 lore raw
Quoted 9 lines · Hollis Blanchard

Hi Sam, I would like to use "cc-option-yn" in arch/ppc64/boot/Makefile.

All recent 64-bit gcc/binutils can produce 32-bit code by passing -m32 (or similar) to them. arch/ppc64/boot/zImage is actually a 32-bit executable, and the Makefile still requires a separate 32-bit cross-compiler to build it (in addition to the 64-bit cross-compiler used for the vmlinux). To decide if $(CC) can handle -m32, I'd like to use cc-option-yn (as in arch/ppc64/Makefile).

Quoted 3 lines

I've tried moving the cc-option stuff out of the top-level Makefile into something that can be included from arch/ppc64/boot/Makefile, but so far the right magic has escaped me. Any ideas?

Something like this should do the trick?
You could also include everything in your Makefile but I prefer Makefile.lib to make it a bit more general.

I need to sanitize Makefile.lib before I like to do it in mainline though.

Sam

===== scripts/Makefile.lib 1.26 vs edited =====

scripts/Makefile.lib +31 -0
@@ -232,3 +232,34 @@
 # Usage:
 # $(Q)$(MAKE) $(build)=dir
 build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
+
+######
+# cc support functions to be used (only) in arch/$(ARCH)/Makefile
+# See documentation in Documentation/kbuild/makefiles.txt
+
+# cc-option
+# Usage: cflags-y += $(call gcc-option, -march=winchip-c6, -march=i586)
+
+cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
+             > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
+
+# For backward compatibility
+check_gcc = $(warning check_gcc is deprecated - use cc-option) \
+            $(call cc-option, $(1),$(2))
+
+# cc-option-yn
+# Usage: flag := $(call gcc-option-yn, -march=winchip-c6)
+cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
+                > /dev/null 2>&1; then echo "y"; else echo "n"; fi;)
+
+# cc-option-align
+# Prefix align with either -falign or -malign
+cc-option-align = $(subst -functions=0,,\
+	$(call cc-option,-falign-functions=0,-malign-functions=0))
+
+# cc-version
+# Usage gcc-ver := $(call cc-version $(CC))
+cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \
+              $(if $(1), $(1), $(CC)))
+
+
#2 lore raw
Quoted 3 lines · Sam Ravnborg

Something like this should do the trick?
You could also include everything in your Makefile but I prefer Makefile.lib to make it a bit more general.

That's what I had tried. I'm having strange problems though. This patch:

arch/ppc64/boot/Makefile Mon Oct 18 14:03:40 2004 renamed from arch/ppc64/boot/Makefile Sun Oct 3 12:23:50 2004 +7 -0
@@ -20,6 +20,8 @@
 #      CROSS32_COMPILE is setup as a prefix just like CROSS_COMPILE
 #      in the toplevel makefile.
 
+include scripts/Makefile.lib
+
 CROSS32_COMPILE ?=
 #CROSS32_COMPILE = /usr/local/ppc/bin/powerpc-linux-
 
@@ -72,7 +74,12 @@
 quiet_cmd_stripvm = STRIP $@
       cmd_stripvm = $(STRIP) -s $< -o $@
 
+HAS_BIARCH      := $(call cc-option-yn, -lalala)
+
 vmlinux.strip: vmlinux FORCE
+       echo $(cc-option-yn)
+       echo $(HAS_BIARCH)
+       $(call cc-option-yn, -m64)
        $(call if_changed,stripvm)
 $(obj)/vmlinux.initrd: vmlinux.strip $(obj)/addRamDisk 

$(obj)/ramdisk.image.gz FORCE

        $(call if_changed,ramdisk)

... yields the following output:

make -f scripts/Makefile.build obj=arch/ppc64/boot arch/ppc64/boot/zImage echo y
y
echo y
y
y
make[1]: y: Command not found

Also confusing: the gcc switch "-lalala" is invalid, so I don't know where *any* y's came from. User error?

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#3 lore raw
Quoted 10 lines · Hollis Blanchard
Quoted 3 lines · Sam Ravnborg

Something like this should do the trick?
You could also include everything in your Makefile but I prefer Makefile.lib to make it a bit more general.

That's what I had tried. I'm having strange problems though. This patch:

arch/ppc64/boot/Makefile Mon Oct 18 14:03:40 2004 line 24

Quoted 5 lines
arch/ppc64/boot/Makefile Mon Oct 18 14:03:40 2004 renamed from arch/ppc64/boot/Makefile Sun Oct 3 12:23:50 2004 +2 -0
@@ -20,6 +20,8 @@
 #      CROSS32_COMPILE is setup as a prefix just like CROSS_COMPILE
 #      in the toplevel makefile.
 
+include scripts/Makefile.lib
+

This is wrong. kbuild will include Makefile.lib for you.

arch/ppc64/boot/Makefile Mon Oct 18 14:03:40 2004 line 77

Quoted 8 lines
arch/ppc64/boot/Makefile Mon Oct 18 14:03:40 2004 renamed from arch/ppc64/boot/Makefile Sun Oct 3 12:23:50 2004 +1 -0
 CROSS32_COMPILE ?=
 #CROSS32_COMPILE = /usr/local/ppc/bin/powerpc-linux-
 
@@ -72,7 +74,12 @@
 quiet_cmd_stripvm = STRIP $@
       cmd_stripvm = $(STRIP) -s $< -o $@
 
+HAS_BIARCH      := $(call cc-option-yn, -lalala)

so HAS_BIARCH will evaluate to 'n'

arch/ppc64/boot/Makefile Mon Oct 18 14:03:40 2004 line 80

Quoted 3 lines
arch/ppc64/boot/Makefile Mon Oct 18 14:03:40 2004 renamed from arch/ppc64/boot/Makefile Sun Oct 3 12:23:50 2004 +2 -0
+
 vmlinux.strip: vmlinux FORCE
+       echo $(cc-option-yn)

$(cc-option-yn) should not evaluate to 'y' - so you did something else wrong.

arch/ppc64/boot/Makefile Mon Oct 18 14:03:40 2004 line 81

Quoted 1 line
arch/ppc64/boot/Makefile Mon Oct 18 14:03:40 2004 renamed from arch/ppc64/boot/Makefile Sun Oct 3 12:23:50 2004 +1 -0
+       echo $(HAS_BIARCH)

This should have been 'n' - but the 'y' is explained by the above bug.

arch/ppc64/boot/Makefile Mon Oct 18 14:03:40 2004 line 82

Quoted 1 line
arch/ppc64/boot/Makefile Mon Oct 18 14:03:40 2004 renamed from arch/ppc64/boot/Makefile Sun Oct 3 12:23:50 2004 +1 -0
+       $(call cc-option-yn, -m64)

Here you try to execute 'y', this will fail.

Quoted 7 lines
arch/ppc64/boot/Makefile Mon Oct 18 14:03:40 2004 renamed from arch/ppc64/boot/Makefile Sun Oct 3 12:23:50 2004 +0 -0
        $(call if_changed,stripvm)
 $(obj)/vmlinux.initrd: vmlinux.strip $(obj)/addRamDisk 

$(obj)/ramdisk.image.gz FORCE

        $(call if_changed,ramdisk)

... yields the following output:

Quoted 7 lines

make -f scripts/Makefile.build obj=arch/ppc64/boot arch/ppc64/boot/zImage echo y
y
echo y
y
y
make[1]: y: Command not found

Skip the include of Mafilefile.lib and try again. If you still has troubles try posting a complete diff.

Sam

#4 lore raw
Quoted 2 lines · Sam Ravnborg

Skip the include of Mafilefile.lib and try again. If you still has troubles try posting a complete diff.

Complete diff:

===== arch/ppc64/boot/Makefile 1.25 vs edited =====

arch/ppc64/boot/Makefile Mon Oct 18 14:24:50 2004 renamed from arch/ppc64/boot/Makefile Sun Oct 3 12:23:50 2004 +5 -0
@@ -72,7 +72,12 @@
 quiet_cmd_stripvm = STRIP $@
       cmd_stripvm = $(STRIP) -s $< -o $@
 
+HAS_BIARCH      := $(call cc-option-yn, -lalala)
+
 vmlinux.strip: vmlinux FORCE
+       echo $(cc-option-yn)
+       echo $(HAS_BIARCH)
+       $(call cc-option-yn, -m64)
        $(call if_changed,stripvm)
 $(obj)/vmlinux.initrd: vmlinux.strip $(obj)/addRamDisk 

$(obj)/ramdisk.image.gz FORCE

        $(call if_changed,ramdisk)

===== scripts/Makefile.lib 1.26 vs edited =====

scripts/Makefile.lib Wed Oct 13 14:13:38 2004 renamed from scripts/Makefile.lib Sun Aug 15 05:17:51 2004 +25 -0
@@ -232,3 +232,28 @@
 # Usage:
 # $(Q)$(MAKE) $(build)=dir
 build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
+
+######
+# cc support functions to be used (only) in arch/$(ARCH)/Makefile
+# See documentation in Documentation/kbuild/makefiles.txt
+
+# cc-option
+# Usage: cflags-y += $(call gcc-option, -march=winchip-c6, -march=i586)
+
+cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
+             > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
+
+# For backward compatibility
+check_gcc = $(warning check_gcc is deprecated - use cc-option) \
+            $(call cc-option, $(1),$(2))
+
+# cc-option-yn
+# Usage: flag := $(call gcc-option-yn, -march=winchip-c6)
+cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null 
\
+                > /dev/null 2>&1; then echo "y"; else echo "n"; fi;)
+
+# cc-version
+# Usage gcc-ver := $(call cc-version $(CC))
+cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \
+              $(if $(1), $(1), $(CC)))
+

Output:
...
make -f scripts/Makefile.build obj=arch/ppc64/boot arch/ppc64/boot/zImage echo y
y
echo

y
make[1]: y: Command not found

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center