Sink the _GNU_SOURCE definition down into the target configuration,

and only define it where we know we need it---Linux and Cygwin. Thanks
to Chris for the prodding.

llvm-svn: 101989
This commit is contained in:
Douglas Gregor 2010-04-21 05:52:38 +00:00
parent 58c65652a8
commit 3ecc665505
2 changed files with 4 additions and 24 deletions

View File

@ -219,6 +219,8 @@ protected:
Builder.defineMacro("__ELF__");
if (Opts.POSIXThreads)
Builder.defineMacro("_REENTRANT");
if (Opts.CPlusPlus)
Builder.defineMacro("_GNU_SOURCE");
}
public:
LinuxTargetInfo(const std::string& triple)
@ -1221,6 +1223,8 @@ public:
Builder.defineMacro("__CYGWIN__");
Builder.defineMacro("__CYGWIN32__");
DefineStd(Builder, "unix", Opts);
if (Opts.CPlusPlus)
Builder.defineMacro("_GNU_SOURCE");
}
};
} // end anonymous namespace

View File

@ -294,30 +294,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
// C++ translation unit.
Builder.defineMacro("__cplusplus", "199711L");
Builder.defineMacro("__private_extern__", "extern");
// 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) {