Skip to content

Commit 10c187d

Browse files
rnkjyli0116
authored andcommitted
[clang] Split out and disable tests that break relative rpaths (llvm#137411)
These two tests copy the clang binary into the test tree and assume it will run from a new location. This is incompatible with relative rpath values, which is what you typically get in a dylib developer build. Disable these tests if shared libraries are involved. Another way to make these tests work would be to update the loader search path environment variables, but it is difficult to do that portably.
1 parent 94dad1f commit 10c187d

File tree

7 files changed

+95
-70
lines changed

7 files changed

+95
-70
lines changed

clang/test/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# for use by Lit, and delegates to LLVM's lit test handlers.
33

44
llvm_canonicalize_cmake_booleans(
5+
BUILD_SHARED_LIBS
56
CLANG_BUILD_EXAMPLES
67
CLANG_BUILT_STANDALONE
78
CLANG_DEFAULT_PIE_ON_LINUX
@@ -10,6 +11,7 @@ llvm_canonicalize_cmake_booleans(
1011
CLANG_SPAWN_CC1
1112
CLANG_ENABLE_CIR
1213
CLANG_ENABLE_OBJC_REWRITER
14+
CLANG_LINK_CLANG_DYLIB
1315
ENABLE_BACKTRACES
1416
LLVM_BUILD_EXAMPLES
1517
LLVM_BYE_LINK_INTO_TOOLS
@@ -19,6 +21,7 @@ llvm_canonicalize_cmake_booleans(
1921
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
2022
LLVM_ENABLE_THREADS
2123
LLVM_ENABLE_REVERSE_ITERATION
24+
LLVM_LINK_LLVM_DYLIB
2225
LLVM_WITH_Z3
2326
PPC_LINUX_DEFAULT_IEEELONGDOUBLE
2427
LLVM_TOOL_LLVM_DRIVER_BUILD

clang/test/Driver/clang_f_opts.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -542,19 +542,6 @@
542542
// CHECK-RECORD-GCC-SWITCHES: "-record-command-line"
543543
// CHECK-NO-RECORD-GCC-SWITCHES-NOT: "-record-command-line"
544544
// CHECK-RECORD-GCC-SWITCHES-ERROR: error: unsupported option '-frecord-command-line' for target
545-
// Test when clang is in a path containing a space.
546-
// The initial `rm` is a workaround for https://openradar.appspot.com/FB8914243
547-
// (Scenario: Run tests once, `clang` gets copied and run at new location and signature
548-
// is cached at the new clang's inode, then clang is changed, tests run again, old signature
549-
// is still cached with old clang's inode, so it won't execute this time. Removing the dir
550-
// first guarantees a new inode without old cache entries.)
551-
// RUN: rm -rf "%t.r/with spaces"
552-
// RUN: mkdir -p "%t.r/with spaces"
553-
// RUN: cp %clang "%t.r/with spaces/clang"
554-
// RUN: "%t.r/with spaces/clang" -### -S --target=x86_64-unknown-linux -frecord-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES-ESCAPED %s
555-
// CHECK-RECORD-GCC-SWITCHES-ESCAPED: "-record-command-line" "{{.+}}with\\ spaces{{.+}}"
556-
// Clean up copy of large binary copied into temp directory to avoid bloat.
557-
// RUN: rm -f "%t.r/with spaces/clang" || true
558545

559546
// RUN: %clang -### -S -ftrivial-auto-var-init=uninitialized %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-UNINIT %s
560547
// RUN: %clang -### -S -ftrivial-auto-var-init=pattern %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-PATTERN %s
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// UNSUPPORTED: target={{.*}}-aix{{.*}}
2+
3+
// Copying clang to a new location and running it will not work unless it is
4+
// statically linked. Dynamically linked builds typically use relative rpaths,
5+
// which this will break.
6+
// REQUIRES: static-libs
7+
8+
// Test when clang is in a path containing a space.
9+
// The initial `rm` is a workaround for https://openradar.appspot.com/FB8914243
10+
// (Scenario: Run tests once, `clang` gets copied and run at new location and signature
11+
// is cached at the new clang's inode, then clang is changed, tests run again, old signature
12+
// is still cached with old clang's inode, so it won't execute this time. Removing the dir
13+
// first guarantees a new inode without old cache entries.)
14+
// RUN: rm -rf "%t.r/with spaces"
15+
// RUN: mkdir -p "%t.r/with spaces"
16+
// RUN: cp %clang "%t.r/with spaces/clang"
17+
// RUN: "%t.r/with spaces/clang" -### -S --target=x86_64-unknown-linux -frecord-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES-ESCAPED %s
18+
// CHECK-RECORD-GCC-SWITCHES-ESCAPED: "-record-command-line" "{{.+}}with\\ spaces{{.+}}"
19+
// Clean up copy of large binary copied into temp directory to avoid bloat.
20+
// RUN: rm -f "%t.r/with spaces/clang" || true
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// General tests that the header search paths for libc++ detected by the driver
2+
// and passed to CC1 are correct on Darwin platforms. This test copies the clang
3+
// binary, which won't work if it uses any dynamic libraries (BUILD_SHARED_LIBS,
4+
// LLVM_LINK_LLVM_DYLIB, or CLANG_LINK_CLANG_DYLIB).
5+
6+
// UNSUPPORTED: system-windows
7+
// REQUIRES: static-libs
8+
9+
// ----------------------------------------------------------------------------
10+
// On Darwin, libc++ can be installed in one of the following places:
11+
// 1. Alongside the compiler in <install>/include/c++/v1
12+
// 2. Alongside the compiler in <clang-executable-folder>/../include/c++/v1
13+
// 3. In a SDK (or a custom sysroot) in <sysroot>/usr/include/c++/v1
14+
15+
// The build folders do not have an `include/c++/v1`; create a new
16+
// local folder hierarchy that meets this requirement.
17+
// Note: this might not work with weird RPATH configurations.
18+
// RUN: rm -rf %t/install
19+
// RUN: mkdir -p %t/install/bin
20+
// RUN: cp %clang %t/install/bin/clang
21+
// RUN: mkdir -p %t/install/include/c++/v1
22+
23+
// Headers in (1) and in (2) -> (1) is preferred over (2)
24+
// RUN: rm -rf %t/symlinked1
25+
// RUN: mkdir -p %t/symlinked1/bin
26+
// RUN: ln -sf %t/install/bin/clang %t/symlinked1/bin/clang
27+
// RUN: mkdir -p %t/symlinked1/include/c++/v1
28+
29+
// RUN: %t/symlinked1/bin/clang -### %s -no-canonical-prefixes -fsyntax-only 2>&1 \
30+
// RUN: --target=x86_64-apple-darwin \
31+
// RUN: -stdlib=libc++ \
32+
// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
33+
// RUN: | FileCheck -DSYMLINKED=%t/symlinked1 \
34+
// RUN: -DTOOLCHAIN=%t/install \
35+
// RUN: -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
36+
// RUN: --check-prefix=CHECK-SYMLINKED-INCLUDE-CXX-V1 %s
37+
// CHECK-SYMLINKED-INCLUDE-CXX-V1: "-internal-isystem" "[[SYMLINKED]]/bin/../include/c++/v1"
38+
// CHECK-SYMLINKED-INCLUDE-CXX-V1-NOT: "-internal-isystem" "[[TOOLCHAIN]]/bin/../include/c++/v1"
39+
// CHECK-SYMLINKED-INCLUDE-CXX-V1-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
40+
41+
// Headers in (2) and in (3) -> (2) is preferred over (3)
42+
// RUN: rm -rf %t/symlinked2
43+
// RUN: mkdir -p %t/symlinked2/bin
44+
// RUN: ln -sf %t/install/bin/clang %t/symlinked2/bin/clang
45+
46+
// RUN: %t/symlinked2/bin/clang -### %s -fsyntax-only 2>&1 \
47+
// RUN: --target=x86_64-apple-darwin \
48+
// RUN: -stdlib=libc++ \
49+
// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
50+
// RUN: | FileCheck -DTOOLCHAIN=%t/install \
51+
// RUN: -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
52+
// RUN: --check-prefix=CHECK-TOOLCHAIN-INCLUDE-CXX-V1 %s
53+
// CHECK-TOOLCHAIN-INCLUDE-CXX-V1: "-internal-isystem" "[[TOOLCHAIN]]/bin/../include/c++/v1"
54+
// CHECK-TOOLCHAIN-INCLUDE-CXX-V1-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
55+
56+
// Headers in (2) and nowhere else -> (2) is used
57+
// RUN: %t/symlinked2/bin/clang -### %s -fsyntax-only 2>&1 \
58+
// RUN: --target=x86_64-apple-darwin \
59+
// RUN: -stdlib=libc++ \
60+
// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
61+
// RUN: | FileCheck -DTOOLCHAIN=%t/install \
62+
// RUN: -DSYSROOT=%S/Inputs/basic_darwin_sdk_no_libcxx \
63+
// RUN: --check-prefix=CHECK-TOOLCHAIN-NO-SYSROOT %s
64+
// CHECK-TOOLCHAIN-NO-SYSROOT: "-internal-isystem" "[[TOOLCHAIN]]/bin/../include/c++/v1"

clang/test/Driver/darwin-header-search-libcxx.cpp

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -172,60 +172,3 @@
172172
// RUN: --check-prefix=CHECK-LIBCXX-STDLIB-UNSPECIFIED %s
173173
// CHECK-LIBCXX-STDLIB-UNSPECIFIED: "-cc1"
174174
// CHECK-LIBCXX-STDLIB-UNSPECIFIED: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
175-
176-
// ----------------------------------------------------------------------------
177-
// On Darwin, libc++ can be installed in one of the following places:
178-
// 1. Alongside the compiler in <install>/include/c++/v1
179-
// 2. Alongside the compiler in <clang-executable-folder>/../include/c++/v1
180-
// 3. In a SDK (or a custom sysroot) in <sysroot>/usr/include/c++/v1
181-
182-
// The build folders do not have an `include/c++/v1`; create a new
183-
// local folder hierarchy that meets this requirement.
184-
// Note: this might not work with weird RPATH configurations.
185-
// RUN: rm -rf %t/install
186-
// RUN: mkdir -p %t/install/bin
187-
// RUN: cp %clang %t/install/bin/clang
188-
// RUN: mkdir -p %t/install/include/c++/v1
189-
190-
// Headers in (1) and in (2) -> (1) is preferred over (2)
191-
// RUN: rm -rf %t/symlinked1
192-
// RUN: mkdir -p %t/symlinked1/bin
193-
// RUN: ln -sf %t/install/bin/clang %t/symlinked1/bin/clang
194-
// RUN: mkdir -p %t/symlinked1/include/c++/v1
195-
196-
// RUN: %t/symlinked1/bin/clang -### %s -no-canonical-prefixes -fsyntax-only 2>&1 \
197-
// RUN: --target=x86_64-apple-darwin \
198-
// RUN: -stdlib=libc++ \
199-
// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
200-
// RUN: | FileCheck -DSYMLINKED=%t/symlinked1 \
201-
// RUN: -DTOOLCHAIN=%t/install \
202-
// RUN: -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
203-
// RUN: --check-prefix=CHECK-SYMLINKED-INCLUDE-CXX-V1 %s
204-
// CHECK-SYMLINKED-INCLUDE-CXX-V1: "-internal-isystem" "[[SYMLINKED]]/bin/../include/c++/v1"
205-
// CHECK-SYMLINKED-INCLUDE-CXX-V1-NOT: "-internal-isystem" "[[TOOLCHAIN]]/bin/../include/c++/v1"
206-
// CHECK-SYMLINKED-INCLUDE-CXX-V1-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
207-
208-
// Headers in (2) and in (3) -> (2) is preferred over (3)
209-
// RUN: rm -rf %t/symlinked2
210-
// RUN: mkdir -p %t/symlinked2/bin
211-
// RUN: ln -sf %t/install/bin/clang %t/symlinked2/bin/clang
212-
213-
// RUN: %t/symlinked2/bin/clang -### %s -fsyntax-only 2>&1 \
214-
// RUN: --target=x86_64-apple-darwin \
215-
// RUN: -stdlib=libc++ \
216-
// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
217-
// RUN: | FileCheck -DTOOLCHAIN=%t/install \
218-
// RUN: -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
219-
// RUN: --check-prefix=CHECK-TOOLCHAIN-INCLUDE-CXX-V1 %s
220-
// CHECK-TOOLCHAIN-INCLUDE-CXX-V1: "-internal-isystem" "[[TOOLCHAIN]]/bin/../include/c++/v1"
221-
// CHECK-TOOLCHAIN-INCLUDE-CXX-V1-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
222-
223-
// Headers in (2) and nowhere else -> (2) is used
224-
// RUN: %t/symlinked2/bin/clang -### %s -fsyntax-only 2>&1 \
225-
// RUN: --target=x86_64-apple-darwin \
226-
// RUN: -stdlib=libc++ \
227-
// RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
228-
// RUN: | FileCheck -DTOOLCHAIN=%t/install \
229-
// RUN: -DSYSROOT=%S/Inputs/basic_darwin_sdk_no_libcxx \
230-
// RUN: --check-prefix=CHECK-TOOLCHAIN-NO-SYSROOT %s
231-
// CHECK-TOOLCHAIN-NO-SYSROOT: "-internal-isystem" "[[TOOLCHAIN]]/bin/../include/c++/v1"

clang/test/lit.cfg.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ def have_host_clang_repl_cuda():
225225
if "aarch64" in config.host_arch:
226226
config.available_features.add("aarch64-host")
227227

228+
# Some tests are sensitive to whether clang is statically or dynamically linked
229+
# to other libraries.
230+
if not (config.build_shared_libs or config.link_llvm_dylib or config.link_clang_dylib):
231+
config.available_features.add("static-libs")
232+
228233
# Plugins (loadable modules)
229234
if config.has_plugins and config.llvm_plugin_ext:
230235
config.available_features.add("plugins")

clang/test/lit.site.cfg.py.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ config.clang_examples = @CLANG_BUILD_EXAMPLES@
3232
config.enable_shared = @ENABLE_SHARED@
3333
config.enable_backtrace = @ENABLE_BACKTRACES@
3434
config.enable_threads = @LLVM_ENABLE_THREADS@
35+
config.build_shared_libs = @BUILD_SHARED_LIBS@
36+
config.link_llvm_dylib = @LLVM_LINK_LLVM_DYLIB@
37+
config.link_clang_dylib = @CLANG_LINK_CLANG_DYLIB@
3538
config.reverse_iteration = @LLVM_ENABLE_REVERSE_ITERATION@
3639
config.host_arch = "@HOST_ARCH@"
3740
config.perl_executable = "@PERL_EXECUTABLE@"

0 commit comments

Comments
 (0)