llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Garvit Gupta (quic-garvgupt) <details> <summary>Changes</summary> GCCInstallation.(2/3) This patch adds the defaults for CXXSstdlib type and other runtime libs. Additionally, this patch also modifes the linker job and extend it to support for GCCInstallation. This is the second PR in the series of 3 PRs for merging and extending Baremetal toolchain object. The division of the PRs is as follows: - Teach Baremetal toolchain about GCC installation and make sysroot and assembler related changes. - Changes related to linker job and defaults for CXXStdlib and other runtime libs. - Finally removing the call to RISCVToolchain object. RFC: https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524 Change-Id: I8fdb3490a3888001b1bb999e7ee8df90a187d18d --- Patch is 51.75 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/121830.diff 9 Files Affected: - (modified) clang/lib/Driver/ToolChains/BareMetal.cpp (+86-24) - (modified) clang/lib/Driver/ToolChains/BareMetal.h (+13-8) - (modified) clang/test/Driver/aarch64-toolchain-extra.c (+7-1) - (modified) clang/test/Driver/aarch64-toolchain.c (+74-1) - (modified) clang/test/Driver/arm-toolchain-extra.c (+6) - (modified) clang/test/Driver/arm-toolchain.c (+75-2) - (modified) clang/test/Driver/baremetal-multilib.yaml (+1-1) - (modified) clang/test/Driver/baremetal-sysroot.cpp (+1-1) - (modified) clang/test/Driver/baremetal.cpp (+39-38) ``````````diff diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp index 7b0f2bc2fd3895..38de25e20ea8df 100644 --- a/clang/lib/Driver/ToolChains/BareMetal.cpp +++ b/clang/lib/Driver/ToolChains/BareMetal.cpp @@ -172,6 +172,8 @@ BareMetal::BareMetal(const Driver &D, const llvm::Triple &Triple, : Generic_ELF(D, Triple, Args) { GCCInstallation.init(Triple, Args); SysRoot = computeSysRoot(); + UseLD = + Args.getLastArgValue(options::OPT_fuse_ld_EQ).equals_insensitive("ld"); if (GCCInstallation.isValid()) { Multilibs = GCCInstallation.getMultilibs(); SelectedMultilibs.assign({GCCInstallation.getMultilib()}); @@ -342,6 +344,32 @@ BareMetal::OrderedMultilibs BareMetal::getOrderedMultilibs() const { return llvm::reverse(Default); } +ToolChain::CXXStdlibType BareMetal::GetDefaultCXXStdlibType() const { + if (getTriple().isRISCV() && GCCInstallation.isValid()) + return ToolChain::CST_Libstdcxx; + return ToolChain::CST_Libcxx; +} + +ToolChain::RuntimeLibType BareMetal::GetDefaultRuntimeLibType() const { + if (getTriple().isRISCV() && GCCInstallation.isValid()) + return ToolChain::RLT_Libgcc; + return ToolChain::RLT_CompilerRT; +} + +ToolChain::UnwindLibType +BareMetal::GetUnwindLibType(const llvm::opt::ArgList &Args) const { + if (getTriple().isRISCV()) + return ToolChain::UNW_None; + + return ToolChain::GetUnwindLibType(Args); +} + +const char *BareMetal::getDefaultLinker() const { + if (isUsingLD()) + return "ld"; + return "ld.lld"; +} + void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs, ArgStringList &CC1Args) const { if (DriverArgs.hasArg(options::OPT_nostdinc)) @@ -535,12 +563,21 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA, const llvm::Triple::ArchType Arch = TC.getArch(); const llvm::Triple &Triple = getToolChain().getEffectiveTriple(); - AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA); + if (!D.SysRoot.empty()) + CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot)); CmdArgs.push_back("-Bstatic"); - if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax)) - CmdArgs.push_back("--no-relax"); + if (Triple.isRISCV()) { + if (Args.hasArg(options::OPT_mno_relax)) + CmdArgs.push_back("--no-relax"); + if (TC.isUsingLD()) { + CmdArgs.push_back("-m"); + CmdArgs.push_back(Arch == llvm::Triple::riscv64 ? "elf64lriscv" + : "elf32lriscv"); + } + CmdArgs.push_back("-X"); + } if (Triple.isARM() || Triple.isThumb()) { bool IsBigEndian = arm::isARMBigEndian(Triple, Args); @@ -551,19 +588,54 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL"); } - if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles, - options::OPT_r)) { - CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o"))); + bool WantCRTs = + !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles); + + const char *crtbegin, *crtend; + if (WantCRTs) { + if (!Args.hasArg(options::OPT_r)) + CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o"))); + if (TC.isUsingLD()) { + auto RuntimeLib = TC.GetRuntimeLibType(Args); + if (RuntimeLib == ToolChain::RLT_Libgcc) { + crtbegin = "crtbegin.o"; + crtend = "crtend.o"; + } else { + assert(RuntimeLib == ToolChain::RLT_CompilerRT); + crtbegin = + TC.getCompilerRTArgString(Args, "crtbegin", ToolChain::FT_Object); + crtend = + TC.getCompilerRTArgString(Args, "crtend", ToolChain::FT_Object); + } + CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(crtbegin))); + } } - Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group, - options::OPT_s, options::OPT_t, options::OPT_r}); + Args.addAllArgs(CmdArgs, + {options::OPT_L, options::OPT_u, options::OPT_T_Group, + options::OPT_s, options::OPT_t, options::OPT_r}); TC.AddFilePathLibArgs(Args, CmdArgs); for (const auto &LibPath : TC.getLibraryPaths()) CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-L", LibPath))); + if (D.isUsingLTO()) { + assert(!Inputs.empty() && "Must have at least one input."); + // Find the first filename InputInfo object. + auto Input = llvm::find_if( + Inputs, [](const InputInfo &II) -> bool { return II.isFilename(); }); + if (Input == Inputs.end()) + // For a very rare case, all of the inputs to the linker are + // InputArg. If that happens, just use the first InputInfo. + Input = Inputs.begin(); + + addLTOOptions(TC, Args, CmdArgs, Output, *Input, + D.getLTOMode() == LTOK_Thin); + } + + AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA); + if (TC.ShouldLinkCXXStdlib(Args)) { bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) && !Args.hasArg(options::OPT_static); @@ -576,26 +648,16 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA, } if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { + CmdArgs.push_back("--start-group"); AddRunTimeLibs(TC, D, CmdArgs, Args); - CmdArgs.push_back("-lc"); + if (TC.isUsingLD()) + CmdArgs.push_back("-lgloss"); + CmdArgs.push_back("--end-group"); } - if (D.isUsingLTO()) { - assert(!Inputs.empty() && "Must have at least one input."); - // Find the first filename InputInfo object. - auto Input = llvm::find_if( - Inputs, [](const InputInfo &II) -> bool { return II.isFilename(); }); - if (Input == Inputs.end()) - // For a very rare case, all of the inputs to the linker are - // InputArg. If that happens, just use the first InputInfo. - Input = Inputs.begin(); - - addLTOOptions(TC, Args, CmdArgs, Output, *Input, - D.getLTOMode() == LTOK_Thin); - } - if (TC.getTriple().isRISCV()) - CmdArgs.push_back("-X"); + if (TC.isUsingLD() && WantCRTs) + CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(crtend))); // The R_ARM_TARGET2 relocation must be treated as R_ARM_REL32 on arm*-*-elf // and arm*-*-eabi (the default is R_ARM_GOT_PREL, used on arm*-*-linux and diff --git a/clang/lib/Driver/ToolChains/BareMetal.h b/clang/lib/Driver/ToolChains/BareMetal.h index de3b1b267c8e7c..738f59ab64b414 100644 --- a/clang/lib/Driver/ToolChains/BareMetal.h +++ b/clang/lib/Driver/ToolChains/BareMetal.h @@ -36,6 +36,7 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF { Tool *buildStaticLibTool() const override; public: + virtual bool isUsingLD() const { return UseLD || GCCInstallation.isValid(); } bool isBareMetal() const override { return true; } bool isCrossCompiling() const override { return true; } bool HasNativeLLVMSupport() const override { return true; } @@ -48,14 +49,18 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF { StringRef getOSLibName() const override { return "baremetal"; } - RuntimeLibType GetDefaultRuntimeLibType() const override { - return ToolChain::RLT_CompilerRT; - } - CXXStdlibType GetDefaultCXXStdlibType() const override { - return ToolChain::CST_Libcxx; + UnwindTableLevel + getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override { + return UnwindTableLevel::None; } - const char *getDefaultLinker() const override { return "ld.lld"; } + CXXStdlibType GetDefaultCXXStdlibType() const override; + + RuntimeLibType GetDefaultRuntimeLibType() const override; + + UnwindLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const override; + + const char *getDefaultLinker() const override; void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, @@ -77,7 +82,7 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF { using OrderedMultilibs = llvm::iterator_range<llvm::SmallVector<Multilib>::const_reverse_iterator>; OrderedMultilibs getOrderedMultilibs() const; - + bool UseLD; std::string SysRoot; std::string computeGCCSysRoot() const; }; @@ -103,7 +108,7 @@ class LLVM_LIBRARY_VISIBILITY StaticLibTool : public Tool { class LLVM_LIBRARY_VISIBILITY Linker final : public Tool { public: - Linker(const ToolChain &TC) : Tool("baremetal::Linker", "ld.lld", TC) {} + Linker(const ToolChain &TC) : Tool("baremetal::Linker", "linker", TC) {} bool isLinkJob() const override { return true; } bool hasIntegratedCPP() const override { return false; } void ConstructJob(Compilation &C, const JobAction &JA, diff --git a/clang/test/Driver/aarch64-toolchain-extra.c b/clang/test/Driver/aarch64-toolchain-extra.c index c4e05fd5d10436..1fa61ca9cdb28c 100644 --- a/clang/test/Driver/aarch64-toolchain-extra.c +++ b/clang/test/Driver/aarch64-toolchain-extra.c @@ -25,4 +25,10 @@ // RUN: --target=aarch64-none-elf --rtlib=libgcc -fuse-ld=ld 2>&1 \ // RUN: | FileCheck -check-prefix=C-ARM-BAREMETAL-NOGCC %s -// C-ARM-BAREMETAL-NOGCC: "-internal-isystem" "{{.*}}/aarch64-nogcc/bin/../aarch64-none-elf/include" \ No newline at end of file +// C-ARM-BAREMETAL-NOGCC: "-internal-isystem" "{{.*}}/aarch64-nogcc/bin/../aarch64-none-elf/include" +// C-ARM-BAREMETAL-NOGCC: "{{.*}}/ld" +// C-ARM-BAREMETAL-NOGCC: "{{.*}}/aarch64-nogcc/bin/../aarch64-none-elf/lib/crt0.o" +// C-ARM-BAREMETAL-NOGCC: "{{.*}}/aarch64-nogcc/{{.*}}/aarch64-none-elf/lib/crtbegin.o" +// C-ARM-BAREMETAL-NOGCC: "{{.*}}/aarch64-nogcc/bin/../aarch64-none-elf/lib" +// C-ARM-BAREMETAL-NOGCC: "--start-group" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgloss" "--end-group" +// C-ARM-BAREMETAL-NOGCC: "{{.*}}/aarch64-nogcc/{{.*}}/aarch64-none-elf/lib/crtend.o" \ No newline at end of file diff --git a/clang/test/Driver/aarch64-toolchain.c b/clang/test/Driver/aarch64-toolchain.c index b850e0fe8954e2..106869d98b9c4c 100644 --- a/clang/test/Driver/aarch64-toolchain.c +++ b/clang/test/Driver/aarch64-toolchain.c @@ -9,6 +9,14 @@ // C-AARCH64-BAREMETAL: "-cc1" "-triple" "aarch64-unknown-none-elf" // C-AARCH64-BAREMETAL: "-isysroot" "{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf" // C-AARCH64-BAREMETAL: "-internal-isystem" "{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include" +// C-AARCH64-BAREMETAL: "{{.*}}/ld" "--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf" +// C-AARCH64-BAREMETAL: "-Bstatic" "-EL" +// C-AARCH64-BAREMETAL: "{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/crt0.o" +// C-AARCH64-BAREMETAL: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o" +// C-AARCH64-BAREMETAL: "-L{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1" +// C-AARCH64-BAREMETAL: "-L{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib" +// C-AARCH64-BAREMETAL: "--start-group" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgloss" "--end-group" +// C-AARCH64-BAREMETAL: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtend.o" // RUN: %clang -### %s -fuse-ld= \ // RUN: --target=aarch64-none-elf --rtlib=libgcc \ @@ -18,6 +26,13 @@ // C-AARCH64-BAREMETAL-NOSYSROOT: "-cc1" "-triple" "aarch64-unknown-none-elf" // C-AARCH64-BAREMETAL-NOSYSROOT: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/include" +// C-AARCH64-BAREMETAL-NOSYSROOT: "{{.*}}/ld" "-Bstatic" "-EL" +// C-AARCH64-BAREMETAL-NOSYSROOT: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/lib/crt0.o" +// C-AARCH64-BAREMETAL-NOSYSROOT: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o" +// C-AARCH64-BAREMETAL-NOSYSROOT: "-L{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1" +// C-AARCH64-BAREMETAL-NOSYSROOT: "-L{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/lib" +// C-AARCH64-BAREMETAL-NOSYSROOT: "--start-group" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgloss" "--end-group" +// C-AARCH64-BAREMETAL-NOSYSROOT: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtend.o" // RUN: %clangxx -### %s -fuse-ld= \ // RUN: --target=aarch64-none-elf -stdlib=libstdc++ --rtlib=libgcc \ @@ -29,6 +44,14 @@ // CXX-AARCH64-BAREMETAL: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/8.2.1/backward" // CXX-AARCH64-BAREMETAL: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/8.2.1" // CXX-AARCH64-BAREMETAL: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include" +// CXX-AARCH64-BAREMETAL: "{{.*}}/ld" "--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf" +// CXX-AARCH64-BAREMETAL: "-Bstatic" "-EL" +// CXX-AARCH64-BAREMETAL: "{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/crt0.o" +// CXX-AARCH64-BAREMETAL: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o" +// CXX-AARCH64-BAREMETAL: "-L{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1" +// CXX-AARCH64-BAREMETAL: "-L{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib" +// CXX-AARCH64-BAREMETAL: "-lstdc++" "-lm" "--start-group" "-lgcc_s" "-lgcc" "-lc" "-lgloss" "--end-group" +// CXX-AARCH64-BAREMETAL: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtend.o" // RUN: %clangxx -### %s -fuse-ld= \ // RUN: --target=aarch64-none-elf -stdlib=libstdc++ --rtlib=libgcc \ @@ -40,6 +63,13 @@ // CXX-AARCH64-BAREMETAL-NOSYSROOT: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/include/c++/8.2.1/backward" // CXX-AARCH64-BAREMETAL-NOSYSROOT: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/include/c++/8.2.1" // CXX-AARCH64-BAREMETAL-NOSYSROOT: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/include" +// CXX-AARCH64-BAREMETAL-NOSYSROOT: "{{.*}}/ld" "-Bstatic" "-EL" +// CXX-AARCH64-BAREMETAL-NOSYSROOT: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/lib/crt0.o" +// CXX-AARCH64-BAREMETAL-NOSYSROOT: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o" +// CXX-AARCH64-BAREMETAL-NOSYSROOT: "-L{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1" +// CXX-AARCH64-BAREMETAL-NOSYSROOT: "-L{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/lib" +// CXX-AARCH64-BAREMETAL-NOSYSROOT: "-lstdc++" "-lm" "--start-group" "-lgcc_s" "-lgcc" "-lc" "-lgloss" "--end-group" +// CXX-AARCH64-BAREMETAL-NOSYSROOT: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtend.o" // RUN: %clangxx -### %s -fuse-ld= \ // RUN: --target=aarch64-none-elf -stdlib=libc++ --rtlib=libgcc \ @@ -50,6 +80,14 @@ // CXX-AARCH64-BAREMETAL-LIBCXX: "-isysroot" "{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf" // CXX-AARCH64-BAREMETAL-LIBCXX: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/v1" // CXX-AARCH64-BAREMETAL-LIBCXX: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include" +// CXX-AARCH64-BAREMETAL-LIBCXX: "{{.*}}/ld" "--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf" +// CXX-AARCH64-BAREMETAL-LIBCXX: "-Bstatic" "-EL" +// CXX-AARCH64-BAREMETAL-LIBCXX: "{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/crt0.o" +// CXX-AARCH64-BAREMETAL-LIBCXX: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o" +// CXX-AARCH64-BAREMETAL-LIBCXX: "-L{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1" +// CXX-AARCH64-BAREMETAL-LIBCXX: "-L{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib" +// CXX-AARCH64-BAREMETAL-LIBCXX: "-lc++" "-lm" "--start-group" "-lgcc_s" "-lgcc" "-lc" "-lgloss" "--end-group" +// CXX-AARCH64-BAREMETAL-LIBCXX: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtend.o" // RUN: %clangxx -### %s -fuse-ld= \ // RUN: --target=aarch64-none-elf -stdlib=libc++ --rtlib=libgcc \ @@ -58,4 +96,39 @@ // RUN: | FileCheck -check-prefix=CXX-AARCH64-BAREMETAL-NOSYSROOT-LIBCXX %s // CXX-AARCH64-BAREMETAL-NOSYSROOT-LIBCXX: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/include/c++/v1" -// CXX-AARCH64-BAREMETAL-NOSYSROOT-LIBCXX: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/include" \ No newline at end of file +// CXX-AARCH64-BAREMETAL-NOSYSROOT-LIBCXX: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/include" +// CXX-AARCH64-BAREMETAL-NOSYSROOT-LIBCXX: "{{.*}}/ld" "-Bstatic" "-EL" +// CXX-AARCH64-BAREMETAL-NOSYSROOT-LIBCXX: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/lib/crt0.o" +// CXX-AARCH64-BAREMETAL-NOSYSROOT-LIBCXX: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o" +// CXX-AARCH64-BAREMETAL-NOSYSROOT-LIBCXX: "-L{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1" +// CXX-AARCH64-BAREMETAL-NOSYSROOT-LIBCXX: "-L{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/lib" +// CXX-AARCH64-BAREMETAL-NOSYSROOT-LIBCXX: "-lc++" "-lm" "--start-group" "-lgcc_s" "-lgcc" "-lc" "-lgloss" "--end-group" +// CXX-AARCH64-BAREMETAL-NOSYSROOT-LIBCXX: "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtend.o" + +// RUN: %clang -### %s -fuse-ld= \ +// RUN: --target=aarch64-none-elf --rtlib=compiler-rt \ +// RUN: --gcc-toolchain=%S/Inputs/basic_aarch64_gcc_tree \ +// RUN: --sysroot=%S/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf 2>&1 \ +// RUN: | FileCheck -check-prefix=AARCH64-BAREMETAL-COMPILER-RT %s + +// AARCH64-BAREMETAL-COMPILER-RT: "{{.*}}crt0.o" +// AARCH64-BAREMETAL-COMPILER-RT: "{{.*}}clang_rt.crtbegin.o" +// AARCH64-BAREMETAL-COMPILER-RT: "--start-group" "{{.*}}libclang_rt.builtins.a" "-lc" "-lgloss" "--end-group" +// AARCH64-BAREMETAL-COMPILER-RT: "{{.*}}clang_rt.crtend.o" + +// RUN: %clang -### %s -fuse-ld= \ +// RUN: --target=aarch64-none-elf --unwindlib=libunwind \ +// RUN: --gcc-toolchain=%S/Inputs/basic_aarch64_gcc_tree \ +// RUN: --sysroot=%S/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf 2>&1 \ +// RUN: | FileCheck -check-prefix=AARCH64-BAREMETAL-UNWINDLIB %s + +// RUN: %clang -### %s -fuse-ld= \ +// RUN: --target=aarch64-none-elf --rtlib=compiler-rt --unwindlib=libunwind \ +// RUN: --gcc-toolchain=%S/Inputs/basic_aarch64_gcc_tree \ +// RUN: --sysroot=%S/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf 2>&1 \ +// RUN: | FileCheck -check-prefix=AARCH64-BAREMETAL-UNWINDLIB %s + +// AARCH64-BAREMETAL-UNWINDLIB: "{{.*}}crt0.o" +// AARCH64-BAREMETAL-UNWINDLIB: "{{.*}}clang_rt.crtbegin.o" +// AARCH64-BAREMETAL-UNWINDLIB: "--start-group" "{{.*}}libclang_rt.builtins.a" "--as-needed" "-lunwind" "--no-as-needed" "-lc" "-lgloss" "--end-group" +// AARCH64-BAREMETAL-UNWINDLIB: "{{.*}}clang_rt.crtend.o" \ No newline at end of file diff --git a/clang/test/Driver/arm-toolchain-extra.c b/clang/test/Driver/arm-toolchain-extra.c index cd1b76bdb08661..28eb9e7c850319 100644 --- a/clang/test/Driver/arm-toolchain-extra.c +++ b/clang/test/Driver/arm-toolchain-extra.c @@ -26,3 +26,9 @@ // RUN: | FileCheck -check-prefix=C-ARM-BAREMETAL-NOGCC %s // C-ARM-BAREMETAL-NOGCC: "-internal-isystem" "{{.*}}/arm-nogcc/bin/../armv6m-none-eabi/include" +// C-ARM-BAREMETAL-NOGCC: "{{.*}}/ld" +// C-ARM-BAREMETAL-NOGCC: "{{.*}}/arm-nogcc/bin/../armv6m-none-eabi/lib/crt0.o" +// C-ARM-BAREMETAL-NOGCC: "{{.*}}/arm-nogcc/{{.*}}/armv6m-none-eabi/lib/crtbegin.o" +// C-ARM-BAREMETAL-NOGCC: "{{.*}}/arm-nogcc/bin/../armv6m-none-eabi/lib" +// C-ARM-BAREMETAL-NOGCC: "--start-group" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgloss" "--end-group" +// C-ARM-BAREMETAL-NOGCC: "{{.*}}/arm-nogcc/{{.*}}/armv6m-none-eabi/lib/crtend.o \ No newline... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/121830 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits