diff options
author | Petr Hosek <phosek@google.com> | 2023-07-12 17:41:16 +0000 |
---|---|---|
committer | Petr Hosek <phosek@google.com> | 2023-07-12 22:30:43 +0000 |
commit | bb7a902c765b9c58412d11df4e2461764f0bbac5 (patch) | |
tree | 03e622f61b90cdfe4af13e0e5d3efcf34b14785f /compiler-rt | |
parent | a4c461c063a2ef229d577d050fef3cff7284fc4b (diff) | |
download | llvm-bb7a902c765b9c58412d11df4e2461764f0bbac5.zip llvm-bb7a902c765b9c58412d11df4e2461764f0bbac5.tar.gz llvm-bb7a902c765b9c58412d11df4e2461764f0bbac5.tar.bz2 |
[CMake] Use COMPILER_RT_BUILD_CRT in the condition for test
Unlike COMPILER_RT_HAS_CRT this handles the case where CRT is available
but has been disabled by setting COMPILER_RT_BUILD_CRT. This addresses
an issue reported on D153989.
Differential Revision: https://reviews.llvm.org/D155126
Diffstat (limited to 'compiler-rt')
-rw-r--r-- | compiler-rt/lib/builtins/CMakeLists.txt | 7 | ||||
-rw-r--r-- | compiler-rt/test/builtins/CMakeLists.txt | 3 | ||||
-rw-r--r-- | compiler-rt/test/builtins/Unit/ctor_dtor.c | 2 | ||||
-rw-r--r-- | compiler-rt/test/builtins/Unit/dso_handle.cpp | 2 | ||||
-rw-r--r-- | compiler-rt/test/builtins/Unit/lit.cfg.py | 35 | ||||
-rw-r--r-- | compiler-rt/test/builtins/Unit/lit.site.cfg.py.in | 1 |
6 files changed, 30 insertions, 20 deletions
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index 45d68fd..7f00391 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -895,9 +895,14 @@ if(COMPILER_RT_BUILD_STANDALONE_LIBATOMIC) add_dependencies(compiler-rt builtins-standalone-atomic) endif() +# TODO: COMPILER_RT_BUILD_CRT used to be a cached variable so we need to unset +# it first so cmake_dependent_option can set the local variable of the same +# name. This statement can be removed in the future. +unset(COMPILER_RT_BUILD_CRT CACHE) + cmake_dependent_option(COMPILER_RT_BUILD_CRT "Build crtbegin.o/crtend.o" ON "COMPILER_RT_HAS_CRT" OFF) -if(COMPILER_RT_BUILD_CRT) +if (COMPILER_RT_BUILD_CRT) add_compiler_rt_component(crt) option(COMPILER_RT_CRT_USE_EH_FRAME_REGISTRY "Use eh_frame in crtbegin.o/crtend.o" ON) diff --git a/compiler-rt/test/builtins/CMakeLists.txt b/compiler-rt/test/builtins/CMakeLists.txt index 2d0cc24..7c0469a 100644 --- a/compiler-rt/test/builtins/CMakeLists.txt +++ b/compiler-rt/test/builtins/CMakeLists.txt @@ -13,9 +13,10 @@ configure_lit_site_cfg( include(builtin-config-ix) -if (COMPILER_RT_HAS_CRT) +if (COMPILER_RT_BUILD_CRT) list(APPEND BUILTINS_TEST_DEPS crt) endif() +pythonize_bool(COMPILER_RT_BUILD_CRT) # Indicate if this is an MSVC environment. pythonize_bool(MSVC) diff --git a/compiler-rt/test/builtins/Unit/ctor_dtor.c b/compiler-rt/test/builtins/Unit/ctor_dtor.c index 2fdd2f7..4756072 100644 --- a/compiler-rt/test/builtins/Unit/ctor_dtor.c +++ b/compiler-rt/test/builtins/Unit/ctor_dtor.c @@ -1,4 +1,4 @@ -// REQUIRES: linux +// REQUIRES: crt // RUN: %clang -fno-use-init-array -g -c %s -o %t.o // RUN: %clang -o %t -no-pie -nostdlib %crt1 %crti %crtbegin %t.o -lc %libgcc %crtend %crtn diff --git a/compiler-rt/test/builtins/Unit/dso_handle.cpp b/compiler-rt/test/builtins/Unit/dso_handle.cpp index 00c5491..7967469 100644 --- a/compiler-rt/test/builtins/Unit/dso_handle.cpp +++ b/compiler-rt/test/builtins/Unit/dso_handle.cpp @@ -1,4 +1,4 @@ -// REQUIRES: linux +// REQUIRES: crt // RUN: %clangxx -g -fno-exceptions -DCRT_SHARED -c %s -fPIC -o %tshared.o // RUN: %clangxx -g -fno-exceptions -c %s -fPIC -o %t.o diff --git a/compiler-rt/test/builtins/Unit/lit.cfg.py b/compiler-rt/test/builtins/Unit/lit.cfg.py index 16d5a46..f63d159 100644 --- a/compiler-rt/test/builtins/Unit/lit.cfg.py +++ b/compiler-rt/test/builtins/Unit/lit.cfg.py @@ -106,26 +106,29 @@ else: base_lib = base_lib.replace("\\", "/") config.substitutions.append(("%librt ", base_lib + " -lc -lm ")) - if config.host_os == "Linux": - base_obj = os.path.join( - config.compiler_rt_libdir, "clang_rt.%%s%s.o" % config.target_suffix - ) - if sys.platform in ["win32"] and execute_external: - # Don't pass dosish path separator to msys bash.exe. - base_obj = base_obj.replace("\\", "/") +builtins_build_crt = get_required_attr(config, "builtins_build_crt") +if builtins_build_crt: + base_obj = os.path.join( + config.compiler_rt_libdir, "clang_rt.%%s%s.o" % config.target_suffix + ) + if sys.platform in ["win32"] and execute_external: + # Don't pass dosish path separator to msys bash.exe. + base_obj = base_obj.replace("\\", "/") - config.substitutions.append(("%crtbegin", base_obj % "crtbegin")) - config.substitutions.append(("%crtend", base_obj % "crtend")) + config.substitutions.append(("%crtbegin", base_obj % "crtbegin")) + config.substitutions.append(("%crtend", base_obj % "crtend")) - config.substitutions.append(("%crt1", get_library_path("crt1.o"))) - config.substitutions.append(("%crti", get_library_path("crti.o"))) - config.substitutions.append(("%crtn", get_library_path("crtn.o"))) + config.substitutions.append(("%crt1", get_library_path("crt1.o"))) + config.substitutions.append(("%crti", get_library_path("crti.o"))) + config.substitutions.append(("%crtn", get_library_path("crtn.o"))) - config.substitutions.append(("%libgcc", get_libgcc_file_name())) + config.substitutions.append(("%libgcc", get_libgcc_file_name())) - config.substitutions.append( - ("%libstdcxx", "-l" + config.sanitizer_cxx_lib.lstrip("lib")) - ) + config.substitutions.append( + ("%libstdcxx", "-l" + config.sanitizer_cxx_lib.lstrip("lib")) + ) + + config.available_features.add("crt") builtins_source_dir = os.path.join( get_required_attr(config, "compiler_rt_src_root"), "lib", "builtins" diff --git a/compiler-rt/test/builtins/Unit/lit.site.cfg.py.in b/compiler-rt/test/builtins/Unit/lit.site.cfg.py.in index 920c915..a42d5c1 100644 --- a/compiler-rt/test/builtins/Unit/lit.site.cfg.py.in +++ b/compiler-rt/test/builtins/Unit/lit.site.cfg.py.in @@ -5,6 +5,7 @@ config.builtins_lit_source_dir = "@BUILTINS_LIT_SOURCE_DIR@/Unit" config.target_cflags = "@BUILTINS_TEST_TARGET_CFLAGS@" config.target_arch = "@BUILTINS_TEST_TARGET_ARCH@" config.sanitizer_cxx_lib = "@SANITIZER_TEST_CXX_LIBNAME@" +config.builtins_build_crt = @COMPILER_RT_BUILD_CRT_PYBOOL@ config.is_msvc = @MSVC_PYBOOL@ config.builtins_is_msvc = @BUILTINS_IS_MSVC_PYBOOL@ config.builtins_lit_source_features = "@BUILTINS_LIT_SOURCE_FEATURES@" |