Bug 18772 - -fgnu-runtime not working when -E is specified at the same time
Summary: -fgnu-runtime not working when -E is specified at the same time
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-02 01:33 UTC by Lars Sonchocky-Helldorf
Modified: 2005-07-23 22:49 UTC (History)
2 users (show)

See Also:
Host: i686-apple-darwin7.2.1
Target: i686-apple-darwin7.2.1
Build: i686-apple-darwin7.2.1
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Sonchocky-Helldorf 2004-12-02 01:33:32 UTC
One of the purposes of the -fgnu-runtime flag is to get hold of the right libobjc header files when 
specified. This does not work when -E is specified at the same time.

Why do I think the mutually exclusion off "-E" and "-fgnu-runtime" is a bug:

The -E option is regularly used by configure scripts to get hold of the preprocessor output of gcc. 
However, this option doesn't seem to work together with  the "-fgnu-runtime" option. I always get 
warnings like (whether an additional '-x objective-c' is specified or not doesn't matter):

cc1: warning: command line option "-fgnu-runtime" is valid for ObjC/ObjC++ but not for C

and in result gcc also includes the wrong header files:

I have stripped down the testcase to the following small program (conftest.c):

#include <objc/objc-api.h>

main()
{

}

If I use gcc on that like:

localhost:~/GNUstep-Darwin/test lars$ /opt/local/bin/gcc -E -x objective-c -fgnu-runtime conftest.c

I get:

cc1: warning: command line option "-fgnu-runtime" is valid for ObjC/ObjC++ but not for C
# 1 "conftest.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "conftest.c"
# 1 "/usr/include/objc/objc-api.h" 1 3 4
# 2 "conftest.c" 2

main()
{

}

which is wrong because /usr/include/objc/objc-api.h got included (which is the objc-api.h of the next-
runtime (default on Darwin)).

If I instead use gcc like:

localhost:~/GNUstep-Darwin/test lars$ /opt/local/bin/gcc -x objective-c -fgnu-runtime -save-temps 
conftest.c

I get a file "conftest.mi" which starts like:

# 1 "conftest.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "conftest.c"
# 1 "/opt/local/bin/../lib/gcc/i686-apple-darwin7.2.1/4.0.0/include-gnu-runtime/objc/objc-api.h" 
1 3 4
# 30 "/opt/local/bin/../lib/gcc/i686-apple-darwin7.2.1/4.0.0/include-gnu-runtime/objc/objc-api.h" 
3 4

Here gcc has included the right (gnu-runtime) objc-api.h


regards, Lars


p.s.:
by the way: Apples gcc (gcc version 3.3 20030304 (Apple Computer, Inc. build 1495)) doesn't warn if it 
gets "-E" and "-fgnu-runtime" at once but it also does the the wrong thing.
Comment 1 Andrew Pinski 2004-12-02 01:42:11 UTC
Really you or who ever should not just use -E to test if a header exists, they should be testing if the 
header exists and works (aka -c).
Comment 2 Andrew Pinski 2004-12-12 21:32:07 UTC
The GNUstep bug was fixed and really there is no reason to fix this.
Comment 3 Andrew Pinski 2005-01-14 23:45:56 UTC
Reopening to mark as ...
Comment 4 Andrew Pinski 2005-01-14 23:46:27 UTC
Fixed.

By:
http://gcc.gnu.org/ml/gcc-patches/2005-01/msg00853.html