Pirama Arumuga Nainar | 65a16dd | 2017-03-03 23:20:49 +0000 | [diff] [blame] | 1 | // Test that the driver adds an arch-specific subdirectory in |
Pirama Arumuga Nainar | b9d8062 | 2017-03-14 16:58:07 +0000 | [diff] [blame^] | 2 | // {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' |
Pirama Arumuga Nainar | 65a16dd | 2017-03-03 23:20:49 +0000 | [diff] [blame] | 3 | // |
Pirama Arumuga Nainar | b9d8062 | 2017-03-14 16:58:07 +0000 | [diff] [blame^] | 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 |
| 11 | // |
| 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 |
| 19 | // |
| 20 | // Test that -rpath is added only under the right circumstance even if |
| 21 | // -frtlib-add-rpath is specified. |
Pirama Arumuga Nainar | 65a16dd | 2017-03-03 23:20:49 +0000 | [diff] [blame] | 22 | // |
| 23 | // Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan |
Pirama Arumuga Nainar | b9d8062 | 2017-03-14 16:58:07 +0000 | [diff] [blame^] | 24 | // RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \ |
Pirama Arumuga Nainar | 65a16dd | 2017-03-03 23:20:49 +0000 | [diff] [blame] | 25 | // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
Pirama Arumuga Nainar | b9d8062 | 2017-03-14 16:58:07 +0000 | [diff] [blame^] | 26 | // RUN: -frtlib-add-rpath \ |
| 27 | // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s |
| 28 | // |
| 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 |
Pirama Arumuga Nainar | 65a16dd | 2017-03-03 23:20:49 +0000 | [diff] [blame] | 34 | // |
| 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 \ |
Pirama Arumuga Nainar | b9d8062 | 2017-03-14 16:58:07 +0000 | [diff] [blame^] | 39 | // RUN: -frtlib-add-rpath \ |
| 40 | // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s |
| 41 | // |
| 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 |
Pirama Arumuga Nainar | 65a16dd | 2017-03-03 23:20:49 +0000 | [diff] [blame] | 48 | // |
| 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 \ |
Pirama Arumuga Nainar | b9d8062 | 2017-03-14 16:58:07 +0000 | [diff] [blame^] | 52 | // RUN: -frtlib-add-rpath \ |
| 53 | // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s |
Pirama Arumuga Nainar | 65a16dd | 2017-03-03 23:20:49 +0000 | [diff] [blame] | 54 | // |
| 55 | // Add LIBPATH, RPATH for OpenMP |
Pirama Arumuga Nainar | b9d8062 | 2017-03-14 16:58:07 +0000 | [diff] [blame^] | 56 | // RUN: %clang %s -### 2>&1 -target x86_64-linux -fopenmp \ |
Pirama Arumuga Nainar | 65a16dd | 2017-03-03 23:20:49 +0000 | [diff] [blame] | 57 | // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
Pirama Arumuga Nainar | b9d8062 | 2017-03-14 16:58:07 +0000 | [diff] [blame^] | 58 | // RUN: -frtlib-add-rpath \ |
| 59 | // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s |
Pirama Arumuga Nainar | 65a16dd | 2017-03-03 23:20:49 +0000 | [diff] [blame] | 60 | // |
| 61 | // Add LIBPATH but no RPATH for ubsan (or any other sanitizer) |
| 62 | // RUN: %clang %s -### 2>&1 -fsanitize=undefined \ |
| 63 | // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
Pirama Arumuga Nainar | b9d8062 | 2017-03-14 16:58:07 +0000 | [diff] [blame^] | 64 | // RUN: -frtlib-add-rpath \ |
| 65 | // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s |
Pirama Arumuga Nainar | 65a16dd | 2017-03-03 23:20:49 +0000 | [diff] [blame] | 66 | // |
| 67 | // Add LIBPATH but no RPATH if no sanitizer or runtime is specified |
| 68 | // RUN: %clang %s -### 2>&1 \ |
| 69 | // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ |
Pirama Arumuga Nainar | b9d8062 | 2017-03-14 16:58:07 +0000 | [diff] [blame^] | 70 | // RUN: -frtlib-add-rpath \ |
| 71 | // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s |
Pirama Arumuga Nainar | 65a16dd | 2017-03-03 23:20:49 +0000 | [diff] [blame] | 72 | // |
| 73 | // Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist |
| 74 | // RUN: %clang %s -### 2>&1 \ |
| 75 | // RUN: -resource-dir=%S/Inputs/resource_dir \ |
Pirama Arumuga Nainar | b9d8062 | 2017-03-14 16:58:07 +0000 | [diff] [blame^] | 76 | // RUN: -frtlib-add-rpath \ |
| 77 | // RUN: | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s |
Pirama Arumuga Nainar | 65a16dd | 2017-03-03 23:20:49 +0000 | [diff] [blame] | 78 | // |
Pirama Arumuga Nainar | b9d8062 | 2017-03-14 16:58:07 +0000 | [diff] [blame^] | 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 |