Skip to content

Commit 0e1ef69

Browse files
rorthtstellar
authored andcommitted
[Driver] Fix _XOPEN_SOURCE definition on Solaris (llvm#137141)
Since commit 613a077, `flang` doesn't build any longer on Solaris/amd64: ``` flang/lib/Evaluate/intrinsics-library.cpp:225:26: error: address of overloaded function 'acos' does not match required type '__float128 (__float128)' 225 | FolderFactory<F, F{std::acos}>::Create("acos"), | ^~~~~~~~~ ``` That patch led to the version of `quadmath.h` deep inside `/usr/gcc/<N>` to be found, thus `HAS_QUADMATHLIB` is defined. However, the `struct HostRuntimeLibrary<__float128, LibraryVersion::Libm>` template is guarded by `_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600`, while `clang` only predefines `_XOPEN_SOURCE=500`. This code dates back to commit 0c1941c back in 2012. Currently, this is long obsolete and `gcc` prefefines `_XOPEN_SOURCE=600` instead since GCC 4.6 back in 2011. This patch follows that. Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`. (cherry picked from commit e71c8ea)
1 parent 5d99a97 commit 0e1ef69

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

clang/lib/Basic/Targets/OSTargets.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -618,14 +618,7 @@ class LLVM_LIBRARY_VISIBILITY SolarisTargetInfo : public OSTargetInfo<Target> {
618618
DefineStd(Builder, "unix", Opts);
619619
Builder.defineMacro("__svr4__");
620620
Builder.defineMacro("__SVR4");
621-
// Solaris headers require _XOPEN_SOURCE to be set to 600 for C99 and
622-
// newer, but to 500 for everything else. feature_test.h has a check to
623-
// ensure that you are not using C99 with an old version of X/Open or C89
624-
// with a new version.
625-
if (Opts.C99)
626-
Builder.defineMacro("_XOPEN_SOURCE", "600");
627-
else
628-
Builder.defineMacro("_XOPEN_SOURCE", "500");
621+
Builder.defineMacro("_XOPEN_SOURCE", "600");
629622
if (Opts.CPlusPlus) {
630623
Builder.defineMacro("__C99FEATURES__");
631624
Builder.defineMacro("_FILE_OFFSET_BITS", "64");

0 commit comments

Comments
 (0)