blob: e6a5da8752cf29ba4f025cb09da9a6aa7b200201 [file] [log] [blame]
Pirama Arumuga Nainar65a16dd2017-03-03 23:20:49 +00001// Test that the driver adds an arch-specific subdirectory in
2// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
3// compilations.
4//
5// -rpath only gets added during native compilation. To keep the test simple,
6// just test for x86_64-linux native compilation.
7// REQUIRES: x86_64-linux
8//
9// Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan
10// RUN: %clang %s -### 2>&1 -fsanitize=undefined \
11// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
12// RUN: | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s
13//
14// Add LIBPATH, RPATH for -fsanitize=address -shared-libasan
15// RUN: %clang %s -### 2>&1 -target x86_64-linux \
16// RUN: -fsanitize=address -shared-libasan \
17// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
18// RUN: | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
19//
20// Add LIBPATH, RPATH with -fsanitize=address for Android
21// RUN: %clang %s -### 2>&1 -target x86_64-linux-android -fsanitize=address \
22// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
23// RUN: | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
24//
25// Add LIBPATH, RPATH for OpenMP
26// RUN: %clang %s -### 2>&1 -fopenmp \
27// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
28// RUN: | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
29//
30// Add LIBPATH but no RPATH for ubsan (or any other sanitizer)
31// RUN: %clang %s -### 2>&1 -fsanitize=undefined \
32// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
33// RUN: | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s
34//
35// Add LIBPATH but no RPATH if no sanitizer or runtime is specified
36// RUN: %clang %s -### 2>&1 \
37// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
38// RUN: | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s
39//
40// Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist
41// RUN: %clang %s -### 2>&1 \
42// RUN: -resource-dir=%S/Inputs/resource_dir \
43// RUN: | FileCheck --check-prefixes=FILEPATH,NO-LIBPATH,NO-RPATH %s
44//
45//
46// FILEPATH: "-x" "c" "[[FILE_PATH:.*]]/{{.*}}.c"
47// LIBPATH: -L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64
48// RPATH: "-rpath" "[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64"
49// NO-LIBPATH-NOT: -L{{.*}}Inputs/resource_dir
50// NO-RPATH-NOT: "-rpath" {{.*}}/Inputs/resource_dir