blob: 3bcf6e3d3f868e866039350b6a6a36fe56e1c4d2 [file] [log] [blame]
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +00001// Test that the driver adds an arch-specific subdirectory in
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +00002// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath'
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +00003//
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +00004// 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 Nainar65a16dd2017-03-03 23:20:49 +000022//
23// Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000024// RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000025// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000026// 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 Nainar65a16dd2017-03-03 23:20:49 +000034//
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 Nainarb9d80622017-03-14 16:58:07 +000039// 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 Nainar65a16dd2017-03-03 23:20:49 +000048//
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 Nainarb9d80622017-03-14 16:58:07 +000052// RUN: -frtlib-add-rpath \
53// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000054//
55// Add LIBPATH, RPATH for OpenMP
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000056// RUN: %clang %s -### 2>&1 -target x86_64-linux -fopenmp \
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000057// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000058// RUN: -frtlib-add-rpath \
59// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000060//
61// Add LIBPATH but no RPATH for ubsan (or any other sanitizer)
Pirama Arumuga Nainarcd037452017-03-14 17:26:56 +000062// RUN: %clang %s -### 2>&1 -fsanitize=undefined -target x86_64-linux \
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000063// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000064// RUN: -frtlib-add-rpath \
65// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000066//
67// Add LIBPATH but no RPATH if no sanitizer or runtime is specified
Pirama Arumuga Nainarcd037452017-03-14 17:26:56 +000068// RUN: %clang %s -### 2>&1 -target x86_64-linux \
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000069// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000070// RUN: -frtlib-add-rpath \
71// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000072//
73// Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist
Pirama Arumuga Nainarcd037452017-03-14 17:26:56 +000074// RUN: %clang %s -### 2>&1 -target x86_64-linux \
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000075// RUN: -resource-dir=%S/Inputs/resource_dir \
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000076// RUN: -frtlib-add-rpath \
77// RUN: | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000078//
Reid Klecknere30d3eb2017-03-14 18:24:41 +000079// 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}}