r368245 - [Driver] Move LIBRARY_PATH before user inputs
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 7 18:55:27 PDT 2019
Author: maskray
Date: Wed Aug 7 18:55:27 2019
New Revision: 368245
URL: http://llvm.org/viewvc/llvm-project?rev=368245&view=rev
Log:
[Driver] Move LIBRARY_PATH before user inputs
Fixes PR16786
Currently, library paths specified by LIBRARY_PATH are placed after inputs: `inputs LIBRARY_PATH stdlib`
In gcc, the order is: `LIBRARY_PATH inputs stdlib` if not cross compiling.
(On Darwin targets, isCrossCompiling() always returns false.)
This patch changes the behavior to match gcc.
Reviewed By: hfinkel
Differential Revision: https://reviews.llvm.org/D65880
Modified:
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/test/Driver/linker-opts.c
Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=368245&r1=368244&r2=368245&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Wed Aug 7 18:55:27 2019
@@ -145,6 +145,11 @@ void tools::AddLinkerInputs(const ToolCh
// (constructed via -Xarch_).
Args.AddAllArgValues(CmdArgs, options::OPT_Zlinker_input);
+ // LIBRARY_PATH are included before user inputs and only supported on native
+ // toolchains.
+ if (!TC.isCrossCompiling())
+ addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
+
for (const auto &II : Inputs) {
// If the current tool chain refers to an OpenMP or HIP offloading host, we
// should ignore inputs that refer to OpenMP or HIP offloading devices -
@@ -182,12 +187,6 @@ void tools::AddLinkerInputs(const ToolCh
A.renderAsInput(Args, CmdArgs);
}
}
-
- // LIBRARY_PATH - included following the user specified library paths.
- // and only supported on native toolchains.
- if (!TC.isCrossCompiling()) {
- addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
- }
}
void tools::AddTargetFeature(const ArgList &Args,
Modified: cfe/trunk/test/Driver/linker-opts.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linker-opts.c?rev=368245&r1=368244&r2=368245&view=diff
==============================================================================
--- cfe/trunk/test/Driver/linker-opts.c (original)
+++ cfe/trunk/test/Driver/linker-opts.c Wed Aug 7 18:55:27 2019
@@ -1,8 +1,10 @@
// RUN: rm -rf %t
// RUN: mkdir %t
//
-// RUN: env LIBRARY_PATH=%t/test1 %clang -x c %s -### 2>&1 | FileCheck %s
+// RUN: env LIBRARY_PATH=%t/test1 %clang -target %itanium_abi_triple %s -la -### 2>&1 | FileCheck %s
// CHECK: "-L{{.*}}/test1"
+// CHECK: "{{[^"]+}}.o"
+// CHECK: "-la"
// GCC driver is used as linker on cygming. It should be aware of LIBRARY_PATH.
// XFAIL: windows-msvc
@@ -10,8 +12,8 @@
// REQUIRES: native
// Make sure that LIBRARY_PATH works for both i386 and x86_64 on Darwin.
-// RUN: env LIBRARY_PATH=%t/test1 %clang -target x86_64-apple-darwin %s -### 2>&1 | FileCheck %s
-// RUN: env LIBRARY_PATH=%t/test1 %clang -target i386-apple-darwin %s -### 2>&1 | FileCheck %s
+// RUN: env LIBRARY_PATH=%t/test1 %clang -target x86_64-apple-darwin %s -la -### 2>&1 | FileCheck %s
+// RUN: env LIBRARY_PATH=%t/test1 %clang -target i386-apple-darwin %s -la -### 2>&1 | FileCheck %s
//
// Make sure that we don't warn on unused compiler arguments.
// RUN: %clang -Xclang -I. -x c %s -c -o %t/tmp.o
More information about the cfe-commits
mailing list