summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPirama Arumuga Nainar <pirama@google.com>2017-03-14 16:58:07 +0000
committerPirama Arumuga Nainar <pirama@google.com>2017-03-14 16:58:07 +0000
commitb9d8062eda0204206dbf149b52c0a13238e57a78 (patch)
treea431f7f2c2cfd2e2d11f41255e310d63da1d0b47
parent2b9f48afdd67dcfdd37d7afe6a34059cd390fc21 (diff)
downloadbcm5719-llvm-b9d8062eda0204206dbf149b52c0a13238e57a78.tar.gz
bcm5719-llvm-b9d8062eda0204206dbf149b52c0a13238e57a78.zip
[Driver] Add flag to request arch-specific-subdir in -rpath
Summary: This patch adds -f[no-]rtlib-add-rpath, which if enabled, embeds the arch-specific subdirectory in resource directory using -rpath (instead of doing so only during native compilation). This patch also re-enables test arch-specific-libdir.c which was silently unsupported because of the REQUIRES tag 'linux'. Reviewers: bkramer, rnk, mgorny Subscribers: srhines, cfe-commits Differential Revision: https://reviews.llvm.org/D30700 llvm-svn: 297751
-rw-r--r--clang/include/clang/Driver/Options.td4
-rw-r--r--clang/lib/Driver/ToolChains/CommonArgs.cpp4
-rw-r--r--clang/test/Driver/arch-specific-libdir-rpath.c75
-rw-r--r--clang/test/Driver/arch-specific-libdir.c2
-rw-r--r--clang/test/lit.cfg4
5 files changed, 59 insertions, 30 deletions
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 7952b33fd5e..0fc5400a93a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2098,6 +2098,10 @@ def resource_dir_EQ : Joined<["-"], "resource-dir=">, Flags<[DriverOption, CoreO
def rpath : Separate<["-"], "rpath">, Flags<[LinkerInput]>, Group<Link_Group>;
def rtlib_EQ : Joined<["-", "--"], "rtlib=">,
HelpText<"Compiler runtime library to use">;
+def frtlib_add_rpath: Flag<["-"], "frtlib-add-rpath">, Flags<[NoArgumentUnused]>,
+ HelpText<"Add -rpath with architecture-specific resource directory to the linker flags">;
+def fno_rtlib_add_rpath: Flag<["-"], "fno-rtlib-add-rpath">, Flags<[NoArgumentUnused]>,
+ HelpText<"Do not add -rpath with architecture-specific resource directory to the linker flags">;
def r : Flag<["-"], "r">, Flags<[LinkerInput,NoArgumentUnused]>,
Group<Link_Group>;
def save_temps_EQ : Joined<["-", "--"], "save-temps=">, Flags<[DriverOption]>,
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 5afe1358657..48a2cf038d5 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -419,10 +419,6 @@ void tools::AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,
void tools::addArchSpecificRPath(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs) {
- // In the cross-compilation case, arch-specific library path is likely
- // unavailable at runtime.
- if (TC.isCrossCompiling()) return;
-
std::string CandidateRPath = TC.getArchSpecificLibPath();
if (TC.getVFS().exists(CandidateRPath)) {
CmdArgs.push_back("-rpath");
diff --git a/clang/test/Driver/arch-specific-libdir-rpath.c b/clang/test/Driver/arch-specific-libdir-rpath.c
index e6a5da8752c..537870becbc 100644
--- a/clang/test/Driver/arch-specific-libdir-rpath.c
+++ b/clang/test/Driver/arch-specific-libdir-rpath.c
@@ -1,50 +1,85 @@
// Test that the driver adds an arch-specific subdirectory in
-// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
-// compilations.
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath'
//
-// -rpath only gets added during native compilation. To keep the test simple,
-// just test for x86_64-linux native compilation.
-// REQUIRES: x86_64-linux
+// Test the default behavior when neither -frtlib-add-rpath nor
+// -fno-rtlib-add-rpath is specified, which is to skip -rpath
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -frtlib-add-rpath \
+// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s
+//
+// Test that -rpath is not added under -fno-rtlib-add-rpath even if other
+// conditions are met.
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -frtlib-add-rpath \
+// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s
+//
+// Test that -rpath is added only under the right circumstance even if
+// -frtlib-add-rpath is specified.
//
// Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan
-// RUN: %clang %s -### 2>&1 -fsanitize=undefined \
+// RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -frtlib-add-rpath \
+// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
+//
+// Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan
+// RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN: | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s
+// RUN: -frtlib-add-rpath \
+// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
//
// Add LIBPATH, RPATH for -fsanitize=address -shared-libasan
// RUN: %clang %s -### 2>&1 -target x86_64-linux \
// RUN: -fsanitize=address -shared-libasan \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN: | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
+// RUN: -frtlib-add-rpath \
+// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
+//
+// Add LIBPATH, RPATH for -fsanitize=address -shared-libasan on aarch64
+// RUN: %clang %s -### 2>&1 -target aarch64-linux \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -frtlib-add-rpath \
+// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-AArch64,RPATH-AArch64 %s
//
// Add LIBPATH, RPATH with -fsanitize=address for Android
// RUN: %clang %s -### 2>&1 -target x86_64-linux-android -fsanitize=address \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN: | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
+// RUN: -frtlib-add-rpath \
+// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
//
// Add LIBPATH, RPATH for OpenMP
-// RUN: %clang %s -### 2>&1 -fopenmp \
+// RUN: %clang %s -### 2>&1 -target x86_64-linux -fopenmp \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN: | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
+// RUN: -frtlib-add-rpath \
+// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
//
// Add LIBPATH but no RPATH for ubsan (or any other sanitizer)
// RUN: %clang %s -### 2>&1 -fsanitize=undefined \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN: | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s
+// RUN: -frtlib-add-rpath \
+// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
//
// Add LIBPATH but no RPATH if no sanitizer or runtime is specified
// RUN: %clang %s -### 2>&1 \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN: | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s
+// RUN: -frtlib-add-rpath \
+// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
//
// Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist
// RUN: %clang %s -### 2>&1 \
// RUN: -resource-dir=%S/Inputs/resource_dir \
-// RUN: | FileCheck --check-prefixes=FILEPATH,NO-LIBPATH,NO-RPATH %s
-//
+// RUN: -frtlib-add-rpath \
+// RUN: | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s
//
-// FILEPATH: "-x" "c" "[[FILE_PATH:.*]]/{{.*}}.c"
-// LIBPATH: -L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64
-// RPATH: "-rpath" "[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64"
-// NO-LIBPATH-NOT: -L{{.*}}Inputs/resource_dir
-// NO-RPATH-NOT: "-rpath" {{.*}}/Inputs/resource_dir
+// RESDIR: "-resource-dir" "[[RESDIR:[^ ]*]]"
+// LIBPATH-X86_64: -L[[RESDIR]]/lib/linux/x86_64
+// RPATH-X86_64: "-rpath" "[[RESDIR]]/lib/linux/x86_64"
+// LIBPATH-AArch64: -L[[RESDIR]]/lib/linux/aarch64
+// RPATH-AArch64: "-rpath" "[[RESDIR]]/lib/linux/aarch64"
+// NO-LIBPATH-NOT: -L{{.*}}Inputs/resource_dir
+// NO-RPATH-NOT: "-rpath" {{.*}}/Inputs/resource_dir
diff --git a/clang/test/Driver/arch-specific-libdir.c b/clang/test/Driver/arch-specific-libdir.c
index 3889b37131e..48196e6bdd0 100644
--- a/clang/test/Driver/arch-specific-libdir.c
+++ b/clang/test/Driver/arch-specific-libdir.c
@@ -1,8 +1,6 @@
// Test that the driver adds an arch-specific subdirectory in
// {RESOURCE_DIR}/lib/linux to the search path.
//
-// REQUIRES: linux
-//
// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
// RUN: | FileCheck --check-prefixes=FILEPATH,ARCHDIR-i386 %s
diff --git a/clang/test/lit.cfg b/clang/test/lit.cfg
index 5beecb65bd6..2b494c49109 100644
--- a/clang/test/lit.cfg
+++ b/clang/test/lit.cfg
@@ -397,10 +397,6 @@ if platform.system() not in ['Darwin', 'Fuchsia']:
if config.host_triple == config.target_triple:
config.available_features.add("native")
-# Test Driver/arch-specific-libdir-rpath.c is restricted to x86_64-linux
-if re.match(r'^x86_64.*-linux', config.target_triple):
- config.available_features.add("x86_64-linux")
-
# Case-insensitive file system
def is_filesystem_case_insensitive():
handle, path = tempfile.mkstemp(prefix='case-test', dir=config.test_exec_root)
OpenPOWER on IntegriCloud