linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* using cc-option in arch/ppc64/boot/Makefile
@ 2004-10-14 16:11 Hollis Blanchard
  2004-10-17  9:57 ` Sam Ravnborg
  0 siblings, 1 reply; 5+ messages in thread
From: Hollis Blanchard @ 2004-10-14 16:11 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-kernel

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?

-- 
Hollis Blanchard
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: using cc-option in arch/ppc64/boot/Makefile
  2004-10-14 16:11 using cc-option in arch/ppc64/boot/Makefile Hollis Blanchard
@ 2004-10-17  9:57 ` Sam Ravnborg
  2004-10-18 13:47   ` Hollis Blanchard
  0 siblings, 1 reply; 5+ messages in thread
From: Sam Ravnborg @ 2004-10-17  9:57 UTC (permalink / raw)
  To: Hollis Blanchard; +Cc: Sam Ravnborg, linux-kernel

On Thu, Oct 14, 2004 at 04:11:32PM +0000, Hollis Blanchard wrote:
> 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?

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 =====
--- 1.26/scripts/Makefile.lib	2004-08-15 12:17:51 +02:00
+++ edited/scripts/Makefile.lib	2004-10-17 11:54:42 +02:00
@@ -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)))
+
+

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: using cc-option in arch/ppc64/boot/Makefile
  2004-10-17  9:57 ` Sam Ravnborg
@ 2004-10-18 13:47   ` Hollis Blanchard
  2004-10-18 21:01     ` Sam Ravnborg
  0 siblings, 1 reply; 5+ messages in thread
From: Hollis Blanchard @ 2004-10-18 13:47 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-kernel

On Sunday 17 October 2004 09:57, Sam Ravnborg wrote:
> 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:

--- 1.25/arch/ppc64/boot/Makefile       Sun Oct  3 12:23:50 2004
+++ edited/arch/ppc64/boot/Makefile     Mon Oct 18 14:03:40 2004
@@ -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?

-- 
Hollis Blanchard
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: using cc-option in arch/ppc64/boot/Makefile
  2004-10-18 21:01     ` Sam Ravnborg
@ 2004-10-18 15:58       ` Hollis Blanchard
  0 siblings, 0 replies; 5+ messages in thread
From: Hollis Blanchard @ 2004-10-18 15:58 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-kernel

On Monday 18 October 2004 21:01, Sam Ravnborg wrote:
> 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 =====
--- 1.25/arch/ppc64/boot/Makefile       Sun Oct  3 12:23:50 2004
+++ edited/arch/ppc64/boot/Makefile     Mon Oct 18 14:24:50 2004
@@ -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 =====
--- 1.26/scripts/Makefile.lib   Sun Aug 15 05:17:51 2004
+++ edited/scripts/Makefile.lib Wed Oct 13 14:13:38 2004
@@ -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


-- 
Hollis Blanchard
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: using cc-option in arch/ppc64/boot/Makefile
  2004-10-18 13:47   ` Hollis Blanchard
@ 2004-10-18 21:01     ` Sam Ravnborg
  2004-10-18 15:58       ` Hollis Blanchard
  0 siblings, 1 reply; 5+ messages in thread
From: Sam Ravnborg @ 2004-10-18 21:01 UTC (permalink / raw)
  To: Hollis Blanchard; +Cc: Sam Ravnborg, linux-kernel

On Mon, Oct 18, 2004 at 01:47:55PM +0000, Hollis Blanchard wrote:
> On Sunday 17 October 2004 09:57, Sam Ravnborg wrote:
> > 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:
> 
> --- 1.25/arch/ppc64/boot/Makefile       Sun Oct  3 12:23:50 2004
> +++ edited/arch/ppc64/boot/Makefile     Mon Oct 18 14:03:40 2004
> @@ -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.

>  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'

> +
>  vmlinux.strip: vmlinux FORCE
> +       echo $(cc-option-yn)
$(cc-option-yn) should not evaluate to 'y' - so you did something else wrong.
> +       echo $(HAS_BIARCH)
This should have been 'n' - but the 'y' is explained by the above bug.

> +       $(call cc-option-yn, -m64)
Here you try to execute 'y', this will fail.

>         $(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

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

	Sam

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-10-18 21:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-14 16:11 using cc-option in arch/ppc64/boot/Makefile Hollis Blanchard
2004-10-17  9:57 ` Sam Ravnborg
2004-10-18 13:47   ` Hollis Blanchard
2004-10-18 21:01     ` Sam Ravnborg
2004-10-18 15:58       ` Hollis Blanchard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).