blob: 2ea41aade3422f181124c3046904c69cb2ddb30b [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 \
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +00009// 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 \
Petr Hosekbae48562018-04-02 23:36:14 +000016// RUN: -fno-rtlib-add-rpath \
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000017// 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.
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000021//
22// Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000023// RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000024// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000025// RUN: -frtlib-add-rpath \
Petr Hosekbae48562018-04-02 23:36:14 +000026// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000027//
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 \
Petr Hosekbae48562018-04-02 23:36:14 +000032// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000033//
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 \
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000038// 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 \
Petr Hosekbae48562018-04-02 23:36:14 +000046// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-AARCH64,RPATH-AARCH64 %s
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000047//
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 \
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000051// RUN: -frtlib-add-rpath \
52// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000053//
54// Add LIBPATH, RPATH for OpenMP
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000055// RUN: %clang %s -### 2>&1 -target x86_64-linux -fopenmp \
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000056// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000057// RUN: -frtlib-add-rpath \
58// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000059//
60// Add LIBPATH but no RPATH for ubsan (or any other sanitizer)
Pirama Arumuga Nainarcd037452017-03-14 17:26:56 +000061// RUN: %clang %s -### 2>&1 -fsanitize=undefined -target x86_64-linux \
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000062// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000063// RUN: -frtlib-add-rpath \
Petr Hosekbae48562018-04-02 23:36:14 +000064// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000065//
66// Add LIBPATH but no RPATH if no sanitizer or runtime is specified
Pirama Arumuga Nainarcd037452017-03-14 17:26:56 +000067// RUN: %clang %s -### 2>&1 -target x86_64-linux \
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000068// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000069// RUN: -frtlib-add-rpath \
Petr Hosekbae48562018-04-02 23:36:14 +000070// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000071//
72// Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist
Pirama Arumuga Nainarcd037452017-03-14 17:26:56 +000073// RUN: %clang %s -### 2>&1 -target x86_64-linux \
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +000074// RUN: -resource-dir=%S/Inputs/resource_dir \
Pirama Arumuga Nainarb9d80622017-03-14 16:58:07 +000075// RUN: -frtlib-add-rpath \
76// RUN: | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s
Petr Hosekbae48562018-04-02 23:36:14 +000077
Reid Klecknere30d3eb2017-03-14 18:24:41 +000078// RESDIR: "-resource-dir" "[[RESDIR:[^"]*]]"
Petr Hosekbae48562018-04-02 23:36:14 +000079//
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}}