[cfe-commits] r101450 - in /cfe/trunk: lib/Frontend/InitPreprocessor.cpp test/Preprocessor/init.c
Douglas Gregor
dgregor at apple.com
Tue Apr 20 22:54:08 PDT 2010
On Apr 16, 2010, at 11:12 AM, Chris Lattner wrote:
>
> On Apr 15, 2010, at 11:31 PM, Douglas Gregor wrote:
>
>> Author: dgregor
>> Date: Fri Apr 16 01:31:05 2010
>> New Revision: 101450
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=101450&view=rev
>> Log:
>> Only predefine the macro _GNU_SOURCE in C++ mode when we're on a
>> platform that typically uses glibc. Fixes a Boost.Thread compilation
>> failure.
>
> Hey Doug,
>
> Should this be sunk into the Targets.cpp file? It seems very similar to __i386__ and such. Switching on triple seems weird.
Yes, it should be. r101989.
- Doug
> -Chris
>
>>
>> Modified:
>> cfe/trunk/lib/Frontend/InitPreprocessor.cpp
>> cfe/trunk/test/Preprocessor/init.c
>>
>> Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=101450&r1=101449&r2=101450&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
>> +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Fri Apr 16 01:31:05 2010
>> @@ -294,8 +294,30 @@
>> // C++ translation unit.
>> Builder.defineMacro("__cplusplus", "199711L");
>> Builder.defineMacro("__private_extern__", "extern");
>> - // Ugly hack to work with GNU libstdc++.
>> - Builder.defineMacro("_GNU_SOURCE");
>> +
>> + // Define _GNU_SOURCE on platforms where we expect to use glibc.
>> + switch (TI.getTriple().getOS()) {
>> + case llvm::Triple::Cygwin:
>> + case llvm::Triple::MinGW64:
>> + case llvm::Triple::MinGW32:
>> + case llvm::Triple::Linux:
>> + case llvm::Triple::Solaris:
>> + case llvm::Triple::AuroraUX:
>> + Builder.defineMacro("_GNU_SOURCE");
>> + break;
>> +
>> + case llvm::Triple::Darwin:
>> + case llvm::Triple::DragonFly:
>> + case llvm::Triple::FreeBSD:
>> + case llvm::Triple::UnknownOS:
>> + case llvm::Triple::Lv2:
>> + case llvm::Triple::NetBSD:
>> + case llvm::Triple::OpenBSD:
>> + case llvm::Triple::Psp:
>> + case llvm::Triple::Win32:
>> + case llvm::Triple::Haiku:
>> + break;
>> + }
>> }
>>
>> if (LangOpts.Microsoft) {
>>
>> Modified: cfe/trunk/test/Preprocessor/init.c
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=101450&r1=101449&r2=101450&view=diff
>> ==============================================================================
>> --- cfe/trunk/test/Preprocessor/init.c (original)
>> +++ cfe/trunk/test/Preprocessor/init.c Fri Apr 16 01:31:05 2010
>> @@ -11,7 +11,6 @@
>> //
>> // RUN: %clang_cc1 -x c++ -std=c++0x -E -dM < /dev/null | FileCheck -check-prefix CXX0X %s
>> //
>> -// CXX0X:#define _GNU_SOURCE 1
>> // CXX0X:#define __DEPRECATED 1
>> // CXX0X:#define __GNUG__
>> // CXX0X:#define __GXX_EXPERIMENTAL_CXX0X__ 1
>> @@ -22,7 +21,6 @@
>> //
>> // RUN: %clang_cc1 -x c++ -std=c++98 -E -dM < /dev/null | FileCheck -check-prefix CXX98 %s
>> //
>> -// CXX98:#define _GNU_SOURCE 1
>> // CXX98:#define __DEPRECATED 1
>> // CXX98:#define __GNUG__
>> // CXX98:#define __GXX_WEAK__ 1
>> @@ -58,7 +56,6 @@
>> //
>> // RUN: %clang_cc1 -x c++ -std=gnu++98 -E -dM < /dev/null | FileCheck -check-prefix GXX98 %s
>> //
>> -// GXX98:#define _GNU_SOURCE 1
>> // GXX98:#define __DEPRECATED 1
>> // GXX98:#define __GNUG__
>> // GXX98:#define __GXX_WEAK__ 1
>> @@ -1028,3 +1025,6 @@
>> // X86_64:#define __x86_64 1
>> // X86_64:#define __x86_64__ 1
>> //
>> +// RUN: %clang_cc1 -x c++ -triple i686-pc-linux-gnu -E -dM < /dev/null | FileCheck -check-prefix GNUSOURCE %s
>> +// GNUSOURCE:#define _GNU_SOURCE 1
>> +//
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
More information about the cfe-commits
mailing list