[compiler-rt] f8a2ed7 - [ubsan_minimal] Introduce custom substitutions for clang with minimal runtime (#151613)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 31 18:10:58 PDT 2025
Author: Andrew Lazarev
Date: 2025-07-31T18:10:55-07:00
New Revision: f8a2ed7aaccd60ed8939dfeb32fc38e05ebeda25
URL: https://github.com/llvm/llvm-project/commit/f8a2ed7aaccd60ed8939dfeb32fc38e05ebeda25
DIFF: https://github.com/llvm/llvm-project/commit/f8a2ed7aaccd60ed8939dfeb32fc38e05ebeda25.diff
LOG: [ubsan_minimal] Introduce custom substitutions for clang with minimal runtime (#151613)
Make clang calls using custom suffix to allow correct calls without
reading cfg.py. As I see tests for other other specific checks are doing
it too (e.g. %clangxx_asan).
Added:
Modified:
compiler-rt/test/ubsan_minimal/TestCases/alignment-assumption.c
compiler-rt/test/ubsan_minimal/TestCases/icall.c
compiler-rt/test/ubsan_minimal/TestCases/implicit-integer-sign-change.c
compiler-rt/test/ubsan_minimal/TestCases/implicit-signed-integer-truncation-or-sign-change.c
compiler-rt/test/ubsan_minimal/TestCases/implicit-signed-integer-truncation.c
compiler-rt/test/ubsan_minimal/TestCases/implicit-unsigned-integer-truncation.c
compiler-rt/test/ubsan_minimal/TestCases/local_bounds.cpp
compiler-rt/test/ubsan_minimal/TestCases/nullptr-and-nonzero-offset.c
compiler-rt/test/ubsan_minimal/TestCases/override-callback.c
compiler-rt/test/ubsan_minimal/TestCases/recover-dedup-limit.cpp
compiler-rt/test/ubsan_minimal/TestCases/recover-dedup.cpp
compiler-rt/test/ubsan_minimal/TestCases/test-darwin-interface.c
compiler-rt/test/ubsan_minimal/TestCases/uadd-overflow.cpp
compiler-rt/test/ubsan_minimal/lit.common.cfg.py
Removed:
################################################################################
diff --git a/compiler-rt/test/ubsan_minimal/TestCases/alignment-assumption.c b/compiler-rt/test/ubsan_minimal/TestCases/alignment-assumption.c
index acc3e855faebe..134c143b867bd 100644
--- a/compiler-rt/test/ubsan_minimal/TestCases/alignment-assumption.c
+++ b/compiler-rt/test/ubsan_minimal/TestCases/alignment-assumption.c
@@ -1,4 +1,4 @@
-// RUN: %clang -fsanitize=alignment %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_min_runtime -fsanitize=alignment %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
#include <stdlib.h>
diff --git a/compiler-rt/test/ubsan_minimal/TestCases/icall.c b/compiler-rt/test/ubsan_minimal/TestCases/icall.c
index 6948057663a20..a0953b8cd5d74 100644
--- a/compiler-rt/test/ubsan_minimal/TestCases/icall.c
+++ b/compiler-rt/test/ubsan_minimal/TestCases/icall.c
@@ -1,5 +1,5 @@
-// RUN: %clang -fsanitize=cfi-icall -fno-sanitize-trap=cfi-icall -fuse-ld=lld -flto -fvisibility=hidden %s -o %t && not --crash %run %t 2>&1 | FileCheck %s
-// RUN: %clang -fsanitize=cfi-icall -fno-sanitize-trap=cfi-icall -fsanitize-recover=cfi-icall -fuse-ld=lld -flto -fvisibility=hidden %s -o %t && %run %t 2>&1 | FileCheck %s
+// RUN: %clang_min_runtime -fsanitize=cfi-icall -fno-sanitize-trap=cfi-icall -fuse-ld=lld -flto -fvisibility=hidden %s -o %t && not --crash %run %t 2>&1 | FileCheck %s
+// RUN: %clang_min_runtime -fsanitize=cfi-icall -fno-sanitize-trap=cfi-icall -fsanitize-recover=cfi-icall -fuse-ld=lld -flto -fvisibility=hidden %s -o %t && %run %t 2>&1 | FileCheck %s
// REQUIRES: lld-available, cfi
diff --git a/compiler-rt/test/ubsan_minimal/TestCases/implicit-integer-sign-change.c b/compiler-rt/test/ubsan_minimal/TestCases/implicit-integer-sign-change.c
index 0f1bbbf2e2146..1e3a14c87145c 100644
--- a/compiler-rt/test/ubsan_minimal/TestCases/implicit-integer-sign-change.c
+++ b/compiler-rt/test/ubsan_minimal/TestCases/implicit-integer-sign-change.c
@@ -1,4 +1,4 @@
-// RUN: %clang -fsanitize=implicit-integer-sign-change %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_min_runtime -fsanitize=implicit-integer-sign-change %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
#include <stdint.h>
diff --git a/compiler-rt/test/ubsan_minimal/TestCases/implicit-signed-integer-truncation-or-sign-change.c b/compiler-rt/test/ubsan_minimal/TestCases/implicit-signed-integer-truncation-or-sign-change.c
index e9f26dd7450cd..a05af6b9add6a 100644
--- a/compiler-rt/test/ubsan_minimal/TestCases/implicit-signed-integer-truncation-or-sign-change.c
+++ b/compiler-rt/test/ubsan_minimal/TestCases/implicit-signed-integer-truncation-or-sign-change.c
@@ -1,4 +1,4 @@
-// RUN: %clang -fsanitize=implicit-signed-integer-truncation,implicit-integer-sign-change %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_min_runtime -fsanitize=implicit-signed-integer-truncation,implicit-integer-sign-change %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
#include <stdint.h>
diff --git a/compiler-rt/test/ubsan_minimal/TestCases/implicit-signed-integer-truncation.c b/compiler-rt/test/ubsan_minimal/TestCases/implicit-signed-integer-truncation.c
index dc8d7756346da..945c033b9c408 100644
--- a/compiler-rt/test/ubsan_minimal/TestCases/implicit-signed-integer-truncation.c
+++ b/compiler-rt/test/ubsan_minimal/TestCases/implicit-signed-integer-truncation.c
@@ -1,4 +1,4 @@
-// RUN: %clang -fsanitize=implicit-signed-integer-truncation %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_min_runtime -fsanitize=implicit-signed-integer-truncation %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
#include <stdint.h>
diff --git a/compiler-rt/test/ubsan_minimal/TestCases/implicit-unsigned-integer-truncation.c b/compiler-rt/test/ubsan_minimal/TestCases/implicit-unsigned-integer-truncation.c
index 77d38f5637fd3..35515b706fa68 100644
--- a/compiler-rt/test/ubsan_minimal/TestCases/implicit-unsigned-integer-truncation.c
+++ b/compiler-rt/test/ubsan_minimal/TestCases/implicit-unsigned-integer-truncation.c
@@ -1,4 +1,4 @@
-// RUN: %clang -fsanitize=implicit-unsigned-integer-truncation %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_min_runtime -fsanitize=implicit-unsigned-integer-truncation %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
#include <stdint.h>
diff --git a/compiler-rt/test/ubsan_minimal/TestCases/local_bounds.cpp b/compiler-rt/test/ubsan_minimal/TestCases/local_bounds.cpp
index c972e1ecfc017..4b542fa639d42 100644
--- a/compiler-rt/test/ubsan_minimal/TestCases/local_bounds.cpp
+++ b/compiler-rt/test/ubsan_minimal/TestCases/local_bounds.cpp
@@ -1,7 +1,7 @@
-// RUN: %clangxx -fsanitize=local-bounds %s -O3 -o %t && %run %t 1
-// RUN: %clangxx -fsanitize=local-bounds %s -O3 -o %t && not --crash %run %t 3
-// RUN: %clangxx -fsanitize=local-bounds -fno-sanitize-trap=local-bounds %s -O3 -o %t && not --crash %run %t 3 2>&1 | FileCheck %s
-// RUN: %clangxx -fsanitize=local-bounds -fno-sanitize-trap=local-bounds -fsanitize-recover=local-bounds %s -O3 -o %t && %run %t 3 2>&1 | FileCheck %s
+// RUN: %clangxx_min_runtime -fsanitize=local-bounds %s -O3 -o %t && %run %t 1
+// RUN: %clangxx_min_runtime -fsanitize=local-bounds %s -O3 -o %t && not --crash %run %t 3
+// RUN: %clangxx_min_runtime -fsanitize=local-bounds -fno-sanitize-trap=local-bounds %s -O3 -o %t && not --crash %run %t 3 2>&1 | FileCheck %s
+// RUN: %clangxx_min_runtime -fsanitize=local-bounds -fno-sanitize-trap=local-bounds -fsanitize-recover=local-bounds %s -O3 -o %t && %run %t 3 2>&1 | FileCheck %s
#include <cstdlib>
diff --git a/compiler-rt/test/ubsan_minimal/TestCases/nullptr-and-nonzero-offset.c b/compiler-rt/test/ubsan_minimal/TestCases/nullptr-and-nonzero-offset.c
index bba9a38da0c73..7378a17f66fcf 100644
--- a/compiler-rt/test/ubsan_minimal/TestCases/nullptr-and-nonzero-offset.c
+++ b/compiler-rt/test/ubsan_minimal/TestCases/nullptr-and-nonzero-offset.c
@@ -1,5 +1,5 @@
-// RUN: %clang -fsanitize=pointer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="pointer-overflow"
-// RUN: %clangxx -x c++ -fsanitize=pointer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="pointer-overflow"
+// RUN: %clang_min_runtime -fsanitize=pointer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="pointer-overflow"
+// RUN: %clangxx_min_runtime -x c++ -fsanitize=pointer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="pointer-overflow"
#include <stdlib.h>
diff --git a/compiler-rt/test/ubsan_minimal/TestCases/override-callback.c b/compiler-rt/test/ubsan_minimal/TestCases/override-callback.c
index 9d326ff1cc54c..aaed134b3ae81 100644
--- a/compiler-rt/test/ubsan_minimal/TestCases/override-callback.c
+++ b/compiler-rt/test/ubsan_minimal/TestCases/override-callback.c
@@ -1,6 +1,6 @@
-// RUN: %clang -fsanitize=implicit-integer-sign-change %s -o %t && %run %t 2>&1 | FileCheck %s
-// RUN: %clang -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=all %s -o %t && not --crash %run %t 2>&1 | FileCheck %s
-// RUN: %clang -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=all -DOVERRIDE=1 %s -o %t && not --crash %run %t 2>&1 | FileCheck %s --check-prefixes=FATAL
+// RUN: %clang_min_runtime -fsanitize=implicit-integer-sign-change %s -o %t && %run %t 2>&1 | FileCheck %s
+// RUN: %clang_min_runtime -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=all %s -o %t && not --crash %run %t 2>&1 | FileCheck %s
+// RUN: %clang_min_runtime -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=all -DOVERRIDE=1 %s -o %t && not --crash %run %t 2>&1 | FileCheck %s --check-prefixes=FATAL
#include <stdint.h>
#include <stdio.h>
diff --git a/compiler-rt/test/ubsan_minimal/TestCases/recover-dedup-limit.cpp b/compiler-rt/test/ubsan_minimal/TestCases/recover-dedup-limit.cpp
index faa2b66ad80f9..ebc89015692ea 100644
--- a/compiler-rt/test/ubsan_minimal/TestCases/recover-dedup-limit.cpp
+++ b/compiler-rt/test/ubsan_minimal/TestCases/recover-dedup-limit.cpp
@@ -1,4 +1,4 @@
-// RUN: %clangxx -fsanitize=signed-integer-overflow -fsanitize-recover=all %s -o %t && %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_min_runtime -fsanitize=signed-integer-overflow -fsanitize-recover=all %s -o %t && %run %t 2>&1 | FileCheck %s
#include <stdint.h>
diff --git a/compiler-rt/test/ubsan_minimal/TestCases/recover-dedup.cpp b/compiler-rt/test/ubsan_minimal/TestCases/recover-dedup.cpp
index b7c9ddc3e5cfb..0b54579ece9a9 100644
--- a/compiler-rt/test/ubsan_minimal/TestCases/recover-dedup.cpp
+++ b/compiler-rt/test/ubsan_minimal/TestCases/recover-dedup.cpp
@@ -1,4 +1,4 @@
-// RUN: %clangxx -w -fsanitize=signed-integer-overflow,nullability-return,returns-nonnull-attribute -fsanitize-recover=all %s -o %t && %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_min_runtime -w -fsanitize=signed-integer-overflow,nullability-return,returns-nonnull-attribute -fsanitize-recover=all %s -o %t && %run %t 2>&1 | FileCheck %s
#include <stdint.h>
#include <stdio.h>
diff --git a/compiler-rt/test/ubsan_minimal/TestCases/test-darwin-interface.c b/compiler-rt/test/ubsan_minimal/TestCases/test-darwin-interface.c
index 1da049f9a35c3..abc1073e02073 100644
--- a/compiler-rt/test/ubsan_minimal/TestCases/test-darwin-interface.c
+++ b/compiler-rt/test/ubsan_minimal/TestCases/test-darwin-interface.c
@@ -3,11 +3,11 @@
//
// REQUIRES: x86_64-darwin
-// RUN: nm -jgU `%clangxx -fsanitize-minimal-runtime -fsanitize=undefined %s -o %t '-###' 2>&1 | grep "libclang_rt.ubsan_minimal_osx_dynamic.dylib" | sed -e 's/.*"\(.*libclang_rt.ubsan_minimal_osx_dynamic.dylib\)".*/\1/'` | grep "^___ubsan_handle" \
+// RUN: nm -jgU `%clangxx_min_runtime -fsanitize-minimal-runtime -fsanitize=undefined %s -o %t '-###' 2>&1 | grep "libclang_rt.ubsan_minimal_osx_dynamic.dylib" | sed -e 's/.*"\(.*libclang_rt.ubsan_minimal_osx_dynamic.dylib\)".*/\1/'` | grep "^___ubsan_handle" \
// RUN: | sed 's/_minimal//g' \
// RUN: > %t.minimal.symlist
//
-// RUN: nm -jgU `%clangxx -fno-sanitize-minimal-runtime -fsanitize=undefined %s -o %t '-###' 2>&1 | grep "libclang_rt.ubsan_osx_dynamic.dylib" | sed -e 's/.*"\(.*libclang_rt.ubsan_osx_dynamic.dylib\)".*/\1/'` | grep "^___ubsan_handle" \
+// RUN: nm -jgU `%clangxx_min_runtime -fno-sanitize-minimal-runtime -fsanitize=undefined %s -o %t '-###' 2>&1 | grep "libclang_rt.ubsan_osx_dynamic.dylib" | sed -e 's/.*"\(.*libclang_rt.ubsan_osx_dynamic.dylib\)".*/\1/'` | grep "^___ubsan_handle" \
// RUN: | grep -vE "^___ubsan_handle_dynamic_type_cache_miss" \
// RUN: | grep -vE "^___ubsan_handle_cfi_bad_type" \
// RUN: | sed 's/_v1//g' \
diff --git a/compiler-rt/test/ubsan_minimal/TestCases/uadd-overflow.cpp b/compiler-rt/test/ubsan_minimal/TestCases/uadd-overflow.cpp
index 4ae081c653ec8..e1f04d36972fc 100644
--- a/compiler-rt/test/ubsan_minimal/TestCases/uadd-overflow.cpp
+++ b/compiler-rt/test/ubsan_minimal/TestCases/uadd-overflow.cpp
@@ -1,5 +1,5 @@
-// RUN: %clangxx -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx -fsanitize=unsigned-integer-overflow -fno-sanitize-recover=all %s -o %t && not --crash %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_min_runtime -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_min_runtime -fsanitize=unsigned-integer-overflow -fno-sanitize-recover=all %s -o %t && not --crash %run %t 2>&1 | FileCheck %s
#include <stdint.h>
diff --git a/compiler-rt/test/ubsan_minimal/lit.common.cfg.py b/compiler-rt/test/ubsan_minimal/lit.common.cfg.py
index bcc0e46fbef91..33473e27ba063 100644
--- a/compiler-rt/test/ubsan_minimal/lit.common.cfg.py
+++ b/compiler-rt/test/ubsan_minimal/lit.common.cfg.py
@@ -27,9 +27,13 @@ def build_invocation(compile_flags):
clang_ubsan_cflags = ["-fsanitize-minimal-runtime"] + target_cflags
clang_ubsan_cxxflags = config.cxx_mode_flags + clang_ubsan_cflags
-# Define %clang and %clangxx substitutions to use in test RUN lines.
-config.substitutions.append(("%clang ", build_invocation(clang_ubsan_cflags)))
-config.substitutions.append(("%clangxx ", build_invocation(clang_ubsan_cxxflags)))
+# Define %clang_min_runtime and %clangxx_min_runtime substitutions to use in test RUN lines.
+config.substitutions.append(
+ ("%clang_min_runtime ", build_invocation(clang_ubsan_cflags))
+)
+config.substitutions.append(
+ ("%clangxx_min_runtime ", build_invocation(clang_ubsan_cxxflags))
+)
# Default test suffixes.
config.suffixes = [".c", ".cpp"]
More information about the llvm-commits
mailing list