[clang] aeaddf9 - Revert "[RISCV] Use compiler-rt if no GCC installation detected"

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 13 13:21:33 PST 2019


Author: Richard Smith
Date: 2019-11-13T13:14:57-08:00
New Revision: aeaddf926a74814aa4f33050cfc12b19f419f1b0

URL: https://github.com/llvm/llvm-project/commit/aeaddf926a74814aa4f33050cfc12b19f419f1b0
DIFF: https://github.com/llvm/llvm-project/commit/aeaddf926a74814aa4f33050cfc12b19f419f1b0.diff

LOG: Revert "[RISCV] Use compiler-rt if no GCC installation detected"

This change causes test failures for builds configured with
-DCLANG_DEFAULT_RTLIB=compiler-rt.

This reverts commit 3289352e6bb9d2949c678c625478024bf2a5fbfb.

Added: 
    clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtbegin.o
    clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtend.o
    clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtbegin.o
    clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtend.o

Modified: 
    clang/lib/Driver/ToolChains/RISCVToolchain.cpp
    clang/lib/Driver/ToolChains/RISCVToolchain.h
    clang/test/Driver/riscv32-toolchain-extra.c
    clang/test/Driver/riscv64-toolchain-extra.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
index dc478e6a835e..8019940b521f 100644
--- a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -41,16 +41,6 @@ Tool *RISCVToolChain::buildLinker() const {
   return new tools::RISCV::Linker(*this);
 }
 
-ToolChain::RuntimeLibType RISCVToolChain::GetDefaultRuntimeLibType() const {
-  return GCCInstallation.isValid() ?
-    ToolChain::RLT_Libgcc : ToolChain::RLT_CompilerRT;
-}
-
-ToolChain::UnwindLibType
-RISCVToolChain::GetUnwindLibType(const llvm::opt::ArgList &Args) const {
-  return ToolChain::UNW_None;
-}
-
 void RISCVToolChain::addClangTargetOptions(
     const llvm::opt::ArgList &DriverArgs,
     llvm::opt::ArgStringList &CC1Args,
@@ -120,22 +110,9 @@ void RISCV::Linker::ConstructJob(Compilation &C, const JobAction &JA,
   bool WantCRTs =
       !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
 
-  const char *crtbegin, *crtend;
-  auto RuntimeLib = ToolChain.GetRuntimeLibType(Args);
-  if (RuntimeLib == ToolChain::RLT_Libgcc) {
-    crtbegin = "crtbegin.o";
-    crtend = "crtend.o";
-  } else {
-    assert (RuntimeLib == ToolChain::RLT_CompilerRT);
-    crtbegin = ToolChain.getCompilerRTArgString(Args, "crtbegin",
-                                                ToolChain::FT_Object);
-    crtend = ToolChain.getCompilerRTArgString(Args, "crtend",
-                                              ToolChain::FT_Object);
-  }
-
   if (WantCRTs) {
     CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
-    CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
+    CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbegin.o")));
   }
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
@@ -156,11 +133,11 @@ void RISCV::Linker::ConstructJob(Compilation &C, const JobAction &JA,
     CmdArgs.push_back("-lc");
     CmdArgs.push_back("-lgloss");
     CmdArgs.push_back("--end-group");
-    AddRunTimeLibs(ToolChain, ToolChain.getDriver(), CmdArgs, Args);
+    CmdArgs.push_back("-lgcc");
   }
 
   if (WantCRTs)
-    CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtend)));
+    CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o")));
 
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());

diff  --git a/clang/lib/Driver/ToolChains/RISCVToolchain.h b/clang/lib/Driver/ToolChains/RISCVToolchain.h
index bb7f64849bcb..b2b56b066efd 100644
--- a/clang/lib/Driver/ToolChains/RISCVToolchain.h
+++ b/clang/lib/Driver/ToolChains/RISCVToolchain.h
@@ -25,9 +25,6 @@ class LLVM_LIBRARY_VISIBILITY RISCVToolChain : public Generic_ELF {
   void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
                              llvm::opt::ArgStringList &CC1Args,
                              Action::OffloadKind) const override;
-  RuntimeLibType GetDefaultRuntimeLibType() const override;
-  UnwindLibType
-  GetUnwindLibType(const llvm::opt::ArgList &Args) const override;
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
                             llvm::opt::ArgStringList &CC1Args) const override;

diff  --git a/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtbegin.o b/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtbegin.o
new file mode 100644
index 000000000000..e69de29bb2d1

diff  --git a/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtend.o b/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf/lib/crtend.o
new file mode 100644
index 000000000000..e69de29bb2d1

diff  --git a/clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtbegin.o b/clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtbegin.o
new file mode 100644
index 000000000000..e69de29bb2d1

diff  --git a/clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtend.o b/clang/test/Driver/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf/lib/crtend.o
new file mode 100644
index 000000000000..e69de29bb2d1

diff  --git a/clang/test/Driver/riscv32-toolchain-extra.c b/clang/test/Driver/riscv32-toolchain-extra.c
index 4e9ff78943aa..613667213ac8 100644
--- a/clang/test/Driver/riscv32-toolchain-extra.c
+++ b/clang/test/Driver/riscv32-toolchain-extra.c
@@ -22,12 +22,12 @@
 // RUN:    -target riscv32-unknown-elf 2>&1 \
 // RUN:    | FileCheck -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC %s
 
+// C-RV32-BAREMETAL-ILP32-NOGCC: InstalledDir: [[DRIVERDIR:.*]]
 // C-RV32-BAREMETAL-ILP32-NOGCC: "-fuse-init-array"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "-internal-isystem" "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/include"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/lib/crt0.o"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtbegin-riscv32.o"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/lib"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/libclang_rt.builtins-riscv32.a"
-// C-RV32-BAREMETAL-ILP32-NOGCC: "{{.*}}Output/testroot-riscv32-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtend-riscv32.o"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "-internal-isystem" "[[DRIVERDIR]]/../riscv32-unknown-elf/include"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/riscv32-unknown-elf-ld"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/../riscv32-unknown-elf/lib/crt0.o"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/../riscv32-unknown-elf/lib/crtbegin.o"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "-L[[DRIVERDIR]]/../riscv32-unknown-elf/lib"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
+// C-RV32-BAREMETAL-ILP32-NOGCC: "[[DRIVERDIR]]/../riscv32-unknown-elf/lib/crtend.o"

diff  --git a/clang/test/Driver/riscv64-toolchain-extra.c b/clang/test/Driver/riscv64-toolchain-extra.c
index b138fbfb7415..79a6c9a86e5c 100644
--- a/clang/test/Driver/riscv64-toolchain-extra.c
+++ b/clang/test/Driver/riscv64-toolchain-extra.c
@@ -22,12 +22,12 @@
 // RUN:    -target riscv64-unknown-elf 2>&1 \
 // RUN:    | FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
+// C-RV64-BAREMETAL-LP64-NOGCC: InstalledDir: [[DRIVERDIR:.*]]
 // C-RV64-BAREMETAL-LP64-NOGCC: "-fuse-init-array"
-// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/include"
-// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld"
-// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtbegin-riscv64.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib"
-// C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group"
-// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/libclang_rt.builtins-riscv64.a"
-// C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/lib/clang/{{[0-9.]*}}/lib/clang_rt.crtend-riscv64.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" "[[DRIVERDIR]]/../riscv64-unknown-elf/include"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crt0.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crtbegin.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: "-L[[DRIVERDIR]]/../riscv64-unknown-elf/lib"
+// C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
+// C-RV64-BAREMETAL-LP64-NOGCC: "[[DRIVERDIR]]/../riscv64-unknown-elf/lib/crtend.o"


        


More information about the cfe-commits mailing list