Skip to content

Commit

Permalink
[compiler-rt] Only query llvm-config in the orc tests
Browse files Browse the repository at this point in the history
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: #83705
  • Loading branch information
arichardson committed Mar 7, 2024
1 parent 95bde4b commit 2e25926
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
16 changes: 0 additions & 16 deletions compiler-rt/test/lit.common.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,22 +738,6 @@ def is_windows_lto_supported():
if config.have_rpc_xdr_h:
config.available_features.add("sunrpc")

# Ask llvm-config about assertion mode.
try:
llvm_config_cmd = subprocess.Popen(
[os.path.join(config.llvm_tools_dir, "llvm-config"), "--assertion-mode"],
stdout=subprocess.PIPE,
env=config.environment,
)
except OSError as e:
print("Could not launch llvm-config in " + config.llvm_tools_dir)
print(" Failed with error #{0}: {1}".format(e.errno, e.strerror))
exit(42)

if re.search(r"ON", llvm_config_cmd.stdout.read().decode("ascii")):
config.available_features.add("asserts")
llvm_config_cmd.wait()

# Sanitizer tests tend to be flaky on Windows due to PR24554, so add some
# retries. We don't do this on otther platforms because it's slower.
if platform.system() == "Windows":
Expand Down
12 changes: 12 additions & 0 deletions compiler-rt/test/orc/lit.cfg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- Python -*-

import os
import subprocess

# Setup config name.
config.name = "ORC" + config.name_suffix
Expand Down Expand Up @@ -79,3 +80,14 @@ def build_invocation(compile_flags):

if config.host_os not in ["Darwin", "FreeBSD", "Linux", "Windows"]:
config.unsupported = True

# Ask llvm-config about assertion mode.
try:
llvm_config_result = subprocess.check_output(
[os.path.join(config.llvm_tools_dir, "llvm-config"), "--assertion-mode"],
env=config.environment,
)
if llvm_config_result.startswith(b"ON"):
config.available_features.add("asserts")
except OSError as e:
lit_config.warning(f"Could not determine if LLVM was built with assertions: {e}")

0 comments on commit 2e25926

Please sign in to comment.