[compiler-rt] [compiler-rt] Only query llvm-config in the orc tests (PR #83705)
Alexander Richardson via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 2 19:39:01 PST 2024
https://github.com/arichardson created https://github.com/llvm/llvm-project/pull/83705
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.
>From 12e157815b5e12b172c523c22fd370eb78151dde Mon Sep 17 00:00:00 2001
From: Alex Richardson <alexrichardson at google.com>
Date: Sat, 2 Mar 2024 19:38:46 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
---
compiler-rt/test/lit.common.cfg.py | 16 ----------------
compiler-rt/test/orc/lit.cfg.py | 12 ++++++++++++
2 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py
index 113777b0ea8a19..ae28681915afb3 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -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":
diff --git a/compiler-rt/test/orc/lit.cfg.py b/compiler-rt/test/orc/lit.cfg.py
index bd031d79826d3a..897cefb3d1930d 100644
--- a/compiler-rt/test/orc/lit.cfg.py
+++ b/compiler-rt/test/orc/lit.cfg.py
@@ -1,6 +1,7 @@
# -*- Python -*-
import os
+import subprocess
# Setup config name.
config.name = "ORC" + config.name_suffix
@@ -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}")
More information about the llvm-commits
mailing list