Skip to content

Commit 2e25926

Browse files
authored
[compiler-rt] Only query llvm-config in the orc tests
This check for assertions is only used inside the test/orc directory, but doing it in the top level lit config means all testsuites depend on llvm-config being present. This is not necessarily needed e.g. when testing just the builtins. While touching this code, simplify it a bit by using subprocess.check_output() instead of Popen() and use a string comparison instead of a regex match. Reviewed By: lhames Pull Request: llvm#83705
1 parent 95bde4b commit 2e25926

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

Diff for: compiler-rt/test/lit.common.cfg.py

-16
Original file line numberDiff line numberDiff line change
@@ -738,22 +738,6 @@ def is_windows_lto_supported():
738738
if config.have_rpc_xdr_h:
739739
config.available_features.add("sunrpc")
740740

741-
# Ask llvm-config about assertion mode.
742-
try:
743-
llvm_config_cmd = subprocess.Popen(
744-
[os.path.join(config.llvm_tools_dir, "llvm-config"), "--assertion-mode"],
745-
stdout=subprocess.PIPE,
746-
env=config.environment,
747-
)
748-
except OSError as e:
749-
print("Could not launch llvm-config in " + config.llvm_tools_dir)
750-
print(" Failed with error #{0}: {1}".format(e.errno, e.strerror))
751-
exit(42)
752-
753-
if re.search(r"ON", llvm_config_cmd.stdout.read().decode("ascii")):
754-
config.available_features.add("asserts")
755-
llvm_config_cmd.wait()
756-
757741
# Sanitizer tests tend to be flaky on Windows due to PR24554, so add some
758742
# retries. We don't do this on otther platforms because it's slower.
759743
if platform.system() == "Windows":

Diff for: compiler-rt/test/orc/lit.cfg.py

+12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- Python -*-
22

33
import os
4+
import subprocess
45

56
# Setup config name.
67
config.name = "ORC" + config.name_suffix
@@ -79,3 +80,14 @@ def build_invocation(compile_flags):
7980

8081
if config.host_os not in ["Darwin", "FreeBSD", "Linux", "Windows"]:
8182
config.unsupported = True
83+
84+
# Ask llvm-config about assertion mode.
85+
try:
86+
llvm_config_result = subprocess.check_output(
87+
[os.path.join(config.llvm_tools_dir, "llvm-config"), "--assertion-mode"],
88+
env=config.environment,
89+
)
90+
if llvm_config_result.startswith(b"ON"):
91+
config.available_features.add("asserts")
92+
except OSError as e:
93+
lit_config.warning(f"Could not determine if LLVM was built with assertions: {e}")

0 commit comments

Comments
 (0)