summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2013-10-29 10:27:30 +0000
committerChandler Carruth <chandlerc@gmail.com>2013-10-29 10:27:30 +0000
commitda797048d9dac2b34880c9858a393c5af08e817b (patch)
tree89336cf72603adb78e3c216f697909c9df475a29 /clang/lib
parent18b5701a6853f6b4a5b3a05ba5c79105a805b61b (diff)
downloadbcm5719-llvm-da797048d9dac2b34880c9858a393c5af08e817b.tar.gz
bcm5719-llvm-da797048d9dac2b34880c9858a393c5af08e817b.zip
Teach the driver to not try to use 'lib32' multilib spellings on ARM
which doesn't use that multilib. As a consequence, fix Clang's support for cross compiling environments that were relying on this quirk to ensure the correct library search path ordering. This also re-instates the new test cases from Rafael's r193528 for cross-compiling to ARM on Ubuntu 13.10 without any of the changes to the existing test cases (they were no longer needed). This solution was the result of a lot of IRC debugging and trying to understand *exactly* what quirk was being relied upon. It took some time for me to figure out that it was the use of 'lib32' is a multilib that was throwing a wrench in the works. In case you are thinking that its silly to use a multilib of 'lib' at all, entertainingly, GCC does so as well (you can see it with the .../lib/../lib/crt1.o pattern it uses), and the 2-phase sequence of search paths (multilib followed by non-multilib) has observable (if dubious) consequences. =/ Yuck. llvm-svn: 193601
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Driver/ToolChains.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp
index 1903f115b43..2a112c24925 100644
--- a/clang/lib/Driver/ToolChains.cpp
+++ b/clang/lib/Driver/ToolChains.cpp
@@ -2264,13 +2264,26 @@ static void addPathIfExists(Twine Path, ToolChain::path_list &Paths) {
static StringRef getMultilibDir(const llvm::Triple &Triple,
const ArgList &Args) {
- if (!isMipsArch(Triple.getArch()))
- return Triple.isArch32Bit() ? "lib32" : "lib64";
+ if (isMipsArch(Triple.getArch())) {
+ // lib32 directory has a special meaning on MIPS targets.
+ // It contains N32 ABI binaries. Use this folder if produce
+ // code for N32 ABI only.
+ if (hasMipsN32ABIArg(Args))
+ return "lib32";
+ return Triple.isArch32Bit() ? "lib" : "lib64";
+ }
- // lib32 directory has a special meaning on MIPS targets.
- // It contains N32 ABI binaries. Use this folder if produce
- // code for N32 ABI only.
- if (hasMipsN32ABIArg(Args))
+ // It happens that only x86 and PPC use the 'lib32' variant of multilib, and
+ // using that variant while targeting other architectures causes problems
+ // because the libraries are laid out in shared system roots that can't cope
+ // with a 'lib32' multilib search path being considered. So we only enable
+ // them when we know we may need it.
+ //
+ // FIXME: This is a bit of a hack. We should really unify this code for
+ // reasoning about multilib spellings with the lib dir spellings in the
+ // GCCInstallationDetector, but that is a more significant refactoring.
+ if (Triple.getArch() == llvm::Triple::x86 ||
+ Triple.getArch() == llvm::Triple::ppc)
return "lib32";
return Triple.isArch32Bit() ? "lib" : "lib64";
OpenPOWER on IntegriCloud