Add -nostdinc to TARGET_CFLAGS
PATCH 1/1 Add -nostdinc to TARGET_CFLAGS
It should be pretty obvious that we don't want to use system headers when building target, but we've been for so long without this flag that I want to make sure.
Does anyone see a problem with it?
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
$ bzr diff -r 1768..1769 bzr+ssh://bzr.savannah.gnu.org/grub/people/robertmh/lib-linux/Makefile.in
2009-10-26 Robert Millan <[email protected]>
* Makefile.in (TARGET_CPPFLAGS): Add `-nostdinc'.
=== modified file 'Makefile.in'
Makefile.in +1 -1
@@ -75,7 +75,7 @@ TARGET_MODULE_FORMAT = @TARGET_MODULE_FORMAT@ TARGET_APPLE_CC = @TARGET_APPLE_CC@ OBJCONV = @OBJCONV@ -TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/include \ +TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -nostdinc -I$(builddir) -I$(builddir)/include -I$(srcdir)/include \ -Wall -W TARGET_LDFLAGS = @TARGET_LDFLAGS@ TARGET_IMG_LDSCRIPT = @TARGET_IMG_LDSCRIPT@
Committed then.
Quoted 39 lines · Robert Millan
It should be pretty obvious that we don't want to use system headers when building target, but we've been for so long without this flag that I want to make sure.
Does anyone see a problem with it?
Signature · 14 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all." $ bzr diff -r 1768..1769 bzr+ssh://bzr.savannah.gnu.org/grub/people/robertmh/lib-linux/Makefile.in 2009-10-26 Robert Millan <[email protected]> * Makefile.in (TARGET_CPPFLAGS): Add `-nostdinc'. === modified file 'Makefile.in'Makefile.in +1
-1@@ -75,7 +75,7 @@ TARGET_MODULE_FORMAT = @TARGET_MODULE_FORMAT@ TARGET_APPLE_CC = @TARGET_APPLE_CC@ OBJCONV = @OBJCONV@ -TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/include \ +TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -nostdinc -I$(builddir) -I$(builddir)/include -I$(srcdir)/include \ -Wall -W TARGET_LDFLAGS = @TARGET_LDFLAGS@ TARGET_IMG_LDSCRIPT = @TARGET_IMG_LDSCRIPT@_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
It appears that -nostdinc also excludes GCC internal header directory (for e.g. stdarg.h), which I didn't expect.
Does someone know a clean way to resolve this? A quick check at GCC command-line options didn't reveal a way to explicitly include that directory afterwards without knowing its path.
I.e. something similar to gcc -print-file-name=libgcc.a
Quoted 51 lines · Robert Millan
Committed then.
Quoted 39 lines · Robert Millan
It should be pretty obvious that we don't want to use system headers when building target, but we've been for so long without this flag that I want to make sure.
Does anyone see a problem with it?
Signature · 14 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all." $ bzr diff -r 1768..1769 bzr+ssh://bzr.savannah.gnu.org/grub/people/robertmh/lib-linux/Makefile.in 2009-10-26 Robert Millan <[email protected]> * Makefile.in (TARGET_CPPFLAGS): Add `-nostdinc'. === modified file 'Makefile.in'Makefile.in +1
-1@@ -75,7 +75,7 @@ TARGET_MODULE_FORMAT = @TARGET_MODULE_FORMAT@ TARGET_APPLE_CC = @TARGET_APPLE_CC@ OBJCONV = @OBJCONV@ -TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/include \ +TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -nostdinc -I$(builddir) -I$(builddir)/include -I$(srcdir)/include \ -Wall -W TARGET_LDFLAGS = @TARGET_LDFLAGS@ TARGET_IMG_LDSCRIPT = @TARGET_IMG_LDSCRIPT@_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-develSignature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 9 lines · Robert Millan
It appears that -nostdinc also excludes GCC internal header directory (for e.g.
stdarg.h), which I didn't expect.Does someone know a clean way to resolve this? A quick check at GCC command-line options didn't reveal a way to explicitly include that directory afterwards without knowing its path.
I.e. something similar to
gcc -print-file-name=libgcc.a
Maybe with -isysroot=pwd/dummy instead of -nostdinc.
It's an ugly kludge, but the alternatives look even worse.
Does someone have a better idea?
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 5 lines · Robert Millan
Quoted 3 lines · Robert Millan
It appears that -nostdinc also excludes GCC internal header directory (for e.g.
stdarg.h), which I didn't expect.
Quoted 10 lines
Quoted 6 lines
Does someone know a clean way to resolve this? A quick check at GCC command-line options didn't reveal a way to explicitly include that directory afterwards without knowing its path.
I.e. something similar to
gcc -print-file-name=libgcc.aMaybe with -isysroot=
pwd/dummy instead of -nostdinc.
Why not to create a real sysdir? For gcc grub is just another OS environment so we can use same approach as if we were cross-compiling for another OS
Quoted 5 lines
It's an ugly kludge, but the alternatives look even worse.
Does someone have a better idea?
Signature · 3 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
Quoted 13 lines · Vladimir 'phcoder' Serbinenko
Quoted 12 lines · Robert Millan
Quoted 9 lines · Robert Millan
It appears that -nostdinc also excludes GCC internal header directory (for e.g.
stdarg.h), which I didn't expect.Does someone know a clean way to resolve this? A quick check at GCC command-line options didn't reveal a way to explicitly include that directory afterwards without knowing its path.
I.e. something similar to
gcc -print-file-name=libgcc.a
Quoted 6 lines
Quoted 3 lines
Maybe with -isysroot=
pwd/dummy instead of -nostdinc.Why not to create a real sysdir? For gcc grub is just another OS environment so we can use same approach as if we were cross-compiling for another OS
Good point. Actually, I realized that we already have one (include/grub/).
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
2009-10-30 Robert Millan <[email protected]>
* Makefile.in (TARGET_CPPFLAGS): Replace `-nostdinc' with `-isystem=$(srcdir)/include'.
Makefile.in +1 -1
@@ -75,7 +75,7 @@ TARGET_ASFLAGS = @TARGET_ASFLAGS@ TARGET_MODULE_FORMAT = @TARGET_MODULE_FORMAT@ TARGET_APPLE_CC = @TARGET_APPLE_CC@ OBJCONV = @OBJCONV@ -TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -nostdinc -I$(builddir) -I$(builddir)/include -I$(srcdir)/include \ +TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -isystem=$(srcdir)/include -I$(builddir) -I$(builddir)/include \ -Wall -W TARGET_LDFLAGS = @TARGET_LDFLAGS@ TARGET_IMG_LDSCRIPT = @TARGET_IMG_LDSCRIPT@
Am Donnerstag, den 29.10.2009, 11:36 +0100 schrieb Robert Millan:
Quoted 9 lines · Robert Millan
Quoted 8 lines
It appears that -nostdinc also excludes GCC internal header directory (for e.g.
stdarg.h), which I didn't expect.Does someone know a clean way to resolve this? A quick check at GCC command-line options didn't reveal a way to explicitly include that directory afterwards without knowing its path.
Quoted 8 lines
Quoted 1 line
I.e. something similar to
gcc -print-file-name=libgcc.aMaybe with -isysroot=
pwd/dummy instead of -nostdinc.It's an ugly kludge, but the alternatives look even worse.
Does someone have a better idea?
Thanks to the hint from rubisher I looked now at Linux Makefiles. They use this:
NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
# ls $(gcc-4.4 -print-file-name=include)/stdarg.h /usr/lib/gcc/x86_64-linux-gnu/4.4.2/include/stdarg.h
Signature · 2 lines
Felix Zielcke Proud Debian Maintainer and GNU GRUB developer
Am Mittwoch, den 04.11.2009, 11:48 +0100 schrieb Felix Zielcke:
Quoted 19 lines
Am Donnerstag, den 29.10.2009, 11:36 +0100 schrieb Robert Millan:
Quoted 9 lines · Robert Millan
Quoted 8 lines
It appears that -nostdinc also excludes GCC internal header directory (for e.g.
stdarg.h), which I didn't expect.Does someone know a clean way to resolve this? A quick check at GCC command-line options didn't reveal a way to explicitly include that directory afterwards without knowing its path.
Quoted 8 lines
Quoted 1 line
I.e. something similar to
gcc -print-file-name=libgcc.aMaybe with -isysroot=
pwd/dummy instead of -nostdinc.It's an ugly kludge, but the alternatives look even worse.
Does someone have a better idea?
Quoted 8 lines
Thanks to the hint from rubisher I looked now at Linux Makefiles. They use this:
NOSTDINC_FLAGS+= -nostdinc -isystem $(shell $(CC) -print-file-name=include)# ls $(gcc-4.4 -print-file-name=include)/stdarg.h /usr/lib/gcc/x86_64-linux-gnu/4.4.2/include/stdarg.h
Robert?
IMO this makes at least more sense then what we have now and I just tested this now with and without a seperate build directory with experimental branch and it worksTARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -nostdinc -isystem $(shell $(CC) -print-file-name=include) -I$(srcdir)/include -I$(builddir) -I$(builddir)/include -Wall -W
Signature · 2 lines
Felix Zielcke Proud Debian Maintainer and GNU GRUB developer
Quoted 16 lines · Felix Zielcke
Am Mittwoch, den 04.11.2009, 11:48 +0100 schrieb Felix Zielcke:
Quoted 9 lines
Thanks to the hint from rubisher I looked now at Linux Makefiles. They use this:
NOSTDINC_FLAGS+= -nostdinc -isystem $(shell $(CC) -print-file-name=include)# ls $(gcc-4.4 -print-file-name=include)/stdarg.h /usr/lib/gcc/x86_64-linux-gnu/4.4.2/include/stdarg.hRobert?
IMO this makes at least more sense then what we have now and I just tested this now with and without a seperate build directory with experimental branch and it worksTARGET_CPPFLAGS= @TARGET_CPPFLAGS@ -nostdinc -isystem $(shell $(CC)
Review
Quoted 2 lines
(quoted diff) +0
-2-print-file-name=include) -I$(srcdir)/include -I$(builddir) -I$(builddir)/include -Wall -W
What's the advantage?
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 12 lines · Robert Millan
Quoted 11 lines · Felix Zielcke
Am Mittwoch, den 04.11.2009, 11:48 +0100 schrieb Felix Zielcke:
Quoted 9 lines
Thanks to the hint from rubisher I looked now at Linux Makefiles. They use this:
NOSTDINC_FLAGS+= -nostdinc -isystem $(shell $(CC) -print-file-name=include)# ls $(gcc-4.4 -print-file-name=include)/stdarg.h /usr/lib/gcc/x86_64-linux-gnu/4.4.2/include/stdarg.h
Quoted 9 lines
Review
Quoted 7 lines
Robert?
IMO this makes at least more sense then what we have now and I just tested this now with and without a seperate build directory with experimental branch and it worksTARGET_CPPFLAGS= @TARGET_CPPFLAGS@ -nostdinc -isystem $(shell $(CC)(quoted diff) +0
-2-print-file-name=include) -I$(srcdir)/include -I$(builddir) -I$(builddir)/include -Wall -WWhat's the advantage?
Ah, I remember. There was a problem with stddef.h right?
So you propose something like this:
-TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -isystem=$(srcdir)/include -I$(srcdir)/include -I$(builddir) -I$(builddir)/include \
+TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -isystem=$(shell $(CC) -print-file-name=include) -I$(srcdir)/include -I$(builddir) -I$(builddir)/include \
?
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Am Sonntag, den 15.11.2009, 12:12 +0100 schrieb Robert Millan:
Quoted 27 lines · Robert Millan
Quoted 12 lines · Felix Zielcke
Quoted 11 lines
Am Mittwoch, den 04.11.2009, 11:48 +0100 schrieb Felix Zielcke:
Quoted 9 lines
Thanks to the hint from rubisher I looked now at Linux Makefiles. They use this:
NOSTDINC_FLAGS+= -nostdinc -isystem $(shell $(CC) -print-file-name=include)# ls $(gcc-4.4 -print-file-name=include)/stdarg.h /usr/lib/gcc/x86_64-linux-gnu/4.4.2/include/stdarg.hQuoted 9 lines
Review
Quoted 7 lines
Robert?
IMO this makes at least more sense then what we have now and I just tested this now with and without a seperate build directory with experimental branch and it worksTARGET_CPPFLAGS= @TARGET_CPPFLAGS@ -nostdinc -isystem $(shell $(CC)(quoted diff) +0
-2-print-file-name=include) -I$(srcdir)/include -I$(builddir) -I$(builddir)/include -Wall -WWhat's the advantage?
Ah, I remember. There was a problem with
stddef.hright?So you propose something like this:
Review
Quoted 4 lines
(quoted diff) +1
-1-TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -isystem=$(srcdir)/include -I$(srcdir)/include -I$(builddir) -I$(builddir)/include \ +TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -isystem=$(shell $(CC) -print-file-name=include) -I$(srcdir)/include -I$(builddir) -I$(builddir)/include \ ?
See my previous mail, actually this:
-TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -isystem=$(srcdir)/include -I$(srcdir)/include -I$(builddir) -I$(builddir)/include \
+TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -nostdinc -isystem $(shell $(CC) -print-file-name=include) -I$(srcdir)/include -I$(builddir) -I$(builddir)/include \
The = in -isystem doestn't make much sense to me.
And with above -nostdinc really works for us.
Signature · 2 lines
Felix Zielcke Proud Debian Maintainer and GNU GRUB developer
Am Sonntag, den 15.11.2009, 12:04 +0100 schrieb Robert Millan:
Quoted 12 lines · Felix Zielcke
Quoted 11 lines
Am Mittwoch, den 04.11.2009, 11:48 +0100 schrieb Felix Zielcke:
Quoted 9 lines
Thanks to the hint from rubisher I looked now at Linux Makefiles. They use this:
NOSTDINC_FLAGS+= -nostdinc -isystem $(shell $(CC) -print-file-name=include)# ls $(gcc-4.4 -print-file-name=include)/stdarg.h /usr/lib/gcc/x86_64-linux-gnu/4.4.2/include/stdarg.h
Quoted 10 lines
Review
Quoted 7 lines
Robert?
IMO this makes at least more sense then what we have now and I just tested this now with and without a seperate build directory with experimental branch and it worksTARGET_CPPFLAGS= @TARGET_CPPFLAGS@ -nostdinc -isystem $(shell $(CC)(quoted diff) +0
-2-print-file-name=include) -I$(srcdir)/include -I$(builddir) -I$(builddir)/include -Wall -WWhat's the advantage?
The advantage is that this does exatly what we want for the target. Remove /usr/include from the include search directories but still keep the gcc internal one for e.g. stdarg.h
As far as I understand the gcc manual, isystem adds this directory to the search path and treats all headers there in as system headers. And with the = between -isystem and $(srcdir) it actually uses ${sysroot}{$srcdir} but we don't use any --sysroot or -isysroot. The arguments we currently have there just look wrong with my understand of the gcc manual
$ cat test.c #include <stdarg.h> #include <stdint.h>
int main (void)
{
return 0;
}
$ srcdir=$PWD builddir=$PWD gcc -isystem=$srcdir/include -I$srcdir/include -I$builddir -I$builddir/include test.c -o test && ls test test $ srcdir=$PWD builddir=$PWD gcc -nostdinc -isystem $(gcc -print-file-name=include) -I$srcdir/include -I$builddir -I$builddir/include test.c test.c:2:20: error: stdint.h: No such file or directory
Signature · 2 lines
Felix Zielcke Proud Debian Maintainer and GNU GRUB developer
Quoted 10 lines · Felix Zielcke
The advantage is that this does exatly what we want for the target. Remove
/usr/includefrom the include search directories but still keep the gcc internal one for e.g.stdarg.h
As far as I understand the gcc manual, isystem adds this directory to the search path and treats all headers there in as system headers. And with the = between -isystem and $(srcdir) it actually uses ${sysroot}{$srcdir} but we don't use any --sysroot or -isysroot. The arguments we currently have there just look wrong with my understand of the gcc manual
Ah, I see..
Quoted 9 lines
$ cat test.c #include <stdarg.h> #include <stdint.h>int main (void)
{
return 0;
}
Quoted 4 lines
$ srcdir=$PWD builddir=$PWD gcc -isystem=$srcdir/include -I$srcdir/include -I$builddir -I$builddir/include test.c -o test && ls test test $ srcdir=$PWD builddir=$PWD gcc -nostdinc -isystem $(gcc -print-file-name=include) -I$srcdir/include -I$builddir -I$builddir/include test.c test.c:2:20: error: stdint.h: No such file or directory
We used -isystem as a way of excluding system headers but not gcc headers. With the -print-file-name trick this seems to be no longer necessary, right?
So why not "-nostdinc -I$(gcc -print-file-name=include)" instead?
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Am Sonntag, den 15.11.2009, 12:35 +0100 schrieb Robert Millan:
Quoted 28 lines · Felix Zielcke
Quoted 10 lines
The advantage is that this does exatly what we want for the target. Remove
/usr/includefrom the include search directories but still keep the gcc internal one for e.g.stdarg.h
As far as I understand the gcc manual, isystem adds this directory to the search path and treats all headers there in as system headers. And with the = between -isystem and $(srcdir) it actually uses ${sysroot}{$srcdir} but we don't use any --sysroot or -isysroot. The arguments we currently have there just look wrong with my understand of the gcc manualAh, I see..
Quoted 9 lines
$ cat test.c #include <stdarg.h> #include <stdint.h>int main (void)
{
return 0;
}Quoted 4 lines
$ srcdir=$PWD builddir=$PWD gcc -isystem=$srcdir/include -I$srcdir/include -I$builddir -I$builddir/include test.c -o test && ls test test $ srcdir=$PWD builddir=$PWD gcc -nostdinc -isystem $(gcc -print-file-name=include) -I$srcdir/include -I$builddir -I$builddir/include test.c test.c:2:20: error: stdint.h: No such file or directory
Quoted 4 lines
We used -isystem as a way of excluding system headers but not gcc headers. With the -print-file-name trick this seems to be no longer necessary, right?
So why not "-nostdinc -I$(gcc -print-file-name=include)" instead?
I think we should use -isystem for the gcc internal header files not -I, but I just tested experimental branch with -I instead of -isystem and also compiles cleanly (except the usual grub.texi warnings)
As said on IRC already:
http://gcc.gnu.org/onlinedocs/cpp/System-Headers.html
Signature · 2 lines
Felix Zielcke Proud Debian Maintainer and GNU GRUB developer
Quoted 5 lines · Felix Zielcke
Quoted 5 lines
Quoted 4 lines
$ srcdir=$PWD builddir=$PWD gcc -isystem=$srcdir/include -I$srcdir/include -I$builddir -I$builddir/include test.c -o test && ls test test $ srcdir=$PWD builddir=$PWD gcc -nostdinc -isystem $(gcc -print-file-name=include) -I$srcdir/include -I$builddir -I$builddir/include test.c test.c:2:20: error: stdint.h: No such file or directory
Quoted 8 lines
Quoted 4 lines
We used -isystem as a way of excluding system headers but not gcc headers. With the -print-file-name trick this seems to be no longer necessary, right?
So why not "-nostdinc -I$(gcc -print-file-name=include)" instead?
I think we should use -isystem for the gcc internal header files not -I, but I just tested experimental branch with -I instead of -isystem and also compiles cleanly (except the usual grub.texi warnings)
Seems fine. Thanks for investigating this.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Am Sonntag, den 15.11.2009, 13:32 +0100 schrieb Robert Millan:
Quoted 9 lines · Felix Zielcke
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
$ srcdir=$PWD builddir=$PWD gcc -isystem=$srcdir/include -I$srcdir/include -I$builddir -I$builddir/include test.c -o test && ls test test $ srcdir=$PWD builddir=$PWD gcc -nostdinc -isystem $(gcc -print-file-name=include) -I$srcdir/include -I$builddir -I$builddir/include test.c test.c:2:20: error: stdint.h: No such file or directoryWe used -isystem as a way of excluding system headers but not gcc headers. With the -print-file-name trick this seems to be no longer necessary, right?
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
So why not "-nostdinc -I$(gcc -print-file-name=include)" instead?
I think we should use -isystem for the gcc internal header files not -I, but I just tested experimental branch with -I instead of -isystem and also compiles cleanly (except the usual grub.texi warnings)
Seems fine. Thanks for investigating this.
You're welcome.
I commited this now except that I used now $TARGET_CC. Makes more sense inside TARGET_CPPFLAGS.
Signature · 2 lines
Felix Zielcke Proud Debian Maintainer and GNU GRUB developer