[PATCH] D58951: [compiler-rt][tests] Improve handling with non-default toolchains
Hubert Tong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 9 16:54:24 PST 2020
hubert.reinterpretcast updated this revision to Diff 304015.
hubert.reinterpretcast added a comment.
Rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58951/new/
https://reviews.llvm.org/D58951
Files:
compiler-rt/CMakeLists.txt
compiler-rt/cmake/Modules/AddCompilerRT.cmake
compiler-rt/cmake/base-config-ix.cmake
compiler-rt/cmake/config-ix.cmake
compiler-rt/test/lit.common.configured.in
Index: compiler-rt/test/lit.common.configured.in
===================================================================
--- compiler-rt/test/lit.common.configured.in
+++ compiler-rt/test/lit.common.configured.in
@@ -7,7 +7,7 @@
# Generic config options for all compiler-rt lit tests.
set_default("target_triple", "@COMPILER_RT_DEFAULT_TARGET_TRIPLE@")
-set_default("target_cflags", "@COMPILER_RT_TEST_COMPILER_CFLAGS@")
+set_default("target_cflags", "@COMPILER_RT_TOOLCHAIN_CFLAGS@")
set_default("host_arch", "@HOST_ARCH@")
set_default("target_arch", "@COMPILER_RT_DEFAULT_TARGET_ARCH@")
set_default("host_os", "@HOST_OS@")
Index: compiler-rt/cmake/config-ix.cmake
===================================================================
--- compiler-rt/cmake/config-ix.cmake
+++ compiler-rt/cmake/config-ix.cmake
@@ -229,6 +229,7 @@
if(APPLE)
list(APPEND ${cflags_out} ${DARWIN_osx_CFLAGS})
endif()
+ list(APPEND ${cflags_out} ${COMPILER_RT_TOOLCHAIN_CFLAGS})
string(REPLACE ";" " " ${cflags_out} "${${cflags_out}}")
endif()
endmacro()
@@ -244,7 +245,7 @@
get_target_flags_for_arch(${arch} test_cflags)
list(APPEND test_cflags ${DARWIN_${platform}_CFLAGS})
string(REPLACE ";" " " test_cflags_str "${test_cflags}")
- string(APPEND test_cflags_str "${COMPILER_RT_TEST_COMPILER_CFLAGS}")
+ string(APPEND test_cflags_str "${COMPILER_RT_TOOLCHAIN_CFLAGS}")
set(${cflags_out} "${test_cflags_str}" PARENT_SCOPE)
endfunction()
Index: compiler-rt/cmake/base-config-ix.cmake
===================================================================
--- compiler-rt/cmake/base-config-ix.cmake
+++ compiler-rt/cmake/base-config-ix.cmake
@@ -227,4 +227,12 @@
endif()
set(COMPILER_RT_OS_SUFFIX "")
endif()
+ # Set up options associated with the toolchain.
+ if(COMPILER_RT_TEST_COMPILER_CFLAGS)
+ # COMPILER_RT_TEST_COMPILER_CFLAGS is used for cross-compiling.
+ set(COMPILER_RT_TOOLCHAIN_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS})
+ elseif(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN AND COMPILER_RT_TEST_COMPILER_ID MATCHES "Clang")
+ # Use the non-default toolchain specified for the build when compiling tests.
+ set(COMPILER_RT_TOOLCHAIN_CFLAGS "--gcc-toolchain=${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}")
+ endif()
endmacro()
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake
===================================================================
--- compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -570,6 +570,8 @@
set(PASSTHROUGH_VARIABLES
CMAKE_C_COMPILER_TARGET
CMAKE_CXX_COMPILER_TARGET
+ CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN
+ CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN
CMAKE_SHARED_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS
CMAKE_EXE_LINKER_FLAGS
Index: compiler-rt/CMakeLists.txt
===================================================================
--- compiler-rt/CMakeLists.txt
+++ compiler-rt/CMakeLists.txt
@@ -500,11 +500,11 @@
# move some of the common flags to COMPILER_RT_UNITTEST_CFLAGS.
# Unittests need access to C++ standard library.
-string(APPEND COMPILER_RT_TEST_COMPILER_CFLAGS " ${stdlib_flag}")
+string(APPEND COMPILER_RT_TOOLCHAIN_CFLAGS " ${stdlib_flag}")
-# When cross-compiling, COMPILER_RT_TEST_COMPILER_CFLAGS help in compilation
-# and linking of unittests.
-string(REPLACE " " ";" COMPILER_RT_UNITTEST_CFLAGS "${COMPILER_RT_TEST_COMPILER_CFLAGS}")
+# When cross-compiling or using a non-default toolchain,
+# COMPILER_RT_TOOLCHAIN_CFLAGS help in compilation and linking of unittests.
+string(REPLACE " " ";" COMPILER_RT_UNITTEST_CFLAGS "${COMPILER_RT_TOOLCHAIN_CFLAGS}")
set(COMPILER_RT_UNITTEST_LINK_FLAGS ${COMPILER_RT_UNITTEST_CFLAGS})
# Unittests support.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58951.304015.patch
Type: text/x-patch
Size: 3735 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201110/27a5ec0e/attachment.bin>
More information about the llvm-commits
mailing list