diff options
| author | Christian Bruel <christian.bruel@st.com> | 2018-09-06 14:03:44 +0000 |
|---|---|---|
| committer | Christian Bruel <christian.bruel@st.com> | 2018-09-06 14:03:44 +0000 |
| commit | 6ccc4a7c2076302183eb6789c1688997313720e1 (patch) | |
| tree | e5525945ce11c1bf8543fb0e6961de9e3baa4c96 /clang | |
| parent | fea4ac01c5fc4b9626e3ba990839b2f4ba9d8575 (diff) | |
| download | bcm5719-llvm-6ccc4a7c2076302183eb6789c1688997313720e1.tar.gz bcm5719-llvm-6ccc4a7c2076302183eb6789c1688997313720e1.zip | |
Fix the -print-multi-directory flag to print the selected multilib.
Summary: Fix -print-multi-directory to print the selected multilib
Reviewers: jroelofs
Reviewed By: jroelofs
Subscribers: jroelofs, timshen, thakis, srhines, cfe-commits
Differential Revision: https://reviews.llvm.org/D51354
llvm-svn: 341547
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/Driver/ToolChain.h | 3 | ||||
| -rw-r--r-- | clang/lib/Driver/Driver.cpp | 15 | ||||
| -rw-r--r-- | clang/lib/Driver/ToolChains/Linux.cpp | 9 | ||||
| -rw-r--r-- | clang/test/Driver/print-multi-directory.c | 30 |
4 files changed, 44 insertions, 13 deletions
diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index 1395134f40f..36c0e929398 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -149,6 +149,7 @@ private: protected: MultilibSet Multilibs; + Multilib SelectedMultilib; ToolChain(const Driver &D, const llvm::Triple &T, const llvm::opt::ArgList &Args); @@ -227,6 +228,8 @@ public: const MultilibSet &getMultilibs() const { return Multilibs; } + const Multilib &getMultilib() const { return SelectedMultilib; } + const SanitizerArgs& getSanitizerArgs() const; const XRayArgs& getXRayArgs() const; diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 6527c19b614..14cfc48c8f2 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1661,14 +1661,13 @@ bool Driver::HandleImmediateArgs(const Compilation &C) { } if (C.getArgs().hasArg(options::OPT_print_multi_directory)) { - for (const Multilib &Multilib : TC.getMultilibs()) { - if (Multilib.gccSuffix().empty()) - llvm::outs() << ".\n"; - else { - StringRef Suffix(Multilib.gccSuffix()); - assert(Suffix.front() == '/'); - llvm::outs() << Suffix.substr(1) << "\n"; - } + const Multilib &Multilib = TC.getMultilib(); + if (Multilib.gccSuffix().empty()) + llvm::outs() << ".\n"; + else { + StringRef Suffix(Multilib.gccSuffix()); + assert(Suffix.front() == '/'); + llvm::outs() << Suffix.substr(1) << "\n"; } return false; } diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp index 4e4317076fd..d8786817ec1 100644 --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -210,6 +210,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) : Generic_ELF(D, Triple, Args) { GCCInstallation.init(Triple, Args); Multilibs = GCCInstallation.getMultilibs(); + SelectedMultilib = GCCInstallation.getMultilib(); llvm::Triple::ArchType Arch = Triple.getArch(); std::string SysRoot = computeSysRoot(); @@ -299,16 +300,14 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) if (GCCInstallation.isValid()) { const llvm::Triple &GCCTriple = GCCInstallation.getTriple(); const std::string &LibPath = GCCInstallation.getParentLibPath(); - const Multilib &Multilib = GCCInstallation.getMultilib(); - const MultilibSet &Multilibs = GCCInstallation.getMultilibs(); // Add toolchain / multilib specific file paths. - addMultilibsFilePaths(D, Multilibs, Multilib, + addMultilibsFilePaths(D, Multilibs, SelectedMultilib, GCCInstallation.getInstallPath(), Paths); // Sourcery CodeBench MIPS toolchain holds some libraries under // a biarch-like suffix of the GCC installation. - addPathIfExists(D, GCCInstallation.getInstallPath() + Multilib.gccSuffix(), + addPathIfExists(D, GCCInstallation.getInstallPath() + SelectedMultilib.gccSuffix(), Paths); // GCC cross compiling toolchains will install target libraries which ship @@ -330,7 +329,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) // Note that this matches the GCC behavior. See the below comment for where // Clang diverges from GCC's behavior. addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib/../" + - OSLibDir + Multilib.osSuffix(), + OSLibDir + SelectedMultilib.osSuffix(), Paths); // If the GCC installation we found is inside of the sysroot, we want to diff --git a/clang/test/Driver/print-multi-directory.c b/clang/test/Driver/print-multi-directory.c new file mode 100644 index 00000000000..31b167fbab2 --- /dev/null +++ b/clang/test/Driver/print-multi-directory.c @@ -0,0 +1,30 @@ +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target i386-none-linux \ +// RUN: -B%S/Inputs/multilib_64bit_linux_tree/usr \ +// RUN: -print-multi-directory \ +// RUN: | FileCheck --check-prefix=CHECK-X86-MULTILIBS %s + +// CHECK-X86-MULTILIBS: 32 +// CHECK-X86-MULTILIBS-NOT: x32 +// CHECK-X86-MULTILIBS-NOT: . + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target i386-none-linux -m64 \ +// RUN: -B%S/Inputs/multilib_64bit_linux_tree/usr \ +// RUN: -print-multi-directory \ +// RUN: | FileCheck --check-prefix=CHECK-X86_64-MULTILIBS %s + +// CHECK-X86_64-MULTILIBS: . +// CHECK-X86_64-MULTILIBS-NOT: x32 +// CHECK-X86_64-MULTILIBS-NOT: 32 + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi21 \ +// RUN: -mthumb \ +// RUN: -B%S/Inputs/basic_android_ndk_tree \ +// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \ +// RUN: -print-multi-directory \ +// RUN: | FileCheck --check-prefix=CHECK-ARM-MULTILIBS %s + +// CHECK-ARM-MULTILIBS: thumb +// CHECK-ARM-MULTILIBS-NOT: . |

