Skip to content

Commit 97bc08a

Browse files
committed
[CMake] Support compiler-rt builtins library in tests
We're building tests with -nostdlib which means that we need to explicitly include the builtins library. When using libgcc (default) we can simply include -lgcc_s on the link line, but when using compiler-rt builtins we need a complete path to the builtins library. This path is already available in CMake as <PROJECT>_BUILTINS_LIBRARY, so we just need to pass that path to lit and if config.compiler_rt is true, link it to the test. Prior to this patch, running tests when compiler-rt is being used as the builtins library was broken as all tests would fail to link, but with this change running tests when compiler-rt bultins library is being used should be supported. Differential Revision: https://reviews.llvm.org/D56701 llvm-svn: 353208
1 parent e2c5847 commit 97bc08a

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

libcxx/docs/TestingLibcxx.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ configuration. Passing the option on the command line will override the default.
183183
option is specified or the environment variable LIBCXX_COLOR_DIAGNOSTICS is
184184
present then color diagnostics will be enabled.
185185

186+
.. option:: llvm_unwinder
187+
188+
Enable the use of LLVM unwinder instead of libgcc.
189+
190+
.. option:: builtins_library
191+
192+
Path to the builtins library to use instead of libgcc.
193+
186194

187195
Environment Variables
188196
---------------------

libcxx/test/lit.site.cfg.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ config.test_compiler_flags = "@LIBCXX_TEST_COMPILER_FLAGS@"
2727

2828
config.executor = "@LIBCXX_EXECUTOR@"
2929
config.llvm_unwinder = @LIBCXXABI_USE_LLVM_UNWINDER@
30-
config.compiler_rt = @LIBCXX_USE_COMPILER_RT@
30+
config.builtins_library = "@LIBCXX_BUILTINS_LIBRARY@"
3131
config.has_libatomic = @LIBCXX_HAS_ATOMIC_LIB@
3232
config.use_libatomic = @LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB@
3333
config.debug_build = @LIBCXX_DEBUG_BUILD@

libcxx/utils/libcxx/test/target_info.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,10 @@ def add_cxx_link_flags(self, flags):
251251
flags += ['-lunwind', '-ldl']
252252
else:
253253
flags += ['-lgcc_s']
254-
compiler_rt = self.full_config.get_lit_bool('compiler_rt', False)
255-
if not compiler_rt:
254+
builtins_lib = self.full_config.get_lit_conf('builtins_library')
255+
if builtins_lib:
256+
flags += [builtins_lib]
257+
else:
256258
flags += ['-lgcc']
257259
use_libatomic = self.full_config.get_lit_bool('use_libatomic', False)
258260
if use_libatomic:

libcxxabi/test/lit.site.cfg.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ config.cxx_headers = "@LIBCXXABI_LIBCXX_INCLUDES@"
99
config.libunwind_headers = "@LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL@"
1010
config.cxx_library_root = "@LIBCXXABI_LIBCXX_LIBRARY_PATH@"
1111
config.llvm_unwinder = @LIBCXXABI_USE_LLVM_UNWINDER@
12-
config.compiler_rt = @LIBCXXABI_USE_COMPILER_RT@
12+
config.builtins_library = "@LIBCXXABI_BUILTINS_LIBRARY@"
1313
config.enable_threads = @LIBCXXABI_ENABLE_THREADS@
1414
config.use_sanitizer = "@LLVM_USE_SANITIZER@"
1515
config.sanitizer_library = "@LIBCXXABI_SANITIZER_LIBRARY@"

libunwind/test/lit.site.cfg.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ config.libcxx_src_root = "@LIBUNWIND_LIBCXX_PATH@"
88
config.libunwind_headers = "@LIBUNWIND_SOURCE_DIR@/include"
99
config.cxx_library_root = "@LIBUNWIND_LIBCXX_LIBRARY_PATH@"
1010
config.llvm_unwinder = True
11-
config.compiler_rt = @LIBUNWIND_USE_COMPILER_RT@
11+
config.builtins_library = "@LIBUNWIND_BUILTINS_LIBRARY@"
1212
config.enable_threads = @LIBUNWIND_ENABLE_THREADS@
1313
config.use_sanitizer = "@LLVM_USE_SANITIZER@"
1414
config.enable_32bit = @LIBUNWIND_BUILD_32_BITS@

0 commit comments

Comments
 (0)