2006-01-21 18:08:18

by Olaf Hering

[permalink] [raw]
Subject: cc-version not available to change EXTRA_CFLAGS


I want to add a gcc version check for reiserfs, on akpms request.
This one doesnt work with 2.6.16rc1, havent checked if it ever worked.


make -kj14 O=../O-powerpc-ppc64-defconfig arch/powerpc/mm/mem.o
GEN /home/olaf/kernel/olh/ppc64/O-powerpc-ppc64-defconfig/Makefile
scripts/kconfig/conf -s arch/powerpc/Kconfig
arch/powerpc/platforms/83xx/Kconfig:10:warning: 'select' used by config symbol 'MPC834x_SYS' refer to undefined symbol 'DEFAULT_UIMAGE'
#
# using defaults found in .config
#
make[3]: `.kernelrelease' is up to date.
SPLIT include/linux/autoconf.h -> include/config/*
+ '[' -lt 0400 ']'
/bin/sh: line 1: [: -lt: unary operator expected
make[2]: `arch/powerpc/mm/mem.o' is up to date.
olaf@pomegranate:~/kernel/olh/ppc64/linux-2.6.16-rc1-olh> quilt diff
Index: linux-2.6.16-rc1-olh/arch/powerpc/mm/Makefile
===================================================================
--- linux-2.6.16-rc1-olh.orig/arch/powerpc/mm/Makefile
+++ linux-2.6.16-rc1-olh/arch/powerpc/mm/Makefile
@@ -5,6 +5,7 @@
ifeq ($(CONFIG_PPC64),y)
EXTRA_CFLAGS += -mno-minimal-toc
endif
+GCC_BROKEN_VEC := $(shell set -x ; if [ $(call cc-version) -lt 0400 ] ; then echo "y"; fi)

obj-y := fault.o mem.o lmb.o
obj-$(CONFIG_PPC32) += init_32.o pgtable_32.o mmu_context_32.o
Index: linux-2.6.16-rc1-olh/fs/reiserfs/Makefile
===================================================================
--- linux-2.6.16-rc1-olh.orig/fs/reiserfs/Makefile
+++ linux-2.6.16-rc1-olh/fs/reiserfs/Makefile
@@ -28,7 +28,7 @@ endif
# will work around it. If any other architecture displays this behavior,
# add it here.
ifeq ($(CONFIG_PPC32),y)
-EXTRA_CFLAGS := -O1
+EXTRA_CFLAGS := $(shell set -x ; if [ $(call cc-version) -lt 0402 ] ; then echo $(call cc-option,-O1); fi ;)
endif

TAGS:



--
short story of a lazy sysadmin:
alias appserv=wotan


2006-01-21 19:07:54

by Andrey Borzenkov

[permalink] [raw]
Subject: Re: cc-version not available to change EXTRA_CFLAGS

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> make -kj14 O=../O-powerpc-ppc64-defconfig arch/powerpc/mm/mem.o
> GEN /home/olaf/kernel/olh/ppc64/O-powerpc-ppc64-defconfig/Makefile
> scripts/kconfig/conf -s arch/powerpc/Kconfig
> arch/powerpc/platforms/83xx/Kconfig:10:warning: 'select' used by config
> symbol \ 'MPC834x_SYS' refer to undefined symbol 'DEFAULT_UIMAGE' #
> # using defaults found in .config
> #
> make[3]: `.kernelrelease' is up to date.
> SPLIT include/linux/autoconf.h -> include/config/*
> + '[' -lt 0400 ']'
> /bin/sh: line 1: [: -lt: unary operator expected

does chmod +x scripts/gcc-version.sh help?

Which raises the question - I believed, we support Intel CC for kernel
compilation? Or was just just a dream?

- -andrey
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFD0oaFR6LMutpd94wRAsj3AKDQ/TJDNUFT6HlJ+zkG7mW2pmrRZgCfWjfR
qFqo6sJ1jW/t/w1B26i/hdU=
=ByTQ
-----END PGP SIGNATURE-----

2006-01-21 19:11:42

by Olaf Hering

[permalink] [raw]
Subject: Re: cc-version not available to change EXTRA_CFLAGS

On Sat, Jan 21, Andrey Borzenkov wrote:

> does chmod +x scripts/gcc-version.sh help?

no, cc-version is not expanded in this context.

--
short story of a lazy sysadmin:
alias appserv=wotan

2006-01-21 19:47:23

by Andrey Borzenkov

[permalink] [raw]
Subject: Re: cc-version not available to change EXTRA_CFLAGS

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Saturday 21 January 2006 22:11, Olaf Hering wrote:
> On Sat, Jan 21, Andrey Borzenkov wrote:
> > does chmod +x scripts/gcc-version.sh help?
>
> no, cc-version is not expanded in this context.

well it does in this trivial test:

cc-version = $(shell foo/baz 2234)

FOO = $(shell set -x; if [ $(cc-version) -lt 2000 ] ; then echo y; else echo
n; fi)

bar:
echo $(FOO)


I get exactly the same result if foo/baz is not executable or returns empty
string (in the former case I also get error message from make but may be it
is supressed, I never fully groked kernel Makefiles).

So again - does scripts/gcc-version.sh returns any usable value? Is it
executable?

- -andrey
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD4DBQFD0o/CR6LMutpd94wRAjuFAJj2Ov4Z2iVxamYY/IxkLzOGRb1fAJwIBOxt
aH91icTk8dTKzO/VzLjlLA==
=DNXC
-----END PGP SIGNATURE-----

2006-01-21 21:07:09

by Olaf Hering

[permalink] [raw]
Subject: Re: cc-version not available to change EXTRA_CFLAGS

On Sat, Jan 21, Andrey Borzenkov wrote:

> > no, cc-version is not expanded in this context.

> So again - does scripts/gcc-version.sh returns any usable value? Is it
> executable?

As I said, its not called at all in this context.

--
short story of a lazy sysadmin:
alias appserv=wotan

2006-01-21 22:13:03

by Sam Ravnborg

[permalink] [raw]
Subject: Re: cc-version not available to change EXTRA_CFLAGS

On Sat, Jan 21, 2006 at 07:08:05PM +0100, Olaf Hering wrote:
>
> I want to add a gcc version check for reiserfs, on akpms request.
> This one doesnt work with 2.6.16rc1, havent checked if it ever worked.
...
> Index: linux-2.6.16-rc1-olh/fs/reiserfs/Makefile
> ===================================================================
> --- linux-2.6.16-rc1-olh.orig/fs/reiserfs/Makefile
> +++ linux-2.6.16-rc1-olh/fs/reiserfs/Makefile
> @@ -28,7 +28,7 @@ endif
> # will work around it. If any other architecture displays this behavior,
> # add it here.
> ifeq ($(CONFIG_PPC32),y)
> -EXTRA_CFLAGS := -O1
> +EXTRA_CFLAGS := $(shell set -x ; if [ $(call cc-version) -lt 0402 ] ; then echo $(call cc-option,-O1); fi ;)
> endif

cc-option is only available from main Makefile as of today.
I can try to move them to Kbuild.include - that should fix this usecase.

Sam

2006-01-21 22:21:28

by Olaf Hering

[permalink] [raw]
Subject: Re: cc-version not available to change EXTRA_CFLAGS

On Sat, Jan 21, Sam Ravnborg wrote:

> I can try to move them to Kbuild.include - that should fix this usecase.

Thanks.

--
short story of a lazy sysadmin:
alias appserv=wotan

2006-01-21 22:51:46

by Jan Engelhardt

[permalink] [raw]
Subject: Re: cc-version not available to change EXTRA_CFLAGS


>Which raises the question - I believed, we support Intel CC for kernel
>compilation? Or was just just a dream?

Not really. If ICC works though, then it's because ICC was tuned hard to
behave like GCC.


Jan Engelhardt
--

2006-01-21 22:57:43

by Sam Ravnborg

[permalink] [raw]
Subject: Re: cc-version not available to change EXTRA_CFLAGS

On Sat, Jan 21, 2006 at 07:08:05PM +0100, Olaf Hering wrote:
>
> I want to add a gcc version check for reiserfs, on akpms request.
> This one doesnt work with 2.6.16rc1, havent checked if it ever worked.

I did the following:
- Moved definitions from Makefile to scripts/Kbuild.include
- Moved include of Kbuild.include up before include of kbuild file
- Documented the 'new' as-option
- Added new macro: cc-ifversion
- Added documentation for cc-ifversion

Let me know if this works for you.

> ifeq ($(CONFIG_PPC32),y)
> -EXTRA_CFLAGS := -O1
> +EXTRA_CFLAGS := $(shell set -x ; if [ $(call cc-version) -lt 0402 ] ; then echo $(call cc-option,-O1); fi ;)

For -O1 I do not see the point in using $(call cc-option ...).
I assume all gcc version does support -O1 - or?

Sam

diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 443230b..14f925a 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -981,6 +981,20 @@ When kbuild executes the following steps
$(CC) is useally the gcc compiler, but other alternatives are
available.

+ as-option
+ as-option is used to check if $(CC) when used to compile
+ assembler (*.S) files supports the given option. An optional
+ second option may be specified if first option are not supported.
+
+ Example:
+ #arch/sh/Makefile
+ cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),)
+
+ In the above example cflags-y will be assinged the the option
+ -Wa$(comma)-isa=$(isa-y) if it is supported by $(CC).
+ The second argument is optional, and if supplied will be used
+ if first argument is not supported.
+
cc-option
cc-option is used to check if $(CC) support a given option, and not
supported to use an optional second option.
@@ -1039,7 +1053,21 @@ When kbuild executes the following steps

In the above example -mregparm=3 is only used for gcc version greater
than or equal to gcc 3.0.
-
+
+ cc-ifversion
+ cc-ifversion test the version of $(CC) and equals last argument if
+ version expression is true.
+
+ Example:
+ #fs/reiserfs/Makefile
+ EXTRA_CFLAGS := $(call cc-ifversion, -lt, 0402, -O1)
+
+ In this example EXTRA_CFLAGS will be assigned the value -O1 if the
+ $(CC) version is less than 4.2.
+ cc-ifversion takes all the shell operators:
+ -eq, -ne, -lt, -le, -gt, and -ge
+ The third parameter may be a text as in this example, but it may also
+ be an expanded variable or a macro.

=== 7 Kbuild Variables

diff --git a/Makefile b/Makefile
index 31bbc6a..da3c528 100644
--- a/Makefile
+++ b/Makefile
@@ -259,38 +259,6 @@ endif

export quiet Q KBUILD_VERBOSE

-######
-# cc support functions to be used (only) in arch/$(ARCH)/Makefile
-# See documentation in Documentation/kbuild/makefiles.txt
-
-# as-option
-# Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,)
-
-as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \
- -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \
- else echo "$(2)"; fi ;)
-
-# cc-option
-# Usage: cflags-y += $(call cc-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 ;)
-
-# cc-option-yn
-# Usage: flag := $(call cc-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)))
-

# Look for make include files relative to root of kernel src
MAKEFLAGS += --include-dir=$(srctree)
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 0168d6c..92ce94b 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -44,6 +44,43 @@ define filechk
fi
endef

+######
+# cc support functions to be used (only) in arch/$(ARCH)/Makefile
+# See documentation in Documentation/kbuild/makefiles.txt
+
+# as-option
+# Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,)
+
+as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \
+ -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \
+ else echo "$(2)"; fi ;)
+
+# cc-option
+# Usage: cflags-y += $(call cc-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 ;)
+
+# cc-option-yn
+# Usage: flag := $(call cc-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)))
+
+# cc-ifversion
+# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
+cc-ifversion = $(shell if [ $(call cc-version, $(CC)) $(1) $(2) ]; then \
+ echo $(3); fi;)
+
###
# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
# Usage:
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index c33e62b..2737765 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -10,11 +10,12 @@ __build:
# Read .config if it exist, otherwise ignore
-include .config

+include scripts/Kbuild.include
+
# The filename Kbuild has precedence over Makefile
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)

-include scripts/Kbuild.include
include scripts/Makefile.lib

ifdef host-progs

2006-01-21 23:00:20

by Sam Ravnborg

[permalink] [raw]
Subject: Re: cc-version not available to change EXTRA_CFLAGS

On Sat, Jan 21, 2006 at 10:07:42PM +0300, Andrey Borzenkov wrote:
>
> Which raises the question - I believed, we support Intel CC for kernel
> compilation? Or was just just a dream?

We have include/linux/compiler-intel.h as the only artifact to support
the Intel compiler.
In all other places we assume gcc - but Intel tries hard to be gcc
alike.

Sam

2006-01-21 23:15:51

by Olaf Hering

[permalink] [raw]
Subject: Re: cc-version not available to change EXTRA_CFLAGS

On Sat, Jan 21, Sam Ravnborg wrote:

> Let me know if this works for you.

Works perfect, beside this minor glitch.

Warning: trailing whitespace in line 1067 of
Documentation/kbuild/makefiles.txt

> > ifeq ($(CONFIG_PPC32),y)
> > -EXTRA_CFLAGS := -O1
> > +EXTRA_CFLAGS := $(shell set -x ; if [ $(call cc-version) -lt 0402 ] ; then echo $(call cc-option,-O1); fi ;)
>
> For -O1 I do not see the point in using $(call cc-option ...).
> I assume all gcc version does support -O1 - or?

this was just c&p during debug, from another file.

> + Example:
> + #fs/reiserfs/Makefile
> + EXTRA_CFLAGS := $(call cc-ifversion, -lt, 0402, -O1)
> +
> + In this example EXTRA_CFLAGS will be assigned the value -O1 if the
> + $(CC) version is less than 4.2.

I meant 4.0.2 as shipped with SuSE 10.0, but thats ok. I think the buggy
version was 3.2, as we have not seen in with gcc 3.3-hammer in SLES9.
Will you include the reiserfs change with a check for earlier then 4.0
or 4.1 or should I send a separate patch?

--
short story of a lazy sysadmin:
alias appserv=wotan

2006-01-21 23:25:55

by Sam Ravnborg

[permalink] [raw]
Subject: Re: cc-version not available to change EXTRA_CFLAGS

On Sun, Jan 22, 2006 at 12:15:39AM +0100, Olaf Hering wrote:
> Will you include the reiserfs change with a check for earlier then 4.0
> or 4.1 or should I send a separate patch?

Please submit as a separate patch. I try to keep non-kbuild stuff out of
the kbuild tree. This make is less confusing.

I will not commit this until sometime tomorrow - I have to set up
something so I can track bugfixes and enhancements in parallel.
This is 2.6.17 material IMO in kbuild land except if we want this in for
reiserfs before 2.6.17.

I try to be rather strict about bug-fixes versus enhancements in kbuild.
The latest unexpected breakage shows how easy it is to introduce
unexpected errors in someones build :-(

Sam

2006-01-23 11:02:46

by Olaf Hering

[permalink] [raw]
Subject: Re: cc-version not available to change EXTRA_CFLAGS

On Sun, Jan 22, Sam Ravnborg wrote:

> This is 2.6.17 material IMO in kbuild land except if we want this in for
> reiserfs before 2.6.17.

Yes, thats ok.

--
short story of a lazy sysadmin:
alias appserv=wotan

2006-02-10 19:47:16

by Olaf Hering

[permalink] [raw]
Subject: Re: cc-version not available to change EXTRA_CFLAGS

On Sat, Jan 21, Sam Ravnborg wrote:


> +++ b/Makefile
> @@ -259,38 +259,6 @@ endif
>
> export quiet Q KBUILD_VERBOSE
>
> -######
> -# cc support functions to be used (only) in arch/$(ARCH)/Makefile
> -# See documentation in Documentation/kbuild/makefiles.txt

> +++ b/scripts/Kbuild.include
> @@ -44,6 +44,43 @@ define filechk
> fi
> endef
>
> +######
> +# cc support functions to be used (only) in arch/$(ARCH)/Makefile
> +# See documentation in Documentation/kbuild/makefiles.txt

The comment needs updating.

--
short story of a lazy sysadmin:
alias appserv=wotan

2006-02-18 09:04:14

by Sam Ravnborg

[permalink] [raw]
Subject: Re: cc-version not available to change EXTRA_CFLAGS

On Fri, Feb 10, 2006 at 08:47:13PM +0100, Olaf Hering wrote:
> On Sat, Jan 21, Sam Ravnborg wrote:
>
>
> > +++ b/Makefile
> > @@ -259,38 +259,6 @@ endif
> >
> > export quiet Q KBUILD_VERBOSE
> >
> > -######
> > -# cc support functions to be used (only) in arch/$(ARCH)/Makefile
> > -# See documentation in Documentation/kbuild/makefiles.txt
>
> > +++ b/scripts/Kbuild.include
> > @@ -44,6 +44,43 @@ define filechk
> > fi
> > endef
> >
> > +######
> > +# cc support functions to be used (only) in arch/$(ARCH)/Makefile
> > +# See documentation in Documentation/kbuild/makefiles.txt
>
> The comment needs updating.

Done - thanks.

Sam