1 // Test that the driver adds an arch-specific subdirectory in
2 // {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath'
4 // Test the default behavior when neither -frtlib-add-rpath nor
5 // -fno-rtlib-add-rpath is specified, which is to skip -rpath
6 // RUN: %clang %s -### 2>&1 -target x86_64-linux \
7 // RUN: -fsanitize=address -shared-libasan \
8 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
9 // RUN: -frtlib-add-rpath \
10 // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s
12 // Test that -rpath is not added under -fno-rtlib-add-rpath even if other
13 // conditions are met.
14 // RUN: %clang %s -### 2>&1 -target x86_64-linux \
15 // RUN: -fsanitize=address -shared-libasan \
16 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
17 // RUN: -frtlib-add-rpath \
18 // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s
20 // Test that -rpath is added only under the right circumstance even if
21 // -frtlib-add-rpath is specified.
23 // Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan
24 // RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \
25 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
26 // RUN: -frtlib-add-rpath \
27 // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
29 // Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan
30 // RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \
31 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
32 // RUN: -frtlib-add-rpath \
33 // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
35 // Add LIBPATH, RPATH for -fsanitize=address -shared-libasan
36 // RUN: %clang %s -### 2>&1 -target x86_64-linux \
37 // RUN: -fsanitize=address -shared-libasan \
38 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
39 // RUN: -frtlib-add-rpath \
40 // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
42 // Add LIBPATH, RPATH for -fsanitize=address -shared-libasan on aarch64
43 // RUN: %clang %s -### 2>&1 -target aarch64-linux \
44 // RUN: -fsanitize=address -shared-libasan \
45 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
46 // RUN: -frtlib-add-rpath \
47 // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-AArch64,RPATH-AArch64 %s
49 // Add LIBPATH, RPATH with -fsanitize=address for Android
50 // RUN: %clang %s -### 2>&1 -target x86_64-linux-android -fsanitize=address \
51 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
52 // RUN: -frtlib-add-rpath \
53 // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
55 // Add LIBPATH, RPATH for OpenMP
56 // RUN: %clang %s -### 2>&1 -target x86_64-linux -fopenmp \
57 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
58 // RUN: -frtlib-add-rpath \
59 // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
61 // Add LIBPATH but no RPATH for ubsan (or any other sanitizer)
62 // RUN: %clang %s -### 2>&1 -fsanitize=undefined -target x86_64-linux \
63 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
64 // RUN: -frtlib-add-rpath \
65 // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
67 // Add LIBPATH but no RPATH if no sanitizer or runtime is specified
68 // RUN: %clang %s -### 2>&1 -target x86_64-linux \
69 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
70 // RUN: -frtlib-add-rpath \
71 // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
73 // Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist
74 // RUN: %clang %s -### 2>&1 -target x86_64-linux \
75 // RUN: -resource-dir=%S/Inputs/resource_dir \
76 // RUN: -frtlib-add-rpath \
77 // RUN: | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s
79 // RESDIR: "-resource-dir" "[[RESDIR:[^"]*]]"
80 // LIBPATH-X86_64: -L[[RESDIR]]{{(/|\\\\)lib(/|\\\\)linux(/|\\\\)x86_64}}
81 // RPATH-X86_64: "-rpath" "[[RESDIR]]{{(/|\\\\)lib(/|\\\\)linux(/|\\\\)x86_64}}"
82 // LIBPATH-AArch64: -L[[RESDIR]]{{(/|\\\\)lib(/|\\\\)linux(/|\\\\)aarch64}}
83 // RPATH-AArch64: "-rpath" "[[RESDIR]]{{(/|\\\\)lib(/|\\\\)linux(/|\\\\)aarch64}}"
84 // NO-LIBPATH-NOT: -L{{.*Inputs(/|\\\\)resource_dir}}
85 // NO-RPATH-NOT: "-rpath" {{.*(/|\\\\)Inputs(/|\\\\)resource_dir}}