summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDean Michael Berris <dberris@google.com>2018-09-24 05:28:01 +0000
committerDean Michael Berris <dberris@google.com>2018-09-24 05:28:01 +0000
commitf578aaa0586dcc2a259a7e2556c6da9ee01b8b0b (patch)
treefd3ed019b72922f7bf564bf80aebe339c0edaef6
parent9a71e8064581ed8567c8bad52a27fd5ad410e6d8 (diff)
downloadbcm5719-llvm-f578aaa0586dcc2a259a7e2556c6da9ee01b8b0b.tar.gz
bcm5719-llvm-f578aaa0586dcc2a259a7e2556c6da9ee01b8b0b.zip
[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
-rw-r--r--compiler-rt/cmake/Modules/CompilerRTUtils.cmake18
-rw-r--r--compiler-rt/lib/xray/tests/CMakeLists.txt20
-rw-r--r--compiler-rt/lib/xray/tests/unit/CMakeLists.txt18
-rw-r--r--llvm/lib/LLVMBuild.txt1
-rw-r--r--llvm/lib/XRay/LLVMBuild.txt23
5 files changed, 64 insertions, 16 deletions
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(
diff --git a/compiler-rt/lib/xray/tests/CMakeLists.txt b/compiler-rt/lib/xray/tests/CMakeLists.txt
index d639303da43..73aa805cbd9 100644
--- a/compiler-rt/lib/xray/tests/CMakeLists.txt
+++ b/compiler-rt/lib/xray/tests/CMakeLists.txt
@@ -49,9 +49,8 @@ endfunction()
set(XRAY_TEST_ARCH ${XRAY_SUPPORTED_ARCH})
set(XRAY_UNITTEST_LINK_FLAGS
${CMAKE_THREAD_LIBS_INIT}
- -l${SANITIZER_CXX_ABI_LIBRARY}
- -fxray-instrument
- )
+ -l${SANITIZER_CXX_ABI_LIBRARY})
+
if (NOT APPLE)
append_list_if(COMPILER_RT_HAS_LIBM -lm XRAY_UNITTEST_LINK_FLAGS)
append_list_if(COMPILER_RT_HAS_LIBRT -lrt XRAY_UNITTEST_LINK_FLAGS)
@@ -62,6 +61,19 @@ if (NOT APPLE)
append_list_if(
COMPILER_RT_HAS_TERMINFO
-l${COMPILER_RT_TERMINFO_LIB} XRAY_UNITTEST_LINK_FLAGS)
+
+ if (COMPILER_RT_STANDALONE_BUILD)
+ append_list_if(COMPILER_RT_HAS_LLVMXRAY ${LLVM_XRAY_LDFLAGS} XRAY_UNITTEST_LINK_FLAGS)
+ append_list_if(COMPILER_RT_HAS_LLVMXRAY ${LLVM_XRAY_LIBLIST} XRAY_UNITTEST_LINK_FLAGS)
+ else()
+ # We add the library directories one at a time in our CFLAGS.
+ foreach (DIR ${LLVM_LIBRARY_DIR})
+ list(APPEND XRAY_UNITTEST_LINK_FLAGS -L${DIR})
+ endforeach()
+
+ # We also add the actual libraries to link as dependencies.
+ list(APPEND XRAY_UNITTEST_LINK_FLAGS -lLLVMXRay -lLLVMSupport -lLLVMTestingSupport)
+ endif()
endif()
macro(add_xray_unittest testname)
@@ -85,7 +97,7 @@ macro(add_xray_unittest testname)
DEPS gtest xray llvm-xray LLVMXRay LLVMTestingSupport
CFLAGS ${XRAY_UNITTEST_CFLAGS}
LINK_FLAGS ${TARGET_LINK_FLAGS} ${XRAY_UNITTEST_LINK_FLAGS}
- -lLLVMXRay -lLLVMSupport -lLLVMTestingSupport)
+ )
set_target_properties(XRayUnitTests
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
diff --git a/compiler-rt/lib/xray/tests/unit/CMakeLists.txt b/compiler-rt/lib/xray/tests/unit/CMakeLists.txt
index b1ead627e8c..d0ead947df2 100644
--- a/compiler-rt/lib/xray/tests/unit/CMakeLists.txt
+++ b/compiler-rt/lib/xray/tests/unit/CMakeLists.txt
@@ -1,14 +1,8 @@
-add_xray_unittest(XRayBufferQueueTest SOURCES
- buffer_queue_test.cc xray_unit_test_main.cc)
-add_xray_unittest(XRayAllocatorTest SOURCES
- allocator_test.cc xray_unit_test_main.cc)
-add_xray_unittest(XRaySegmentedArrayTest SOURCES
- segmented_array_test.cc xray_unit_test_main.cc)
-add_xray_unittest(XRayFunctionCallTrieTest SOURCES
- function_call_trie_test.cc xray_unit_test_main.cc)
-add_xray_unittest(XRayProfileCollectorTest SOURCES
- profile_collector_test.cc xray_unit_test_main.cc)
-
-add_xray_unittest(XRayFDRLoggingTest SOURCES
+add_xray_unittest(XRayTest SOURCES
+ buffer_queue_test.cc
+ allocator_test.cc
+ segmented_array_test.cc
+ function_call_trie_test.cc
+ profile_collector_test.cc
fdr_log_writer_test.cc
xray_unit_test_main.cc)
diff --git a/llvm/lib/LLVMBuild.txt b/llvm/lib/LLVMBuild.txt
index 19389519ca2..a6cd15699fb 100644
--- a/llvm/lib/LLVMBuild.txt
+++ b/llvm/lib/LLVMBuild.txt
@@ -44,6 +44,7 @@ subdirectories =
ToolDrivers
Transforms
WindowsManifest
+ XRay
[component_0]
type = Group
diff --git a/llvm/lib/XRay/LLVMBuild.txt b/llvm/lib/XRay/LLVMBuild.txt
new file mode 100644
index 00000000000..904168dad93
--- /dev/null
+++ b/llvm/lib/XRay/LLVMBuild.txt
@@ -0,0 +1,23 @@
+;===- ./lib/XRay/LLVMBuild.txt ---------------------------------*- Conf -*--===;
+;
+; The LLVM Compiler Infrastructure
+;
+; This file is distributed under the University of Illinois Open Source
+; License. See LICENSE.TXT for details.
+;
+;===------------------------------------------------------------------------===;
+;
+; This is an LLVMBuild description file for the components in this subdirectory.
+;
+; For more information on the LLVMBuild system, please see:
+;
+; http://llvm.org/docs/LLVMBuild.html
+;
+;===------------------------------------------------------------------------===;
+
+[component_0]
+type = Library
+name = XRay
+parent = Libraries
+required_libraries = Support Object
+installed = 1
OpenPOWER on IntegriCloud