diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2016-01-13 19:58:01 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2016-01-13 19:58:01 +0000 |
| commit | 050e163ae8b4bb6eb252b59e2f8f36e68ae9239d (patch) | |
| tree | 7376a0c71aad05d327e5b1dcbceb3311a10f9f29 /cmake/modules | |
| parent | 8a6c1c25bce0267ee4072bd7b786b921e8a66a35 (diff) | |
Notes
Diffstat (limited to 'cmake/modules')
| -rwxr-xr-x | cmake/modules/AddLLVM.cmake | 6 | ||||
| -rw-r--r-- | cmake/modules/HandleLLVMOptions.cmake | 30 |
2 files changed, 34 insertions, 2 deletions
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake index bed81b28426ef..b06e434a2487a 100755 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -308,6 +308,8 @@ endfunction(set_windows_version_resource_properties) # SHARED;STATIC # STATIC by default w/o BUILD_SHARED_LIBS. # SHARED by default w/ BUILD_SHARED_LIBS. +# OBJECT +# Also create an OBJECT library target. Default if STATIC && SHARED. # MODULE # Target ${name} might not be created on unsupported platforms. # Check with "if(TARGET ${name})". @@ -329,7 +331,7 @@ endfunction(set_windows_version_resource_properties) # ) function(llvm_add_library name) cmake_parse_arguments(ARG - "MODULE;SHARED;STATIC;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME" + "MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME" "OUTPUT_NAME" "ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS" ${ARGN}) @@ -362,7 +364,7 @@ function(llvm_add_library name) endif() # Generate objlib - if(ARG_SHARED AND ARG_STATIC) + if((ARG_SHARED AND ARG_STATIC) OR ARG_OBJECT) # Generate an obj library for both targets. set(obj_name "obj.${name}") add_library(${obj_name} OBJECT EXCLUDE_FROM_ALL diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake index 4c5ffe2f7b28e..6db258ff66a15 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake @@ -363,6 +363,36 @@ if( MSVC ) append("/Zc:inline" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + if (NOT LLVM_ENABLE_TIMESTAMPS AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # clang-cl and cl by default produce non-deterministic binaries because + # link.exe /incremental requires a timestamp in the .obj file. clang-cl + # has the flag /Brepro to force deterministic binaries, so pass that when + # LLVM_ENABLE_TIMESTAMPS is turned off. + # This checks CMAKE_CXX_COMPILER_ID in addition to check_cxx_compiler_flag() + # because cl.exe does not emit an error on flags it doesn't understand, + # letting check_cxx_compiler_flag() claim it understands all flags. + check_cxx_compiler_flag("/Brepro" SUPPORTS_BREPRO) + append_if(SUPPORTS_BREPRO "/Brepro" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + + if (SUPPORTS_BREPRO) + # Check if /INCREMENTAL is passed to the linker and complain that it + # won't work with /Brepro. + string(TOUPPER "${CMAKE_EXE_LINKER_FLAGS}" upper_exe_flags) + string(TOUPPER "${CMAKE_MODULE_LINKER_FLAGS}" upper_module_flags) + string(TOUPPER "${CMAKE_SHARED_LINKER_FLAGS}" upper_shared_flags) + + string(FIND "${upper_exe_flags}" "/INCREMENTAL" exe_index) + string(FIND "${upper_module_flags}" "/INCREMENTAL" module_index) + string(FIND "${upper_shared_flags}" "/INCREMENTAL" shared_index) + + if (${exe_index} GREATER -1 OR + ${module_index} GREATER -1 OR + ${shared_index} GREATER -1) + message(FATAL_ERROR "LLVM_ENABLE_TIMESTAMPS not compatible with /INCREMENTAL linking") + endif() + endif() + endif() + # Disable sized deallocation if the flag is supported. MSVC fails to compile # the operator new overload in User otherwise. check_c_compiler_flag("/WX /Zc:sizedDealloc-" SUPPORTS_SIZED_DEALLOC) |
