[LLVMbugs] [Bug 7826] New: -Xclang forwards to GCC

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Aug 5 05:41:23 PDT 2010


http://llvm.org/bugs/show_bug.cgi?id=7826

           Summary: -Xclang forwards to GCC
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Driver
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: amaury.pouly at gmail.com
                CC: llvmbugs at cs.uiuc.edu


According to the documentation of the -Xclang switch, it 'Pass arg to the clang
compiler frontend.'. But then, when used, the arguments are also passed to the
assembler and the linker if GCC is used. Example (the -W switch is a random
one, I just picked it because clang -cc1 recognizes it):

# clang -ccc-echo -Xclang -W -o ioi ioi.c
"/home/pamaury/avalon/bin/clang" -cc1 -triple x86_64-unknown-linux-gnu -S
-disable-free -main-file-name ioi.c -mrelocation-model static -mdisable-fp-elim
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -resource-dir
/home/pamaury/avalon/lib/clang/2.8 -ferror-limit 19 -fmessage-length 202
-fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -W -o
/tmp/cc-0rvFL5.s -x c ioi.c
 "/usr/bin/gcc" -Xclang -W -c -m64 -o /tmp/cc-GuWlIA.o -x assembler
/tmp/cc-0rvFL5.s
gcc: unrecognized option '-Xclang'
 "/usr/bin/gcc" -Xclang -W -m64 -o ioi /tmp/cc-GuWlIA.o
gcc: unrecognized option '-Xclang'

Looking at the code, it seems that this is because the generic gcc code in
gcc::Common::ConstructJob forwards an argument if the option hasForwardToGCC()
and hasForwardToGCC() itself is defined as:

bool hasForwardToGCC() const { return !DriverOption && !LinkerInput; }

Which seems strange to me because obviously, clang will not use GCC as the
compiler itself (that would defeat the point of using clang :)) so when using
the -Xclang option which is not a driver option nor a linker input but clearly
a compiler related switch, it should not be forwarded to gcc.

As far as I understand, there already are options to forward to the linker and
assembler (-Wl, and -Wa, should work, I never tried them) so I don't see why
the driver would forward other arguments to GCC.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list