[compiler-rt] [compiler-rt] Avoid assertions when using LLVM_ENABLE_PER_TARGET_RUNTIME_DIR (PR #90127)

Paul Kirth via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 25 14:57:17 PDT 2024


https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/90127

>From 691065211e8cdda69572354bd591c1163e063e0b Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Thu, 25 Apr 2024 14:29:28 -0700
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 .../test/ctx_profile/Unit/lit.site.cfg.py.in        | 12 ++++++++----
 compiler-rt/test/memprof/Unit/lit.site.cfg.py.in    | 13 ++++++++-----
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/compiler-rt/test/ctx_profile/Unit/lit.site.cfg.py.in b/compiler-rt/test/ctx_profile/Unit/lit.site.cfg.py.in
index 32a8c48e9c1c79..bf586bfab55237 100644
--- a/compiler-rt/test/ctx_profile/Unit/lit.site.cfg.py.in
+++ b/compiler-rt/test/ctx_profile/Unit/lit.site.cfg.py.in
@@ -21,7 +21,11 @@ config.test_source_root = config.test_exec_root
 # When LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on, the initial value of
 # config.compiler_rt_libdir (COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR) has the
 # host triple as the trailing path component. The value is incorrect for i386
-# tests on x86_64 hosts and vice versa. But, since only x86_64 is enabled as
-# target, and we don't support different environments for building and,
-# respectivelly, running tests, we shouldn't see this case.
-assert not config.enable_per_target_runtime_dir or config.target_arch == config.host_arch
+# tests on x86_64 hosts and vice versa. Adjust config.compiler_rt_libdir
+# accordingly.
+if config.enable_per_target_runtime_dir and config.target_arch != config.host_arch:
+    if config.target_arch == 'i386':
+        config.compiler_rt_libdir = re.sub(r'/x86_64(?=-[^/]+$)', '/i386', config.compiler_rt_libdir)
+    elif config.target_arch == 'x86_64':
+        config.compiler_rt_libdir = re.sub(r'/i386(?=-[^/]+$)', '/x86_64', config.compiler_rt_libdir)
+
diff --git a/compiler-rt/test/memprof/Unit/lit.site.cfg.py.in b/compiler-rt/test/memprof/Unit/lit.site.cfg.py.in
index c968e403a44d09..b9485024fa5082 100644
--- a/compiler-rt/test/memprof/Unit/lit.site.cfg.py.in
+++ b/compiler-rt/test/memprof/Unit/lit.site.cfg.py.in
@@ -21,10 +21,13 @@ config.test_source_root = config.test_exec_root
 # When LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on, the initial value of
 # config.compiler_rt_libdir (COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR) has the
 # host triple as the trailing path component. The value is incorrect for i386
-# tests on x86_64 hosts and vice versa.  But, since only x86_64 is enabled as
-# target, and we don't support different environments for building and,
-# respectivelly, running tests, we shouldn't see this case.
-assert not config.enable_per_target_runtime_dir or config.target_arch == config.host_arch
+# tests on x86_64 hosts and vice versa. Adjust config.compiler_rt_libdir
+# accordingly.
+if config.enable_per_target_runtime_dir and config.target_arch != config.host_arch:
+    if config.target_arch == 'i386':
+        config.compiler_rt_libdir = re.sub(r'/x86_64(?=-[^/]+$)', '/i386', config.compiler_rt_libdir)
+    elif config.target_arch == 'x86_64':
+        config.compiler_rt_libdir = re.sub(r'/i386(?=-[^/]+$)', '/x86_64', config.compiler_rt_libdir)
 
 if not config.parallelism_group:
-  config.parallelism_group = 'shadow-memory'
\ No newline at end of file
+  config.parallelism_group = 'shadow-memory'

>From e4b8638a33c9317bab1b70dce54e25044fea461c Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Thu, 25 Apr 2024 14:57:03 -0700
Subject: [PATCH 2/2] Simplify checking since 32-bit is unsupported

Created using spr 1.3.4
---
 compiler-rt/test/ctx_profile/Unit/lit.site.cfg.py.in | 9 ++-------
 compiler-rt/test/memprof/Unit/lit.site.cfg.py.in     | 8 ++------
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/compiler-rt/test/ctx_profile/Unit/lit.site.cfg.py.in b/compiler-rt/test/ctx_profile/Unit/lit.site.cfg.py.in
index bf586bfab55237..28c9942bf43736 100644
--- a/compiler-rt/test/ctx_profile/Unit/lit.site.cfg.py.in
+++ b/compiler-rt/test/ctx_profile/Unit/lit.site.cfg.py.in
@@ -20,12 +20,7 @@ config.test_source_root = config.test_exec_root
 
 # When LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on, the initial value of
 # config.compiler_rt_libdir (COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR) has the
-# host triple as the trailing path component. The value is incorrect for i386
-# tests on x86_64 hosts and vice versa. Adjust config.compiler_rt_libdir
+# host triple as the trailing path component. Adjust config.compiler_rt_libdir
 # accordingly.
 if config.enable_per_target_runtime_dir and config.target_arch != config.host_arch:
-    if config.target_arch == 'i386':
-        config.compiler_rt_libdir = re.sub(r'/x86_64(?=-[^/]+$)', '/i386', config.compiler_rt_libdir)
-    elif config.target_arch == 'x86_64':
-        config.compiler_rt_libdir = re.sub(r'/i386(?=-[^/]+$)', '/x86_64', config.compiler_rt_libdir)
-
+    config.compiler_rt_libdir = re.sub(r'/i386(?=-[^/]+$)', '/x86_64', config.compiler_rt_libdir)
diff --git a/compiler-rt/test/memprof/Unit/lit.site.cfg.py.in b/compiler-rt/test/memprof/Unit/lit.site.cfg.py.in
index b9485024fa5082..2f5479b7d1b91f 100644
--- a/compiler-rt/test/memprof/Unit/lit.site.cfg.py.in
+++ b/compiler-rt/test/memprof/Unit/lit.site.cfg.py.in
@@ -20,14 +20,10 @@ config.test_source_root = config.test_exec_root
 
 # When LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on, the initial value of
 # config.compiler_rt_libdir (COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR) has the
-# host triple as the trailing path component. The value is incorrect for i386
-# tests on x86_64 hosts and vice versa. Adjust config.compiler_rt_libdir
+# host triple as the trailing path component. Adjust config.compiler_rt_libdir
 # accordingly.
 if config.enable_per_target_runtime_dir and config.target_arch != config.host_arch:
-    if config.target_arch == 'i386':
-        config.compiler_rt_libdir = re.sub(r'/x86_64(?=-[^/]+$)', '/i386', config.compiler_rt_libdir)
-    elif config.target_arch == 'x86_64':
-        config.compiler_rt_libdir = re.sub(r'/i386(?=-[^/]+$)', '/x86_64', config.compiler_rt_libdir)
+    config.compiler_rt_libdir = re.sub(r'/i386(?=-[^/]+$)', '/x86_64', config.compiler_rt_libdir)
 
 if not config.parallelism_group:
   config.parallelism_group = 'shadow-memory'



More information about the llvm-commits mailing list