From f578aaa0586dcc2a259a7e2556c6da9ee01b8b0b Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Mon, 24 Sep 2018 05:28:01 +0000 Subject: [XRay] Clean up XRay build configuration Summary: This change spans both LLVM and compiler-rt, where we do the following: - Add XRay to the LLVMBuild system, to allow for distributing the XRay trace loading library along with the LLVM distributions. - Use `llvm-config` better in the compiler-rt XRay implementation, to depend on the potentially already-distributed LLVM XRay library. While this is tested with the standalone compiler-rt build, it does require that the LLVMXRay library (and LLVMSupport as well) are available during the build. In case the static libraries are available, the unit tests will build and work fine. We're still having issues with attempting to use a shared library version of the LLVMXRay library since the shared library might not be accessible from the standard shared library lookup paths. The larger change here is the inclusion of the LLVMXRay library in the distribution, which allows for building tools around the XRay traces and profiles that the XRay runtime already generates. Reviewers: echristo, beanz Subscribers: mgorny, hiraditya, mboerger, llvm-commits Differential Revision: https://reviews.llvm.org/D52349 llvm-svn: 342859 --- compiler-rt/cmake/Modules/CompilerRTUtils.cmake | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'compiler-rt/cmake/Modules') diff --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake index e2884e23e37..d2cb4867799 100644 --- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake +++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake @@ -236,6 +236,24 @@ macro(load_llvm_config) set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin") set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Paths to LLVM headers") + # Detect if we have the LLVMXRay and TestingSupport library installed and + # available from llvm-config. + execute_process( + COMMAND ${LLVM_CONFIG_PATH} "--ldflags" "--libs" "xray" "testingsupport" + RESULT_VARIABLE HAD_ERROR + OUTPUT_VARIABLE CONFIG_OUTPUT) + if (HAD_ERROR) + message(WARNING "llvm-config finding xray failed with status ${HAD_ERROR}") + set(COMPILER_RT_HAS_LLVMXRAY FALSE) + else() + string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";" CONFIG_OUTPUT ${CONFIG_OUTPUT}) + list(GET CONFIG_OUTPUT 0 LDFLAGS) + list(GET CONFIG_OUTPUT 1 LIBLIST) + set(LLVM_XRAY_LDFLAGS ${LDFLAGS} CACHE STRING "Linker flags for LLVMXRay library") + set(LLVM_XRAY_LIBLIST ${LIBLIST} CACHE STRING "Library list for LLVMXRay") + set(COMPILER_RT_HAS_LLVMXRAY TRUE) + endif() + # Make use of LLVM CMake modules. # --cmakedir is supported since llvm r291218 (4.0 release) execute_process( -- cgit v1.2.3