Skip to contentSkip to conversation

How to do -nostdinc?

DISCUSSION Keith Owens 7 participants 8 messages Dec 15, 2002 – Dec 16, 2002

lore
Share & tools
lore
#0 lore raw

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).

#1 lore raw
Quoted 8 lines · Keith Owens

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

Signature · 6 lines
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
#2 lore raw
In reply to Keith Owens
Quoted 5 lines · Keith Owens

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.

Signature · 2 lines
Russell King ([email protected])                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html
#3 lore raw
In reply to Keith Owens
Quoted 9 lines · Keith Owens

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

Quoted 8 lines

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,

Signature · 4 lines
  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
#4 lore raw
In reply to Keith Owens
Quoted 9 lines · Keith Owens

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

#5 lore raw
Quoted 6 lines · Sam Ravnborg
Quoted 5 lines · Keith Owens

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

Quoted 8 lines
Quoted 4 lines

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).

#6 lore raw
Quoted 12 lines · On 2002.12.16 Keith Owens wrote:
Quoted 10 lines · Sam Ravnborg
Quoted 9 lines · Keith Owens

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

Quoted 8 lines
Quoted 4 lines

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.

Signature · 4 lines
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))
#7 lore raw
In reply to Keith Owens
Followup to:  <[email protected]>
By author:    Keith Owens <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 4 lines

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

Signature · 3 lines
<[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]>