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