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.
Details
Details
Diff Detail
Diff Detail
Event Timeline
Comment Actions
I forgot to mention that this patch also turns on the necessary "-fcxx-modules" on Darwin.
It's probably a good idea to ask more specific questions to the reviewers:
@beanz: Does my CMake copypasta make sense?
@bruno: Are you ok with this as an intermediate step on Darwin?
@rsmith: Let me know if there are any caveats from the Linux side — the intention is that this is NFC on Linux.
Comment Actions
I have one minor suggestion that would make the code cleaner.
Right now, you construct the module flags both before and after the check. What if instead you put the following code under the if(LLVM_ENABLE_MODULES) line:
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()
Then you can replace the first place you construct the modules flags with:
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${module_flags}")
And the second place you construct the flags with just:
append("${module_flags}" CMAKE_CXX_FLAGS)
-Chris