[llvm] r274196 - [CMake] Introduce a LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY flag.

Vassil Vassilev via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 30 08:57:12 PDT 2016


On 30/06/16 17:52, Adrian Prantl wrote:
>> On Jun 30, 2016, at 6:46 AM, Vassil Vassilev <v.g.vassilev at gmail.com> wrote:
>>
>> On 30/06/16 03:46, Adrian Prantl via llvm-commits wrote:
>>> Author: adrian
>>> Date: Wed Jun 29 20:46:49 2016
>>> New Revision: 274196
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=274196&view=rev
>>> Log:
>>> [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
>>>
>>> Modified:
>>>      llvm/trunk/CMakeLists.txt
>>>      llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
>>>
>>> Modified: llvm/trunk/CMakeLists.txt
>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=274196&r1=274195&r2=274196&view=diff
>>> ==============================================================================
>>> --- llvm/trunk/CMakeLists.txt (original)
>>> +++ llvm/trunk/CMakeLists.txt Wed Jun 29 20:46:49 2016
>>> @@ -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)
>>>
>>> Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=274196&r1=274195&r2=274196&view=diff
>>> ==============================================================================
>>> --- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
>>> +++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Wed Jun 29 20:46:49 2016
>>> @@ -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")
>> -fmodules-cache-path is a driver option. I guess you meant to swap -Xclang and -fmodules-cache-path, so that it'd send -fmodules-local-submodule-visibility to cc1.
>>> +    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")
>> I'd remove the redundant -Xclang above and add one here before -fmodules-local-submodule-visibility. This would fix the non-darwin module builds.
> Thanks for noticing! Fixed in r274240.
Sure! Btw, I fixed it in r274227 and it seems that r274240 reintroduces 
the issue.
>
> -- adrian
>
>>> +    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()
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list