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.

-- 
           Summary: -fgnu-runtime not working when -E is specified at the
                    same time
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libobjc
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lars dot sonchocky-helldorf at hamburg dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-apple-darwin7.2.1
  GCC host triplet: i686-apple-darwin7.2.1
GCC target triplet: i686-apple-darwin7.2.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18772

Reply via email to