[clang] 34b0a6e - [clang-repl] Avoid use `$LD_LIBRARY_PATH` in lit tests (#208170)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 8 20:13:19 PDT 2026
Author: Yihan Wang
Date: 2026-07-09T11:13:15+08:00
New Revision: 34b0a6e6d863a6f91698b435c72e69fcfebf13f2
URL: https://github.com/llvm/llvm-project/commit/34b0a6e6d863a6f91698b435c72e69fcfebf13f2
DIFF: https://github.com/llvm/llvm-project/commit/34b0a6e6d863a6f91698b435c72e69fcfebf13f2.diff
LOG: [clang-repl] Avoid use `$LD_LIBRARY_PATH` in lit tests (#208170)
Strengthen clang-repl lit tests by Avoid use `$LD_LIBRARY_PATH`. The
lit's internal shell does not expand shell variables such as
`$LD_LIBRARY_PATH`, so provide the current value as a lit substitution.
This PR can fix the following failures when user build llvm with
non-system C++ standard library.
```
# executed command: env 'LD_LIBRARY_PATH=<build dir>/tools/clang/test/Interpreter/Output/cxx20-modules.cppm.tmp:$LD_LIBRARY_PATH' <build dir>/bin/clang-repl -Xcc=-std=c++20 -Xcc=-fmodule-file=M=<build dir>/tools/clang/test/Interpreter/Output/cxx20-modules.cppm.tmp/mod.pcm -Xcc=--target=x86_64-linux-gnu
# .---command stderr------------
# | <build dir>/bin/clang-repl: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by <build dir>/bin/clang-repl)
# | <build dir>/bin/clang-repl: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by <build dir>/bin/clang-repl)
# | <build dir>/bin/clang-repl: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by <build dir>/bin/clang-repl)
# | <build dir>/bin/clang-repl: /lib64/libstdc++.so.6: version `CXXABI_1.3.13' not found (required by <build dir>/bin/clang-repl)
# `-----------------------------
```
Signed-off-by: yronglin <yronglin777 at gmail.com>
Added:
Modified:
clang/test/Interpreter/cxx20-modules.cppm
clang/test/Interpreter/dynamic-library.cpp
clang/test/Interpreter/lit.local.cfg
Removed:
################################################################################
diff --git a/clang/test/Interpreter/cxx20-modules.cppm b/clang/test/Interpreter/cxx20-modules.cppm
index 97744e3b25f77..aa52dabce89b6 100644
--- a/clang/test/Interpreter/cxx20-modules.cppm
+++ b/clang/test/Interpreter/cxx20-modules.cppm
@@ -9,7 +9,7 @@
// RUN: %clang -fPIC %t/mod.pcm -c -o %t/mod.o --target=x86_64-linux-gnu
// RUN: %clang -nostdlib -fPIC -shared %t/mod.o -o %t/libmod.so --target=x86_64-linux-gnu
//
-// RUN: cat %t/import.cpp | env LD_LIBRARY_PATH=%t:$LD_LIBRARY_PATH \
+// RUN: cat %t/import.cpp | env LD_LIBRARY_PATH=%t:%ld_library_path \
// RUN: clang-repl -Xcc=-std=c++20 -Xcc=-fmodule-file=M=%t/mod.pcm \
// RUN: -Xcc=--target=x86_64-linux-gnu | FileCheck %t/import.cpp
diff --git a/clang/test/Interpreter/dynamic-library.cpp b/clang/test/Interpreter/dynamic-library.cpp
index 6c4621f729c1c..08206058cdbdf 100644
--- a/clang/test/Interpreter/dynamic-library.cpp
+++ b/clang/test/Interpreter/dynamic-library.cpp
@@ -14,7 +14,7 @@
//
// }
-// RUN: cat %s | env LD_LIBRARY_PATH=%S/Inputs:$LD_LIBRARY_PATH clang-repl | FileCheck %s
+// RUN: cat %s | env LD_LIBRARY_PATH=%S/Inputs:%ld_library_path clang-repl | FileCheck %s
extern "C" int printf(const char* format, ...);
diff --git a/clang/test/Interpreter/lit.local.cfg b/clang/test/Interpreter/lit.local.cfg
index 37af5129d4eee..fa4e608deb6e3 100644
--- a/clang/test/Interpreter/lit.local.cfg
+++ b/clang/test/Interpreter/lit.local.cfg
@@ -4,3 +4,11 @@ unsupported_platforms = [ "system-aix", "system-zos" ]
if "host-supports-jit" not in config.available_features or \
any(up in config.available_features for up in unsupported_platforms):
config.unsupported = True
+
+# lit's internal shell does not expand shell variables such as
+# $LD_LIBRARY_PATH, so provide the current value as a lit substitution.
+#
+# This lets tests prepend to LD_LIBRARY_PATH while preserving the entries
+# that lit already set up.
+config.substitutions.append(
+ ('%ld_library_path', config.environment.get('LD_LIBRARY_PATH', '')))
More information about the cfe-commits
mailing list