1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 10:32:48 +02:00

[CMake] [Darwin] Add support for debugging tablegen dependencies

This patch adds an option to the build system LLVM_DEPENDENCY_DEBUGGING. Over time I plan to extend this to do more complex verifications, but the initial patch causes compile errors wherever there is missing a dependency on intrinsics_gen.

Because intrinsics_gen is a compile-time dependency not a link-time dependency, everything that relies on the headers generated in intrinsics_gen needs an explicit dependency.

llvm-svn: 287207
This commit is contained in:
Chris Bieneman 2016-11-17 04:36:59 +00:00
parent 488842a066
commit 9dda0e2259
2 changed files with 37 additions and 1 deletions

View File

@ -151,6 +151,20 @@ if(LLVM_CCACHE_BUILD)
endif()
endif()
option(LLVM_DEPENDENCY_DEBUGGING "Dependency debugging mode to verify correctly expressed library dependencies (Darwin only)" OFF)
# Some features of the LLVM build may be disallowed when dependency debugging is
# enabled. In particular you cannot use ccache because we want to force compile
# operations to always happen.
if(LLVM_DEPENDENCY_DEBUGGING)
if(NOT CMAKE_HOST_APPLE)
message(FATAL_ERROR "Dependency debugging is only currently supported on Darwin hosts.")
endif()
if(LLVM_CCACHE_BUILD)
message(FATAL_ERROR "Cannot enable dependency debugging while using ccache.")
endif()
endif()
option(LLVM_BUILD_GLOBAL_ISEL "Experimental: Build GlobalISel" OFF)
if(LLVM_BUILD_GLOBAL_ISEL)
add_definitions(-DLLVM_BUILD_GLOBAL_ISEL)

View File

@ -377,6 +377,8 @@ function(llvm_add_library name)
endif()
endif()
setup_dependency_debugging(${name} ${LLVM_COMMON_DEPENDS})
# Generate objlib
if((ARG_SHARED AND ARG_STATIC) OR ARG_OBJECT)
# Generate an obj library for both targets.
@ -645,9 +647,11 @@ endmacro(add_llvm_loadable_module name)
macro(add_llvm_executable name)
cmake_parse_arguments(ARG "DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH" "" "" ${ARGN})
cmake_parse_arguments(ARG "DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH" "" "DEPENDS" ${ARGN})
llvm_process_sources( ALL_FILES ${ARG_UNPARSED_ARGUMENTS} )
list(APPEND LLVM_COMMON_DEPENDS ${ARG_DEPENDS})
# Generate objlib
if(LLVM_ENABLE_OBJLIB)
# Generate an obj library for both targets.
@ -669,6 +673,8 @@ macro(add_llvm_executable name)
list(APPEND ALL_FILES "${LLVM_MAIN_SRC_DIR}/cmake/dummy.cpp")
endif()
setup_dependency_debugging(${name} ${LLVM_COMMON_DEPENDS})
if( EXCLUDE_FROM_ALL )
add_executable(${name} EXCLUDE_FROM_ALL ${ALL_FILES})
else()
@ -1377,3 +1383,19 @@ function(llvm_setup_rpath name)
INSTALL_RPATH "${_install_rpath}"
${_install_name_dir})
endfunction()
function(setup_dependency_debugging name)
if(NOT LLVM_DEPENDENCY_DEBUGGING)
return()
endif()
if("intrinsics_gen" IN_LIST ARGN)
return()
endif()
set(deny_attributes_gen "(deny file* (literal \"${LLVM_BINARY_DIR}/include/llvm/IR/Attributes.gen\"))")
set(deny_intrinsics_gen "(deny file* (literal \"${LLVM_BINARY_DIR}/include/llvm/IR/Intrinsics.gen\"))")
set(sandbox_command "sandbox-exec -p '(version 1) (allow default) ${deny_attributes_gen} ${deny_intrinsics_gen}'")
set_property(DIRECTORY PROPERTY RULE_LAUNCH_COMPILE ${sandbox_command})
endfunction()