2002-12-15 11:58:59

by Keith Owens

[permalink] [raw]
Subject: How to do -nostdinc?

There are two ways of setting the -nostdinc flag in the kernel Makefile :-

(1) -nostdinc $(shell $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')
(2) -nostdinc -iwithprefix include

The first format breaks with non-English locales, however the fix is trivial.

(1a) -nostdinc $(shell LANG=C $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')

The second format is simpler but there have been reports that it does
not work with some versions of gcc. I have been unable to find a
definitive statement about which versions of gcc fail and whether the
problem has been fixed. Anybody care to provide a definitive
statement?

If kernel build cannot rely on gcc working with -nostdinc -iwithprefix include
then we need to convert to (1a).


2002-12-15 13:39:59

by Marius Gedminas

[permalink] [raw]
Subject: Re: How to do -nostdinc?

On Sun, Dec 15, 2002 at 11:06:41PM +1100, Keith Owens wrote:
> There are two ways of setting the -nostdinc flag in the kernel Makefile :-
>
> (1) -nostdinc $(shell $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')
> (2) -nostdinc -iwithprefix include
>
> The first format breaks with non-English locales, however the fix is trivial.
>
> (1a) -nostdinc $(shell LANG=C $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')

Wouldn't LC_ALL=C be more reliable?

Marius Gedminas
--
No proper program contains an indication which as an operator-applied
occurrence identifies an operator-defining occurrence which as an
indication-applied occurrence identifies an indication-defining occurrence
different from the one identified by the given indication as an
indication-applied occurrence.
-- ALGOL 68 Report

2002-12-15 15:03:27

by Russell King

[permalink] [raw]
Subject: Re: How to do -nostdinc?

On Sun, Dec 15, 2002 at 11:06:41PM +1100, Keith Owens wrote:
> The second format is simpler but there have been reports that it does
> not work with some versions of gcc. I have been unable to find a
> definitive statement about which versions of gcc fail and whether the
> problem has been fixed. Anybody care to provide a definitive
> statement?

When the problem appeared, it turned out to be an incorrectly configured
and/or built gcc installation. (therefore, by definition, not a kernel
problem.)

I believe the reporter of the problem subsequently fixed his compiler
installation.

I do, however, think we need to lobby the gcc people to get the
"depreciated" status of -iwithprefix reversed - it is a simple solution
to an otherwise disgusting amount of grep/awk/sed.

--
Russell King ([email protected]) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html

2002-12-16 00:09:48

by Steffen Persvold

[permalink] [raw]
Subject: Re: How to do -nostdinc?

On Sun, 15 Dec 2002, Keith Owens wrote:

> There are two ways of setting the -nostdinc flag in the kernel Makefile :-
>
> (1) -nostdinc $(shell $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')
> (2) -nostdinc -iwithprefix include
>
> The first format breaks with non-English locales, however the fix is trivial.
>
> (1a) -nostdinc $(shell LANG=C $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')
>
> The second format is simpler but there have been reports that it does
> not work with some versions of gcc. I have been unable to find a
> definitive statement about which versions of gcc fail and whether the
> problem has been fixed. Anybody care to provide a definitive
> statement?
>
> If kernel build cannot rely on gcc working with -nostdinc -iwithprefix include
> then we need to convert to (1a).

Well, it works fine with gcc-2.91.66 (egcs-1.1.2 release), gcc-2.96 (RH
7.{1,2,3} versions), and gcc-3.2 (RH 8.0 version)

Of course there are other versions out there but 2.91 is rather old...

Regards,
--
Steffen Persvold | Scali AS
mailto:[email protected] | http://www.scali.com
Tel: (+47) 2262 8950 | Olaf Helsets vei 6
Fax: (+47) 2262 8951 | N0621 Oslo, NORWAY

2002-12-16 18:21:28

by Sam Ravnborg

[permalink] [raw]
Subject: Re: How to do -nostdinc?

On Sun, Dec 15, 2002 at 11:06:41PM +1100, Keith Owens wrote:
> There are two ways of setting the -nostdinc flag in the kernel Makefile :-
>
> (1) -nostdinc $(shell $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')
> (2) -nostdinc -iwithprefix include
>
> The first format breaks with non-English locales, however the fix is trivial.
>
> (1a) -nostdinc $(shell LANG=C $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')
>
Hi Keith.

Based on the comments received, solution (2) seems to be OK.
Do you agree?

Sam

2002-12-16 21:18:50

by Keith Owens

[permalink] [raw]
Subject: Re: How to do -nostdinc?

On Mon, 16 Dec 2002 19:29:19 +0100,
Sam Ravnborg <[email protected]> wrote:
>On Sun, Dec 15, 2002 at 11:06:41PM +1100, Keith Owens wrote:
>> There are two ways of setting the -nostdinc flag in the kernel Makefile :-
>>
>> (1) -nostdinc $(shell $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')
>> (2) -nostdinc -iwithprefix include
>>
>> The first format breaks with non-English locales, however the fix is trivial.
>>
>> (1a) -nostdinc $(shell LANG=C $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')
>>
>Hi Keith.
>
>Based on the comments received, solution (2) seems to be OK.
>Do you agree?

Does gcc still mark -iwithprefix as deprecated? If it does then do not
rely on it and use (1a). If gcc will support -iwithprefix then use (2).

2002-12-16 22:37:13

by J.A. Magallon

[permalink] [raw]
Subject: Re: How to do -nostdinc?


On 2002.12.16 Keith Owens wrote:
>On Mon, 16 Dec 2002 19:29:19 +0100,
>Sam Ravnborg <[email protected]> wrote:
>>On Sun, Dec 15, 2002 at 11:06:41PM +1100, Keith Owens wrote:
>>> There are two ways of setting the -nostdinc flag in the kernel Makefile :-
>>>
>>> (1) -nostdinc $(shell $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')
>>> (2) -nostdinc -iwithprefix include
>>>
>>> The first format breaks with non-English locales, however the fix is trivial.
>>>
>>> (1a) -nostdinc $(shell LANG=C $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')
>>>
>>Hi Keith.
>>
>>Based on the comments received, solution (2) seems to be OK.
>>Do you agree?
>
>Does gcc still mark -iwithprefix as deprecated? If it does then do not
>rely on it and use (1a). If gcc will support -iwithprefix then use (2).
>

gcc-3.2, info:

`-iwithprefix DIR'
`-iwithprefixbefore DIR'
Append DIR to the prefix specified previously with `-iprefix', and
add the resulting directory to the include search path.
`-iwithprefixbefore' puts it in the same place `-I' would;
`-iwithprefix' puts it where `-idirafter' would.

Use of these options is discouraged.

--
J.A. Magallon <[email protected]> \ Software is like sex:
werewolf.able.es \ It's better when it's free
Mandrake Linux release 9.1 (Cooker) for i586
Linux 2.4.20-jam1 (gcc 3.2 (Mandrake Linux 9.1 3.2-4mdk))

2002-12-16 23:08:44

by H. Peter Anvin

[permalink] [raw]
Subject: Re: How to do -nostdinc?

Followup to: <[email protected]>
By author: Keith Owens <[email protected]>
In newsgroup: linux.dev.kernel
>
> Does gcc still mark -iwithprefix as deprecated? If it does then do not
> rely on it and use (1a). If gcc will support -iwithprefix then use (2).
>

If they do, let's apply a cluebat and explain to them that there is no
acceptable substitute for many nonhosted applications, not just the
Linux kernel.

-hpa
--
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt <[email protected]>