Skip to content

Commit 2084a07

Browse files
committed
Revert "[compiler-rt] Allow running tests without installing first"
This reverts commit c91254d. It was throwing error: g++: error: unrecognized command line option ‘-resource-dir=
1 parent 110c22f commit 2084a07

File tree

7 files changed

+32
-98
lines changed

7 files changed

+32
-98
lines changed

compiler-rt/CMakeLists.txt

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -584,29 +584,6 @@ string(APPEND COMPILER_RT_TEST_COMPILER_CFLAGS " ${stdlib_flag}")
584584
string(REPLACE " " ";" COMPILER_RT_UNITTEST_CFLAGS "${COMPILER_RT_TEST_COMPILER_CFLAGS}")
585585
set(COMPILER_RT_UNITTEST_LINK_FLAGS ${COMPILER_RT_UNITTEST_CFLAGS})
586586

587-
option(COMPILER_RT_TEST_STANDALONE_BUILD_LIBS
588-
"When set to ON and testing in a standalone build, test the runtime \
589-
libraries built by this standalone build rather than the runtime libraries \
590-
shipped with the compiler (used for testing). When set to OFF and testing \
591-
in a standalone build, test the runtime libraries shipped with the compiler \
592-
(used for testing). This option has no effect if the compiler and this \
593-
build are configured to use the same runtime library path."
594-
ON)
595-
if (COMPILER_RT_TEST_STANDALONE_BUILD_LIBS)
596-
# Ensure that the unit tests can find the sanitizer headers prior to installation.
597-
list(APPEND COMPILER_RT_UNITTEST_CFLAGS "-I${CMAKE_CURRENT_LIST_DIR}/include")
598-
# Ensure that unit tests link against the just-built runtime libraries instead
599-
# of the ones bundled with the compiler by overriding the resource directory.
600-
#
601-
if ("${COMPILER_RT_TEST_COMPILER_ID}" MATCHES "Clang")
602-
list(APPEND COMPILER_RT_UNITTEST_LINK_FLAGS "-resource-dir=${COMPILER_RT_OUTPUT_DIR}")
603-
endif()
604-
get_compiler_rt_output_dir(${COMPILER_RT_DEFAULT_TARGET_ARCH} rtlib_dir)
605-
if (NOT WIN32)
606-
list(APPEND COMPILER_RT_UNITTEST_LINK_FLAGS "-Wl,-rpath,${rtlib_dir}")
607-
endif()
608-
endif()
609-
610587
if(COMPILER_RT_USE_LLVM_UNWINDER)
611588
# We're linking directly against the libunwind that we're building so don't
612589
# try to link in the toolchain's default libunwind which may be missing.

compiler-rt/cmake/Modules/AddCompilerRT.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,6 @@ function(configure_compiler_rt_lit_site_cfg input output)
768768
get_compiler_rt_output_dir(${COMPILER_RT_DEFAULT_TARGET_ARCH} output_dir)
769769

770770
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} COMPILER_RT_RESOLVED_TEST_COMPILER ${COMPILER_RT_TEST_COMPILER})
771-
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} COMPILER_RT_RESOLVED_OUTPUT_DIR ${COMPILER_RT_OUTPUT_DIR})
772771
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR ${output_dir})
773772

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

compiler-rt/test/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Needed for lit support in standalone builds.
22
include(AddLLVM)
33

4+
option(COMPILER_RT_TEST_STANDALONE_BUILD_LIBS
5+
"When set to ON and testing in a standalone build, test the runtime \
6+
libraries built by this standalone build rather than the runtime libraries \
7+
shipped with the compiler (used for testing). When set to OFF and testing \
8+
in a standalone build, test the runtime libraries shipped with the compiler \
9+
(used for testing). This option has no effect if the compiler and this \
10+
build are configured to use the same runtime library path."
11+
ON)
412
pythonize_bool(COMPILER_RT_TEST_STANDALONE_BUILD_LIBS)
513

614
pythonize_bool(LLVM_ENABLE_EXPENSIVE_CHECKS)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ def generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True, msan_enabled=False):
106106
return " ".join(
107107
[
108108
compiler_cmd,
109-
config.target_cflags,
110109
std_cmd,
111110
"-O2 -gline-tables-only",
112111
sanitizers_cmd,

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

Lines changed: 22 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,6 @@
1414
import lit.util
1515

1616

17-
def get_path_from_clang(args, allow_failure):
18-
clang_cmd = [
19-
config.clang.strip(),
20-
f"--target={config.target_triple}",
21-
*args,
22-
]
23-
path = None
24-
try:
25-
result = subprocess.run(
26-
clang_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True
27-
)
28-
path = result.stdout.decode().strip()
29-
except subprocess.CalledProcessError as e:
30-
msg = f"Failed to run {clang_cmd}\nrc:{e.returncode}\nstdout:{e.stdout}\ne.stderr{e.stderr}"
31-
if allow_failure:
32-
lit_config.warning(msg)
33-
else:
34-
lit_config.fatal(msg)
35-
return path, clang_cmd
36-
37-
3817
def find_compiler_libdir():
3918
"""
4019
Returns the path to library resource directory used
@@ -47,6 +26,26 @@ def find_compiler_libdir():
4726
# TODO: Support other compilers.
4827
return None
4928

29+
def get_path_from_clang(args, allow_failure):
30+
clang_cmd = [
31+
config.clang.strip(),
32+
f"--target={config.target_triple}",
33+
]
34+
clang_cmd.extend(args)
35+
path = None
36+
try:
37+
result = subprocess.run(
38+
clang_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True
39+
)
40+
path = result.stdout.decode().strip()
41+
except subprocess.CalledProcessError as e:
42+
msg = f"Failed to run {clang_cmd}\nrc:{e.returncode}\nstdout:{e.stdout}\ne.stderr{e.stderr}"
43+
if allow_failure:
44+
lit_config.warning(msg)
45+
else:
46+
lit_config.fatal(msg)
47+
return path, clang_cmd
48+
5049
# Try using `-print-runtime-dir`. This is only supported by very new versions of Clang.
5150
# so allow failure here.
5251
runtime_dir, clang_cmd = get_path_from_clang(
@@ -169,51 +168,10 @@ def push_dynamic_library_lookup_path(config, new_path):
169168
r"/i386(?=-[^/]+$)", "/x86_64", config.compiler_rt_libdir
170169
)
171170

172-
173-
# Check if the test compiler resource dir matches the local build directory
174-
# (which happens with -DLLVM_ENABLE_PROJECTS=clang;compiler-rt) or if we are
175-
# using an installed clang to test compiler-rt standalone. In the latter case
176-
# we may need to override the resource dir to match the path of the just-built
177-
# compiler-rt libraries.
178-
test_cc_resource_dir, _ = get_path_from_clang(
179-
shlex.split(config.target_cflags) + ["-print-resource-dir"], allow_failure=True
180-
)
181-
# Normalize the path for comparison
182-
if test_cc_resource_dir is not None:
183-
test_cc_resource_dir = os.path.realpath(test_cc_resource_dir)
184-
if lit_config.debug:
185-
lit_config.note(f"Resource dir for {config.clang} is {test_cc_resource_dir}")
186-
local_build_resource_dir = os.path.realpath(config.compiler_rt_output_dir)
187-
if test_cc_resource_dir != local_build_resource_dir and config.test_standalone_build_libs:
188-
if config.compiler_id == "Clang":
189-
if lit_config.debug:
190-
lit_config.note(
191-
f"Overriding test compiler resource dir to use "
192-
f'libraries in "{config.compiler_rt_libdir}"'
193-
)
194-
# Ensure that we use the just-built static libraries when linking by
195-
# overriding the Clang resource directory. Additionally, we want to use
196-
# the builtin headers shipped with clang (e.g. stdint.h), so we
197-
# explicitly add this as an include path (since the headers are not
198-
# going to be in the current compiler-rt build directory).
199-
# We also tell the linker to add an RPATH entry for the local library
200-
# directory so that the just-built shared libraries are used.
201-
config.target_cflags += f" -nobuiltininc"
202-
config.target_cflags += f" -I{config.compiler_rt_src_root}/include"
203-
config.target_cflags += f" -idirafter {test_cc_resource_dir}/include"
204-
config.target_cflags += f" -resource-dir={config.compiler_rt_output_dir}"
205-
config.target_cflags += f" -Wl,-rpath,{config.compiler_rt_libdir}"
206-
else:
207-
lit_config.warning(
208-
f"Cannot override compiler-rt library directory with non-Clang "
209-
f"compiler: {config.compiler_id}"
210-
)
211-
212-
213171
# Ask the compiler for the path to libraries it is going to use. If this
214172
# doesn't match config.compiler_rt_libdir then it means we might be testing the
215173
# compiler's own runtime libraries rather than the ones we just built.
216-
# Warn about this and handle appropriately.
174+
# Warn about about this and handle appropriately.
217175
compiler_libdir = find_compiler_libdir()
218176
if compiler_libdir:
219177
compiler_rt_libdir_real = os.path.realpath(config.compiler_rt_libdir)
@@ -224,7 +182,7 @@ def push_dynamic_library_lookup_path(config, new_path):
224182
f'compiler-rt libdir: "{compiler_rt_libdir_real}"'
225183
)
226184
if config.test_standalone_build_libs:
227-
# Use just built runtime libraries, i.e. the libraries this build just built.
185+
# Use just built runtime libraries, i.e. the the libraries this built just built.
228186
if not config.test_suite_supports_overriding_runtime_lib_path:
229187
# Test suite doesn't support this configuration.
230188
# TODO(dliew): This should be an error but it seems several bots are

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ set_default("compiler_id", "@COMPILER_RT_TEST_COMPILER_ID@")
2727
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@)
30-
set_default("compiler_rt_output_dir", "@COMPILER_RT_RESOLVED_OUTPUT_DIR@")
3130
set_default("compiler_rt_libdir", "@COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR@")
3231
set_default("emulator", "@COMPILER_RT_EMULATOR@")
3332
set_default("asan_shadow_scale", "@COMPILER_RT_ASAN_SHADOW_SCALE@")

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,10 @@
1313

1414
# Add clang substitutions.
1515
config.substitutions.append(
16-
(
17-
"%clang_nosafestack ",
18-
config.clang + config.target_cflags + " -O0 -fno-sanitize=safe-stack ",
19-
)
16+
("%clang_nosafestack ", config.clang + " -O0 -fno-sanitize=safe-stack ")
2017
)
2118
config.substitutions.append(
22-
(
23-
"%clang_safestack ",
24-
config.clang + config.target_cflags + " -O0 -fsanitize=safe-stack ",
25-
)
19+
("%clang_safestack ", config.clang + " -O0 -fsanitize=safe-stack ")
2620
)
2721

2822
if config.lto_supported:

0 commit comments

Comments
 (0)