From 68c679f8416d6261836f6fd50e02a65ded40b157 Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Tue, 29 Jul 2014 20:17:52 +0000 Subject: [PATCH] Support LIBRARY_PATH on all Darwin targets. r197490 changed the behavior of LIBRARY_PATH to try to match GCC's behavior for cross compilers and make clang work better on "bare metal" targets. Unfortunately that change is breaking a number of MacPorts projects because the LIBRARY_PATH environment variable is being ignored when compiling on a 64-bit host for a 32-bit target. Because the host and target architectures differ, isCrossCompiling returns true. This does not make sense for Darwin, where multiple architectures are supported natively via "fat" Mach-O slices and where development is generally done against SDKs regardless. This patch fixes the problem by overriding isCrossCompiling to return false for Darwin toolchains. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214208 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/ToolChain.h | 7 ++++--- lib/Driver/ToolChains.h | 5 +++++ test/Driver/linker-opts.c | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h index 7ee569f8a5..6f5677cc16 100644 --- a/include/clang/Driver/ToolChain.h +++ b/include/clang/Driver/ToolChain.h @@ -116,9 +116,6 @@ 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 StringRef getDefaultUniversalArchName() const; @@ -171,6 +168,10 @@ public: // Platform defaults information + /// \brief Returns true if the toolchain is targeting a non-native + /// architecture. + virtual bool isCrossCompiling() const; + /// HasNativeLTOLinker - Check whether the linker and related tools have /// native LLVM support. virtual bool HasNativeLLVMSupport() const; diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index 479f3350a8..556e8845fe 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -427,6 +427,11 @@ public: /// @name ToolChain Implementation /// { + // Darwin tools support multiple architecture (e.g., i386 and x86_64) and + // most development is done against SDKs, so compiling for a different + // architecture should not get any special treatment. + bool isCrossCompiling() const override { return false; } + llvm::opt::DerivedArgList * TranslateArgs(const llvm::opt::DerivedArgList &Args, const char *BoundArch) const override; diff --git a/test/Driver/linker-opts.c b/test/Driver/linker-opts.c index 3fc95ec7d2..24866a63b1 100644 --- a/test/Driver/linker-opts.c +++ b/test/Driver/linker-opts.c @@ -5,3 +5,7 @@ // XFAIL: win32 // REQUIRES: clang-driver // 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 -- 2.40.0