| 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 -### 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: | 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 -### 2>&1 -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 \ |
| 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 -### 2>&1 -target x86_64-linux -fsanitize=undefined \ |
| 24 | // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
| 25 | // RUN: -frtlib-add-rpath \ |
| 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 -### 2>&1 -target x86_64-linux -fsanitize=undefined \ |
| 30 | // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
| 31 | // RUN: -frtlib-add-rpath \ |
| 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 -### 2>&1 -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 \ |
| 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 -### 2>&1 -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 \ |
| 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 -### 2>&1 -target x86_64-linux-android -fsanitize=address \ |
| 50 | // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
| 51 | // RUN: -frtlib-add-rpath \ |
| 52 | // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s |
| 53 | // |
| 54 | // Add LIBPATH, RPATH for OpenMP |
| 55 | // RUN: %clang %s -### 2>&1 -target x86_64-linux -fopenmp \ |
| 56 | // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
| 57 | // RUN: -frtlib-add-rpath \ |
| 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 -### 2>&1 -fsanitize=undefined -target x86_64-linux \ |
| 62 | // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
| 63 | // RUN: -frtlib-add-rpath \ |
| 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 -### 2>&1 -target x86_64-linux \ |
| 68 | // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
| 69 | // RUN: -frtlib-add-rpath \ |
| 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 -### 2>&1 -target x86_64-linux \ |
| 74 | // RUN: -resource-dir=%S/Inputs/resource_dir \ |
| 75 | // RUN: -frtlib-add-rpath \ |
| 76 | // RUN: | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s |
| 77 | |
| 78 | // RESDIR: "-resource-dir" "[[RESDIR:[^"]*]]" |
| 79 | // |
| 80 | // LIBPATH-X86_64: -L[[RESDIR]]{{(/|\\\\)lib(/|\\\\)linux(/|\\\\)x86_64}} |
| 81 | // RPATH-X86_64: "-rpath" "[[RESDIR]]{{(/|\\\\)lib(/|\\\\)linux(/|\\\\)x86_64}}" |
| 82 | // |
| 83 | // NO-LIBPATH-X86_64-NOT: -L[[RESDIR]]{{(/|\\\\)lib(/|\\\\)linux(/|\\\\)x86_64}} |
| 84 | // NO-RPATH-X86_64-NOT: "-rpath" "[[RESDIR]]{{(/|\\\\)lib(/|\\\\)linux(/|\\\\)x86_64}}" |
| 85 | // |
| 86 | // LIBPATH-AARCH64: -L[[RESDIR]]{{(/|\\\\)lib(/|\\\\)linux(/|\\\\)aarch64}} |
| 87 | // RPATH-AAARCH4: "-rpath" "[[RESDIR]]{{(/|\\\\)lib(/|\\\\)linux(/|\\\\)aarch64}}" |
| 88 | // |
| 89 | // NO-LIBPATH-NOT: "-L{{[^"]*Inputs(/|\\\\)resource_dir}}" |
| 90 | // NO-RPATH-NOT: "-rpath" {{.*(/|\\\\)Inputs(/|\\\\)resource_dir}} |
| 91 | |