From ec770aa22803b894b11d8275e665ec8c29a2a5ce Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Wed, 12 Jul 2017 21:03:54 +0000 Subject: [PATCH] Revert "[Driver] Update Fuchsia driver path handling" The tests are failing on Windows. This reverts commit 429fe8229496f639df6b0b4734beedb1d4317aa5. llvm-svn: 307845 --- clang/lib/Driver/ToolChains/Fuchsia.cpp | 79 ++++++--------------------------- clang/lib/Driver/ToolChains/Fuchsia.h | 20 ++------- clang/test/Driver/fuchsia.cpp | 3 +- 3 files changed, 18 insertions(+), 84 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp index c9937fd..313c748 100644 --- a/clang/lib/Driver/ToolChains/Fuchsia.cpp +++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp @@ -131,44 +131,16 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA, /// Fuchsia - Fuchsia tool chain which can call as(1) and ld(1) directly. -static std::string computeTriple(llvm::Triple Triple) { - SmallString<64> T; - T += Triple.getArchName(); - T += "-"; - T += Triple.getOSName(); - return T.str(); -} - -static std::string getTargetDir(const Driver &D, - llvm::Triple Triple) { - SmallString<128> P(llvm::sys::path::parent_path(D.Dir)); - llvm::sys::path::append(P, "lib", computeTriple(Triple)); - return P.str(); -} - Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) - : ToolChain(D, Triple, Args) { - getProgramPaths().push_back(getDriver().getInstalledDir()); - if (getDriver().getInstalledDir() != D.Dir) - getProgramPaths().push_back(D.Dir); - - SmallString<128> P(getTargetDir(D, getTriple())); - llvm::sys::path::append(P, "lib"); - getFilePaths().push_back(P.str()); - - if (!D.SysRoot.empty()) { - SmallString<128> P(D.SysRoot); - llvm::sys::path::append(P, "lib"); - getFilePaths().push_back(P.str()); - } + : Generic_ELF(D, Triple, Args) { + + getFilePaths().push_back(D.SysRoot + "/lib"); + getFilePaths().push_back(D.ResourceDir + "/lib/fuchsia"); } -std::string Fuchsia::ComputeEffectiveClangTriple(const ArgList &Args, - types::ID InputType) const { - llvm::Triple Triple(ComputeLLVMTriple(Args, InputType)); - Triple.setTriple(computeTriple(Triple)); - return Triple.getTriple(); +Tool *Fuchsia::buildAssembler() const { + return new tools::gnutools::Assembler(*this); } Tool *Fuchsia::buildLinker() const { @@ -236,44 +208,19 @@ void Fuchsia::AddClangSystemIncludeArgs(const ArgList &DriverArgs, return; } - if (!D.SysRoot.empty()) { - SmallString<128> P(D.SysRoot); - llvm::sys::path::append(P, "include"); - addExternCSystemInclude(DriverArgs, CC1Args, P.str()); - } + addExternCSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/include"); } -void Fuchsia::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, - ArgStringList &CC1Args) const { - if (DriverArgs.hasArg(options::OPT_nostdlibinc) || - DriverArgs.hasArg(options::OPT_nostdincxx)) - return; - - switch (GetCXXStdlibType(DriverArgs)) { - case ToolChain::CST_Libcxx: { - SmallString<128> P(getTargetDir(getDriver(), getTriple())); - llvm::sys::path::append(P, "include", "c++", "v1"); - addSystemInclude(DriverArgs, CC1Args, P.str()); - break; - } - - default: - llvm_unreachable("invalid stdlib name"); - } +std::string Fuchsia::findLibCxxIncludePath() const { + return getDriver().SysRoot + "/include/c++/v1"; } void Fuchsia::AddCXXStdlibLibArgs(const ArgList &Args, ArgStringList &CmdArgs) const { - switch (GetCXXStdlibType(Args)) { - case ToolChain::CST_Libcxx: - CmdArgs.push_back("-lc++"); - CmdArgs.push_back("-lc++abi"); - CmdArgs.push_back("-lunwind"); - break; - - case ToolChain::CST_Libstdcxx: - llvm_unreachable("invalid stdlib name"); - } + (void) GetCXXStdlibType(Args); + CmdArgs.push_back("-lc++"); + CmdArgs.push_back("-lc++abi"); + CmdArgs.push_back("-lunwind"); } SanitizerMask Fuchsia::getSupportedSanitizers() const { diff --git a/clang/lib/Driver/ToolChains/Fuchsia.h b/clang/lib/Driver/ToolChains/Fuchsia.h index a723a99..cb8d4a5 100644 --- a/clang/lib/Driver/ToolChains/Fuchsia.h +++ b/clang/lib/Driver/ToolChains/Fuchsia.h @@ -35,29 +35,18 @@ public: namespace toolchains { -class LLVM_LIBRARY_VISIBILITY Fuchsia : public ToolChain { +class LLVM_LIBRARY_VISIBILITY Fuchsia : public Generic_ELF { public: Fuchsia(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args); + bool isPIEDefault() const override { return true; } bool HasNativeLLVMSupport() const override { return true; } bool IsIntegratedAssemblerDefault() const override { return true; } - RuntimeLibType GetDefaultRuntimeLibType() const override { - return ToolChain::RLT_CompilerRT; - } - CXXStdlibType GetDefaultCXXStdlibType() const override { - return ToolChain::CST_Libcxx; - } - bool isPICDefault() const override { return false; } - bool isPIEDefault() const override { return true; } - bool isPICDefaultForced() const override { return false; } llvm::DebuggerKind getDefaultDebuggerTuning() const override { return llvm::DebuggerKind::GDB; } - std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args, - types::ID InputType) const override; - SanitizerMask getSupportedSanitizers() const override; RuntimeLibType @@ -71,9 +60,7 @@ public: void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; - void - AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, - llvm::opt::ArgStringList &CC1Args) const override; + std::string findLibCxxIncludePath() const override; void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override; @@ -82,6 +69,7 @@ public: } protected: + Tool *buildAssembler() const override; Tool *buildLinker() const override; }; diff --git a/clang/test/Driver/fuchsia.cpp b/clang/test/Driver/fuchsia.cpp index 78aecef..4490f94 100644 --- a/clang/test/Driver/fuchsia.cpp +++ b/clang/test/Driver/fuchsia.cpp @@ -1,10 +1,9 @@ // RUN: %clangxx %s -### -no-canonical-prefixes --target=x86_64-unknown-fuchsia \ // RUN: --sysroot=%S/platform 2>&1 -fuse-ld=ld | FileCheck %s // CHECK: {{.*}}clang{{.*}}" "-cc1" -// CHECK: "-triple" "x86_64-fuchsia" // CHECK: "-fuse-init-array" // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]" -// CHECK: "-internal-isystem" "{{.*[/\\]}}x86_64-fuchsia{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}v1" +// CHECK: "-internal-isystem" "[[SYSROOT]]{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}v1" // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|\\\\}}include" // CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu" // CHECK: "--sysroot=[[SYSROOT]]" -- 2.7.4