Skip to content

Commit 6a6483c

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.6-beta.1
1 parent 70af40b commit 6a6483c

File tree

6 files changed

+53
-16
lines changed

6 files changed

+53
-16
lines changed

compiler-rt/cmake/Modules/AddCompilerRT.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ function(configure_compiler_rt_lit_site_cfg input output)
773773

774774
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} COMPILER_RT_RESOLVED_TEST_COMPILER ${COMPILER_RT_TEST_COMPILER})
775775
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} COMPILER_RT_RESOLVED_OUTPUT_DIR ${COMPILER_RT_OUTPUT_DIR})
776+
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} COMPILER_RT_RESOLVED_EXEC_OUTPUT_DIR ${COMPILER_RT_EXEC_OUTPUT_DIR})
776777
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR ${output_dir})
777778

778779
configure_lit_site_cfg(${input} ${output})

compiler-rt/test/hwasan/lit.cfg.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import os
44

5+
from lit.llvm import llvm_config
6+
from lit.llvm.subst import ToolSubst, FindTool
7+
58
# Setup config name.
69
config.name = "HWAddressSanitizer" + getattr(config, "name_suffix", "default")
710

@@ -74,6 +77,12 @@ def build_invocation(compile_flags):
7477
("%env_hwasan_opts=", "env HWASAN_OPTIONS=" + default_hwasan_opts_str)
7578
)
7679

80+
# Ensure that we can use hwasan_symbolize from the expected location
81+
llvm_config.add_tool_substitutions(
82+
[ToolSubst("hwasan_symbolize", unresolved="fatal")],
83+
search_dirs=[config.compiler_rt_bindir],
84+
)
85+
7786
# Default test suffixes.
7887
config.suffixes = [".c", ".cpp"]
7988

compiler-rt/test/lit.common.configured.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ set_default("python_executable", "@Python3_EXECUTABLE@")
2828
set_default("compiler_rt_debug", @COMPILER_RT_DEBUG_PYBOOL@)
2929
set_default("compiler_rt_intercept_libdispatch", @COMPILER_RT_INTERCEPT_LIBDISPATCH_PYBOOL@)
3030
set_default("compiler_rt_output_dir", "@COMPILER_RT_RESOLVED_OUTPUT_DIR@")
31+
set_default("compiler_rt_bindir", "@COMPILER_RT_RESOLVED_EXEC_OUTPUT_DIR@")
3132
set_default("compiler_rt_libdir", "@COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR@")
3233
set_default("emulator", "@COMPILER_RT_EMULATOR@")
3334
set_default("asan_shadow_scale", "@COMPILER_RT_ASAN_SHADOW_SCALE@")

libcxx/CMakeLists.txt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,9 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
413413
string(APPEND LIBCXX_TARGET_SUBDIR /${LIBCXX_LIBDIR_SUBDIR})
414414
endif()
415415
set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LIBCXX_TARGET_SUBDIR})
416-
set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
417-
set(LIBCXX_GENERATED_MODULE_DIR "${LLVM_BINARY_DIR}/modules/c++/v1")
418-
set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LIBCXX_TARGET_SUBDIR}/c++/v1")
416+
set(LIBCXX_GENERATED_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++/v1")
417+
set(LIBCXX_GENERATED_MODULE_DIR "${LIBCXX_BINARY_DIR}/modules/c++/v1")
418+
set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_BINARY_DIR}/include/${LIBCXX_TARGET_SUBDIR}/c++/v1")
419419
set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LIBCXX_TARGET_SUBDIR} CACHE STRING
420420
"Path where built libc++ libraries should be installed.")
421421
set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LIBCXX_TARGET_SUBDIR}/c++/v1" CACHE STRING
@@ -424,13 +424,11 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
424424
else()
425425
if(LLVM_LIBRARY_OUTPUT_INTDIR)
426426
set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
427-
set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
428-
set(LIBCXX_GENERATED_MODULE_DIR "${LLVM_BINARY_DIR}/modules/c++/v1")
429427
else()
430428
set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
431-
set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
432-
set(LIBCXX_GENERATED_MODULE_DIR "${CMAKE_BINARY_DIR}/modules/c++/v1")
433429
endif()
430+
set(LIBCXX_GENERATED_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++/v1")
431+
set(LIBCXX_GENERATED_MODULE_DIR "${LIBCXX_BINARY_DIR}/modules/c++/v1")
434432
set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}")
435433
set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE STRING
436434
"Path where built libc++ libraries should be installed.")

libcxxabi/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,7 @@ set(LIBCXXABI_STATIC_OUTPUT_NAME "c++abi" CACHE STRING "Output name for the stat
8686

8787
set(LIBCXXABI_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE STRING "Path to install the libc++abi headers at.")
8888

89-
if(LLVM_LIBRARY_OUTPUT_INTDIR)
90-
set(LIBCXXABI_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
91-
else()
92-
set(LIBCXXABI_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
93-
endif()
89+
set(LIBCXXABI_GENERATED_INCLUDE_DIR "${LIBCXXABI_BINARY_DIR}/include/c++/v1")
9490

9591
set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.")
9692
set(LIBCXXABI_LIBRARY_VERSION "1.0" CACHE STRING

runtimes/CMakeLists.txt

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ function(runtime_register_component name)
4949
set_property(GLOBAL APPEND PROPERTY SUB_COMPONENTS ${name})
5050
endfunction()
5151

52+
# This file can be used in two ways: it is either called from llvm/CMakeLists.txt
53+
# where case we reuse the build tree of the top-level build or directly invoked
54+
# in this directory. In that case we might be building against a LLVM install
55+
# tree and might not have a valid build tree set up yet.
56+
set(RUNTIMES_STANDALONE_BUILD OFF)
57+
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}")
58+
message(STATUS "Performing standalone runtimes build.")
59+
set(RUNTIMES_STANDALONE_BUILD ON)
60+
endif()
61+
5262
find_package(LLVM PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
5363
find_package(Clang PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
5464

@@ -68,8 +78,13 @@ endif()
6878

6979
# Setting these variables will allow the sub-build to put their outputs into
7080
# the library and bin directories of the top-level build.
71-
set(LLVM_LIBRARY_OUTPUT_INTDIR ${LLVM_LIBRARY_DIR})
72-
set(LLVM_RUNTIME_OUTPUT_INTDIR ${LLVM_TOOLS_BINARY_DIR})
81+
if (RUNTIMES_STANDALONE_BUILD)
82+
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
83+
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/bin)
84+
else()
85+
set(LLVM_LIBRARY_OUTPUT_INTDIR ${LLVM_LIBRARY_DIR})
86+
set(LLVM_RUNTIME_OUTPUT_INTDIR ${LLVM_TOOLS_BINARY_DIR})
87+
endif()
7388

7489
# This variable makes sure that e.g. llvm-lit is found.
7590
set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../llvm)
@@ -239,6 +254,21 @@ foreach(entry ${runtimes})
239254
endforeach()
240255

241256
if(LLVM_INCLUDE_TESTS)
257+
# If built with the runtimes build (rooted at runtimes/CMakeLists.txt), we
258+
# won't have llvm-lit. If built with the bootstrapping build (rooted at
259+
# llvm/CMakeLists.txt), the top-level llvm CMake invocation already generated
260+
# the llvm-lit script.
261+
if (RUNTIMES_STANDALONE_BUILD)
262+
# Ensure that the appropriate variables for lit are set before adding any
263+
# runtimes since their CMake tests configuration might depend on lit being
264+
# present. This ensures that the testsuites use a local lit from the build
265+
# dir rather than ${LLVM_INSTALL_DIR}/bin/llvm-lit (which may not exist if
266+
# LLVM_BINARY_DIR points at an installed LLVM tree rather than a build tree).
267+
set(LLVM_LIT_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/bin)
268+
get_llvm_lit_path(_base_dir _file_name)
269+
set(LLVM_EXTERNAL_LIT "${_base_dir}/${_file_name}" CACHE STRING "Command used to spawn lit" FORCE)
270+
endif()
271+
242272
set(LIT_ARGS_DEFAULT "-sv --show-xfail --show-unsupported")
243273
if (MSVC OR XCODE)
244274
set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
@@ -276,6 +306,8 @@ if(LLVM_INCLUDE_TESTS)
276306
# If built by manually invoking cmake on this directory, we don't have
277307
# llvm-lit. If invoked via llvm/runtimes, the toplevel llvm cmake
278308
# invocation already generated the llvm-lit script.
309+
# NOTE: this must be called fater all testsuites have been added, since
310+
# otherwise the generated llvm-lit does not have all required path mappings.
279311
add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit
280312
${CMAKE_CURRENT_BINARY_DIR}/llvm-lit)
281313
endif()
@@ -309,10 +341,10 @@ if(SUB_COMPONENTS)
309341
if(LLVM_RUNTIMES_TARGET)
310342
configure_file(
311343
${CMAKE_CURRENT_SOURCE_DIR}/Components.cmake.in
312-
${LLVM_BINARY_DIR}/runtimes/${LLVM_RUNTIMES_TARGET}/Components.cmake)
344+
${CMAKE_CURRENT_BINARY_DIR}/runtimes/${LLVM_RUNTIMES_TARGET}/Components.cmake)
313345
else()
314346
configure_file(
315347
${CMAKE_CURRENT_SOURCE_DIR}/Components.cmake.in
316-
${LLVM_BINARY_DIR}/runtimes/Components.cmake)
348+
${CMAKE_CURRENT_BINARY_DIR}/runtimes/Components.cmake)
317349
endif()
318350
endif()

0 commit comments

Comments
 (0)