|
| 1 | +// Test that the driver adds an arch-specific subdirectory in |
| 2 | +// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' |
| 3 | +// |
| 4 | +// REQUIRES: enable_rpath_by_default |
| 5 | +// |
| 6 | +// Test the default behavior when neither -frtlib-add-rpath nor |
| 7 | +// -fno-rtlib-add-rpath is specified, which is to add -rpath |
| 8 | +// RUN: %clang %s -### --target=x86_64-linux \ |
| 9 | +// RUN: -fsanitize=address -shared-libasan \ |
| 10 | +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir 2>&1 \ |
| 11 | +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s |
| 12 | +// |
| 13 | +// Test that -rpath is not added under -fno-rtlib-add-rpath even if other |
| 14 | +// conditions are met. |
| 15 | +// RUN: %clang %s -### --target=x86_64-linux \ |
| 16 | +// RUN: -fsanitize=address -shared-libasan \ |
| 17 | +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
| 18 | +// RUN: -fno-rtlib-add-rpath 2>&1 \ |
| 19 | +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s |
| 20 | +// |
| 21 | +// Test that -rpath is added only under the right circumstance even if |
| 22 | +// -frtlib-add-rpath is specified. |
| 23 | +// |
| 24 | +// Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan |
| 25 | +// RUN: %clang %s -### --target=x86_64-linux -fsanitize=undefined \ |
| 26 | +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
| 27 | +// RUN: -frtlib-add-rpath 2>&1 \ |
| 28 | +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s |
| 29 | +// |
| 30 | +// Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan |
| 31 | +// RUN: %clang %s -### --target=x86_64-linux -fsanitize=undefined \ |
| 32 | +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
| 33 | +// RUN: -frtlib-add-rpath 2>&1 \ |
| 34 | +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s |
| 35 | +// |
| 36 | +// Add LIBPATH, RPATH for -fsanitize=address -shared-libasan |
| 37 | +// RUN: %clang %s -### --target=x86_64-linux \ |
| 38 | +// RUN: -fsanitize=address -shared-libasan \ |
| 39 | +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
| 40 | +// RUN: -frtlib-add-rpath 2>&1 \ |
| 41 | +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s |
| 42 | +// |
| 43 | +// Add LIBPATH, RPATH for -fsanitize=address -shared-libasan on aarch64 |
| 44 | +// RUN: %clang %s -### --target=aarch64-linux \ |
| 45 | +// RUN: -fsanitize=address -shared-libasan \ |
| 46 | +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
| 47 | +// RUN: -frtlib-add-rpath 2>&1 \ |
| 48 | +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-AARCH64,RPATH-AARCH64 %s |
| 49 | +// |
| 50 | +// Add LIBPATH, RPATH with -fsanitize=address for Android |
| 51 | +// RUN: %clang %s -### --target=x86_64-linux-android -fsanitize=address \ |
| 52 | +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
| 53 | +// RUN: -frtlib-add-rpath 2>&1 \ |
| 54 | +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s |
| 55 | +// |
| 56 | +// Add LIBPATH, RPATH for OpenMP |
| 57 | +// RUN: %clang %s -### --target=x86_64-linux -fopenmp \ |
| 58 | +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
| 59 | +// RUN: -frtlib-add-rpath 2>&1 \ |
| 60 | +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s |
| 61 | +// |
| 62 | +// Add LIBPATH but no RPATH for ubsan (or any other sanitizer) |
| 63 | +// RUN: %clang %s -### -fsanitize=undefined --target=x86_64-linux \ |
| 64 | +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
| 65 | +// RUN: -frtlib-add-rpath 2>&1 \ |
| 66 | +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s |
| 67 | +// |
| 68 | +// Add LIBPATH but no RPATH if no sanitizer or runtime is specified |
| 69 | +// RUN: %clang %s -### --target=x86_64-linux \ |
| 70 | +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
| 71 | +// RUN: -frtlib-add-rpath 2>&1 \ |
| 72 | +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s |
| 73 | +// |
| 74 | +// Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist |
| 75 | +// RUN: %clang %s -### --target=x86_64-linux \ |
| 76 | +// RUN: -resource-dir=%S/Inputs/resource_dir \ |
| 77 | +// RUN: -frtlib-add-rpath 2>&1 \ |
| 78 | +// RUN: | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s |
| 79 | + |
| 80 | +// Test that the driver adds an per-target arch-specific subdirectory in |
| 81 | +// {RESOURCE_DIR}/lib/{triple} to the linker search path and to '-rpath' |
| 82 | +// |
| 83 | +// RUN: %clang %s -### 2>&1 --target=x86_64-linux-gnu \ |
| 84 | +// RUN: -fsanitize=address -shared-libasan \ |
| 85 | +// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ |
| 86 | +// RUN: -frtlib-add-rpath \ |
| 87 | +// RUN: | FileCheck --check-prefixes=PERTARGET %s |
| 88 | + |
| 89 | +// RESDIR: "-resource-dir" "[[RESDIR:[^"]*]]" |
| 90 | +// |
| 91 | +// LIBPATH-X86_64: -L[[RESDIR]]{{(/|\\\\)lib(/|\\\\)linux(/|\\\\)x86_64}} |
| 92 | +// RPATH-X86_64: "-rpath" "[[RESDIR]]{{(/|\\\\)lib(/|\\\\)linux(/|\\\\)x86_64}}" |
| 93 | +// |
| 94 | +// NO-LIBPATH-X86_64-NOT: -L[[RESDIR]]{{(/|\\\\)lib(/|\\\\)linux(/|\\\\)x86_64}} |
| 95 | +// NO-RPATH-X86_64-NOT: "-rpath" "[[RESDIR]]{{(/|\\\\)lib(/|\\\\)linux(/|\\\\)x86_64}}" |
| 96 | +// |
| 97 | +// LIBPATH-AARCH64: -L[[RESDIR]]{{(/|\\\\)lib(/|\\\\)linux(/|\\\\)aarch64}} |
| 98 | +// RPATH-AARCH64: "-rpath" "[[RESDIR]]{{(/|\\\\)lib(/|\\\\)linux(/|\\\\)aarch64}}" |
| 99 | +// |
| 100 | +// NO-LIBPATH-NOT: "-L{{[^"]*Inputs(/|\\\\)resource_dir}}" |
| 101 | +// NO-RPATH-NOT: "-rpath" {{.*(/|\\\\)Inputs(/|\\\\)resource_dir}} |
| 102 | + |
| 103 | +// PERTARGET: "-resource-dir" "[[PTRESDIR:[^"]*]]" |
| 104 | +// PERTARGET: -L[[PTRESDIR]]{{(/|\\\\)lib(/|\\\\)x86_64-unknown-linux-gnu}} |
| 105 | +// PERTARGET: "-rpath" "[[PTRESDIR]]{{(/|\\\\)lib(/|\\\\)x86_64-unknown-linux-gnu}}" |
0 commit comments