[llvm-bugs] [Bug 30446] New: Undefining __GNUC__ or setting __GNUC__ to 1 breaks libc++

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 19 09:46:59 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=30446

            Bug ID: 30446
           Summary: Undefining __GNUC__ or setting __GNUC__ to 1 breaks
                    libc++
           Product: libc++
           Version: 3.4
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: noloader at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
    Classification: Unclassified

We are trying to stop Clang from pretending to be other compilers. We have
specific code paths for both LLVM and Apple Clang, and the constant application
of work-arounds because Clang cannot consume the same programs as GCC is
becoming tiresome.

When we add the following to our code it completely breaks things. Originally
we tried undefining __GNUC__ to get it out of "GCC code paths". Then we tried
setting it to 1 to give it a "minimal GCC configuration". Then we tried setting
it to 3 to obtain the "minimal GCC configuration".

Setting __GNUC__ to 4 gets Clang out of GCC 4.0.1, 4.1 and 4.2 code paths. That
allows some of the SSE3 and SSSE3 stuff to compile as expected. GCC added SSE3
support at GCC 4.1, but Clang fails to compile it.

Test program:

$ cat test.cxx 
#if defined(__GNUC__) && defined(__clang__)
# undef __GNUC__
# undef __GNUC_MINOR__
# undef __GNUC_PATCHLEVEL__
# define __GNUC__ 1
#endif

#include <string>
int main(int argc, char* argv[])
{
  return 0;
}

Results:

$ c++ -DNDEBUG -g2 -O2 -stdlib=libc++ test.cxx -o test.exe
In file included from test.cxx:8:
In file included from /usr/bin/../lib/c++/v1/string:435:
In file included from /usr/bin/../lib/c++/v1/iosfwd:90:
In file included from /usr/include/wchar.h:70:
In file included from /usr/include/_types.h:27:
In file included from /usr/include/sys/_types.h:32:
/usr/include/sys/cdefs.h:81:2: warning: "Unsupported compiler detected"
      [-W#warnings]
#warning "Unsupported compiler detected"
 ^
1 warning generated.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160919/a8923442/attachment-0001.html>


More information about the llvm-bugs mailing list