diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt index 2de5b2956d53c4244f84b7765c886e84c6963827..a2804ab17ccbb981c9c3b58cfa245670c54dc0d7 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -89,6 +89,11 @@ else() set(output_name "clang") endif() +# libclang requires headers which need _ALL_SOURCE to build on AIX +if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX") + remove_definitions("-D_XOPEN_SOURCE=700") +endif() + add_clang_library(libclang ${ENABLE_SHARED} ${ENABLE_STATIC} OUTPUT_NAME ${output_name} ${SOURCES} diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 71434bcb3e71ff3c13eff177eb0dd4460eb7bb52..c3647ed88bfdf62b73a5a9bb72446abef0a299c8 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -819,6 +819,13 @@ if(APPLE AND DARWIN_LTO_LIBRARY) "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-lto_library -Wl,${DARWIN_LTO_LIBRARY}") endif() +# Build with _XOPEN_SOURCE on AIX, as stray macros in _ALL_SOURCE mode tend to +# break things. In this case we need to enable the large-file API as well. +if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX") + add_definitions("-D_XOPEN_SOURCE=700") + add_definitions("-D_LARGE_FILE_API") +endif() + # Work around a broken bfd ld behavior. When linking a binary with a # foo.so library, it will try to find any library that foo.so uses and # check its symbols. This is wasteful (the check was done when foo.so diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake index e1e5cd3198b225ee25206ebd3501445e60f48d7d..0218d42eb8910be28a4be6d655978dbe5d98c51d 100644 --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -23,6 +23,13 @@ if( CMAKE_SYSTEM MATCHES "FreeBSD-9.2-RELEASE" AND list(APPEND CMAKE_REQUIRED_LIBRARIES "cxxrt") endif() +# Do checks with _XOPEN_SOURCE and large-file API on AIX, because we will build +# with those too. +if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX") + list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_XOPEN_SOURCE=700") + list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_LARGE_FILE_API") +endif() + # include checks check_include_file(dlfcn.h HAVE_DLFCN_H) check_include_file(errno.h HAVE_ERRNO_H) diff --git a/llvm/utils/unittest/CMakeLists.txt b/llvm/utils/unittest/CMakeLists.txt index 5b5cbf5d745f9b52921f7f6fce451b90a47b216f..0850d49e3a35725387c226192206991cc556afe5 100644 --- a/llvm/utils/unittest/CMakeLists.txt +++ b/llvm/utils/unittest/CMakeLists.txt @@ -28,6 +28,12 @@ if(WIN32) add_definitions(-DGTEST_OS_WINDOWS=1) endif() +# Google Test requires headers which need _ALL_SOURCE to build on AIX +if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX") + remove_definitions("-D_XOPEN_SOURCE=700") + add_definitions("-D_ALL_SOURCE") +endif() + if(SUPPORTS_VARIADIC_MACROS_FLAG) add_definitions("-Wno-variadic-macros") endif()