[llvm-branch-commits] [compiler-rt] Allow running tests without installing first (PR #83088)

Alexander Richardson via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Feb 27 08:40:03 PST 2024


================
@@ -571,6 +571,30 @@ string(APPEND COMPILER_RT_TEST_COMPILER_CFLAGS " ${stdlib_flag}")
 string(REPLACE " " ";" COMPILER_RT_UNITTEST_CFLAGS "${COMPILER_RT_TEST_COMPILER_CFLAGS}")
 set(COMPILER_RT_UNITTEST_LINK_FLAGS ${COMPILER_RT_UNITTEST_CFLAGS})
 
+option(COMPILER_RT_TEST_STANDALONE_BUILD_LIBS
+  "When set to ON and testing in a standalone build, test the runtime \
+  libraries built by this standalone build rather than the runtime libraries \
+  shipped with the compiler (used for testing). When set to OFF and testing \
+  in a standalone build, test the runtime libraries shipped with the compiler \
+  (used for testing). This option has no effect if the compiler and this \
+  build are configured to use the same runtime library path."
+  ON)
+if (COMPILER_RT_TEST_STANDALONE_BUILD_LIBS)
+  # Ensure that the unit tests can find the sanitizer headers prior to installation.
+  list(APPEND COMPILER_RT_UNITTEST_CFLAGS "-I${CMAKE_CURRENT_LIST_DIR}/include")
+  # Ensure that unit tests link against the just-built runtime libraries instead
+  # of the ones bundled with the compiler by overriding the resource directory.
+  #
+  if ("${COMPILER_RT_TEST_COMPILER_ID}" MATCHES "Clang")
+    list(APPEND COMPILER_RT_UNITTEST_LINK_FLAGS "-resource-dir=${CMAKE_CURRENT_BINARY_DIR}")
+  endif()
+  get_compiler_rt_output_dir(${COMPILER_RT_DEFAULT_TARGET_ARCH} output_dir)
+  list(APPEND COMPILER_RT_UNITTEST_LINK_FLAGS "-Wl,-rpath,${output_dir}")
+endif()
+message(WARNING "COMPILER_RT_UNITTEST_LINK_FLAGS=${COMPILER_RT_UNITTEST_LINK_FLAGS}, COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=${COMPILER_RT_TEST_STANDALONE_BUILD_LIBS} COMPILER_RT_TEST_COMPILER_ID=${COMPILER_RT_TEST_COMPILER_ID}")
----------------
arichardson wrote:

Yes, will remove!

https://github.com/llvm/llvm-project/pull/83088


More information about the llvm-branch-commits mailing list