r197490 - LIBRARY_PATH environment variable should only be supported on a native compiler.

Richard Barton richard.barton at arm.com
Tue Dec 17 03:11:25 PST 2013


Author: rbarton
Date: Tue Dec 17 05:11:25 2013
New Revision: 197490

URL: http://llvm.org/viewvc/llvm-project?rev=197490&view=rev
Log:
LIBRARY_PATH environment variable should only be supported on a native compiler.

Modified:
    cfe/trunk/include/clang/Driver/ToolChain.h
    cfe/trunk/lib/Driver/ToolChain.cpp
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/test/Driver/linker-opts.c

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=197490&r1=197489&r2=197490&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Tue Dec 17 05:11:25 2013
@@ -113,6 +113,9 @@ public:
   StringRef getPlatform() const { return Triple.getVendorName(); }
   StringRef getOS() const { return Triple.getOSName(); }
 
+  /// \brief Returns true if the toolchain is targeting a non-native architecture.
+  bool isCrossCompiling() const;
+
   /// \brief Provide the default architecture name (as expected by -arch) for
   /// this toolchain. Note t
   std::string getDefaultUniversalArchName() const;

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=197490&r1=197489&r2=197490&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Tue Dec 17 05:11:25 2013
@@ -154,6 +154,20 @@ bool ToolChain::HasNativeLLVMSupport() c
   return false;
 }
 
+bool ToolChain::isCrossCompiling() const {
+  llvm::Triple HostTriple(LLVM_HOST_TRIPLE);
+  switch (HostTriple.getArch()) {
+      // The A32/T32/T16 instruction sets are not seperate architectures in 
+      // this context.
+      case llvm::Triple::arm:
+      case llvm::Triple::thumb:
+          return getArch() != llvm::Triple::arm &&
+                 getArch() != llvm::Triple::thumb;
+      default:
+          return HostTriple.getArch() != getArch();
+  }
+}
+
 ObjCRuntime ToolChain::getDefaultObjCRuntime(bool isNonFragile) const {
   return ObjCRuntime(isNonFragile ? ObjCRuntime::GNUstep : ObjCRuntime::GCC,
                      VersionTuple());

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=197490&r1=197489&r2=197490&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Dec 17 05:11:25 2013
@@ -190,7 +190,9 @@ static void AddLinkerInputs(const ToolCh
   }
 
   // LIBRARY_PATH - included following the user specified library paths.
-  addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
+  //                and only supported on native toolchains.
+  if (!TC.isCrossCompiling())
+    addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
 }
 
 /// \brief Determine whether Objective-C automated reference counting is

Modified: cfe/trunk/test/Driver/linker-opts.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linker-opts.c?rev=197490&r1=197489&r2=197490&view=diff
==============================================================================
--- cfe/trunk/test/Driver/linker-opts.c (original)
+++ cfe/trunk/test/Driver/linker-opts.c Tue Dec 17 05:11:25 2013
@@ -4,3 +4,4 @@
 // GCC driver is used as linker on cygming. It should be aware of LIBRARY_PATH.
 // XFAIL: win32
 // REQUIRES: clang-driver
+// REQUIRES: native





More information about the cfe-commits mailing list