diff options
author | Adrian Prantl <aprantl@apple.com> | 2016-06-30 01:46:49 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2016-06-30 01:46:49 +0000 |
commit | 48e7cbdf41d7f54c2e75b2c1d16b5b75af4f6e69 (patch) | |
tree | 28db3f27ba2aa004ee4b905520eb7253ee23deef | |
parent | 66ec178c6c738446c086803d24a87cc8848a0280 (diff) | |
download | bcm5719-llvm-48e7cbdf41d7f54c2e75b2c1d16b5b75af4f6e69.tar.gz bcm5719-llvm-48e7cbdf41d7f54c2e75b2c1d16b5b75af4f6e69.zip |
[CMake] Introduce a LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY flag.
On Darwin it is currently impossible to build LLVM with modules
because the Darwin system module map is not compatible with
-fmodules-local-submodule-visibility at this point in time. This
patch makes the flag optional and off by default on Darwin so it
becomes possible to build LLVM with modules again.
http://reviews.llvm.org/D21827
rdar://problem/27019000
llvm-svn: 274196
-rw-r--r-- | llvm/CMakeLists.txt | 5 | ||||
-rw-r--r-- | llvm/cmake/modules/HandleLLVMOptions.cmake | 13 |
2 files changed, 16 insertions, 2 deletions
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index a83d47761a4..f779c6f8031 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -283,6 +283,11 @@ include(AddLLVMDefinitions) option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON) option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON) option(LLVM_ENABLE_MODULES "Compile with C++ modules enabled." OFF) +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + option(LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY "Compile with -fmodules-local-submodule-visibility." OFF) +else() + option(LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY "Compile with -fmodules-local-submodule-visibility." ON) +endif() option(LLVM_ENABLE_CXX1Y "Compile with C++1y enabled." OFF) option(LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF) option(LLVM_ENABLE_LIBCXXABI "Use libc++abi when using libc++." OFF) diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index 493c1c9eb71..d4587913522 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -465,7 +465,16 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE ) endif() if (LLVM_ENABLE_MODULES) set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fmodules -Xclang -fmodules-local-submodule-visibility -fmodules-cache-path=module.cache") + set(module_flags "-fmodules -Xclang -fmodules-cache-path=module.cache") + if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + # On Darwin -fmodules does not imply -fcxx-modules. + set(module_flags "${module_flags} -fcxx-modules") + endif() + if (LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY) + set(module_flags "${module_flags} -fmodules-local-submodule-visibility") + endif() + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${module_flags}") + # Check that we can build code with modules enabled, and that repeatedly # including <cassert> still manages to respect NDEBUG properly. CHECK_CXX_SOURCE_COMPILES("#undef NDEBUG @@ -476,7 +485,7 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE ) CXX_SUPPORTS_MODULES) set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) if (CXX_SUPPORTS_MODULES) - append_if(CXX_SUPPORTS_MODULES "-fmodules -Xclang -fmodules-local-submodule-visibility -fmodules-cache-path=module.cache" CMAKE_CXX_FLAGS) + append("${module_flags}" CMAKE_CXX_FLAGS) else() message(FATAL_ERROR "LLVM_ENABLE_MODULES is not supported by this compiler") endif() |