This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Make -fmodules-local-submodule-visibility optional.
ClosedPublic

Authored by aprantl on Jun 28 2016, 7:28 PM.

Details

Reviewers
bruno
beanz
rsmith
Summary

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.

Diff Detail

Event Timeline

aprantl updated this revision to Diff 62169.Jun 28 2016, 7:28 PM
aprantl retitled this revision from to [CMake] Make -fmodules-local-submodule-visibility optional..
aprantl updated this object.
aprantl added reviewers: bruno, rsmith, beanz.
aprantl added a subscriber: llvm-commits.

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.

beanz edited edge metadata.Jun 29 2016, 1:46 PM

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

aprantl updated this revision to Diff 62285.Jun 29 2016, 2:02 PM
aprantl edited edge metadata.

Update patch according to beanz' suggestion. Much cleaner.

thanks!

beanz accepted this revision.Jun 29 2016, 3:53 PM
beanz edited edge metadata.

CMake code LGTM.

This revision is now accepted and ready to land.Jun 29 2016, 3:53 PM
bruno accepted this revision.Jul 5 2016, 11:55 AM
bruno edited edge metadata.

Hi Adrian,

This LGTM as an intermediate step on Darwin! :-)

aprantl closed this revision.Jul 5 2016, 12:55 PM

Thanks! Closing now.