[cfe-commits] [PATCH] [3/6] Hexagon TC: Reimplement Link::ConstructJob to call linker directly
Matthew Curtis
mcurtis at codeaurora.org
Fri Nov 16 11:05:03 PST 2012
Refreshing patch against current trunk.
Matthew Curtis.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
-------------- next part --------------
>From fcb0b7af9261335d2fb475c676affbcb4579f106 Mon Sep 17 00:00:00 2001
From: Matthew Curtis <mcurtis at codeaurora.org>
Date: Fri, 14 Sep 2012 13:14:24 -0500
Subject: [PATCH 3/6] Hexagon TC: Reimplement Link::ConstructJob to call
linker directly
Rather than calling gcc.
---
include/clang/Driver/Options.td | 1 +
lib/Driver/ToolChains.cpp | 82 +++++-
lib/Driver/ToolChains.h | 1 +
lib/Driver/Tools.cpp | 182 ++++++++---
test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-ld | 1 +
test/Driver/hexagon-toolchain.c | 334 +++++++++++++++++++-
6 files changed, 550 insertions(+), 51 deletions(-)
create mode 100755 test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-ld
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
index 77ba17a..5dca961 100644
--- a/include/clang/Driver/Options.td
+++ b/include/clang/Driver/Options.td
@@ -835,6 +835,7 @@ def mno_warn_nonportable_cfstrings : Flag<["-"], "mno-warn-nonportable-cfstrings
def mno_omit_leaf_frame_pointer : Flag<["-"], "mno-omit-leaf-frame-pointer">, Group<m_Group>;
def momit_leaf_frame_pointer : Flag<["-"], "momit-leaf-frame-pointer">, Group<m_Group>,
HelpText<"Omit frame pointer setup for leaf functions">, Flags<[CC1Option]>;
+def moslib_EQ : Joined<["-"], "moslib=">, Group<m_Group>;
def mpascal_strings : Flag<["-"], "mpascal-strings">, Group<m_Group>;
def mred_zone : Flag<["-"], "mred-zone">, Group<m_Group>;
def mregparm_EQ : Joined<["-"], "mregparm=">, Group<m_Group>;
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index f257b2b..ec0a145 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -1421,6 +1421,57 @@ std::string Hexagon_TC::GetGnuDir(const std::string &InstalledDir) {
return InstallRelDir;
}
+static void GetHexagonLibraryPaths(
+ const ArgList &Args,
+ const std::string Ver,
+ const std::string MarchString,
+ const std::string &InstalledDir,
+ ToolChain::path_list *LibPaths)
+{
+ bool buildingLib = Args.hasArg(options::OPT_shared);
+
+ //----------------------------------------------------------------------------
+ // -L Args
+ //----------------------------------------------------------------------------
+ for (arg_iterator
+ it = Args.filtered_begin(options::OPT_L),
+ ie = Args.filtered_end();
+ it != ie;
+ ++it) {
+ for (unsigned i = 0, e = (*it)->getNumValues(); i != e; ++i)
+ LibPaths->push_back((*it)->getValue(i));
+ }
+
+ //----------------------------------------------------------------------------
+ // Other standard paths
+ //----------------------------------------------------------------------------
+ const std::string MarchSuffix = "/" + MarchString;
+ const std::string G0Suffix = "/G0";
+ const std::string MarchG0Suffix = MarchSuffix + G0Suffix;
+ const std::string RootDir = Hexagon_TC::GetGnuDir(InstalledDir) + "/";
+
+ // lib/gcc/hexagon/...
+ std::string LibGCCHexagonDir = RootDir + "lib/gcc/hexagon/";
+ if (buildingLib) {
+ LibPaths->push_back(LibGCCHexagonDir + Ver + MarchG0Suffix);
+ LibPaths->push_back(LibGCCHexagonDir + Ver + G0Suffix);
+ }
+ LibPaths->push_back(LibGCCHexagonDir + Ver + MarchSuffix);
+ LibPaths->push_back(LibGCCHexagonDir + Ver);
+
+ // lib/gcc/...
+ LibPaths->push_back(RootDir + "lib/gcc");
+
+ // hexagon/lib/...
+ std::string HexagonLibDir = RootDir + "hexagon/lib";
+ if (buildingLib) {
+ LibPaths->push_back(HexagonLibDir + MarchG0Suffix);
+ LibPaths->push_back(HexagonLibDir + G0Suffix);
+ }
+ LibPaths->push_back(HexagonLibDir + MarchSuffix);
+ LibPaths->push_back(HexagonLibDir);
+}
+
Hexagon_TC::Hexagon_TC(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
: Linux(D, Triple, Args) {
@@ -1444,6 +1495,20 @@ Hexagon_TC::Hexagon_TC(const Driver &D, const llvm::Triple &Triple,
MaxVersion = cv;
}
GCCLibAndIncVersion = MaxVersion;
+
+ ToolChain::path_list *LibPaths= &getFilePaths();
+
+ // Remove paths added by Linux toolchain. Currently Hexagon_TC really targets
+ // 'elf' OS type, so the Linux paths are not appropriate. When we actually
+ // support 'linux' we'll need to fix this up
+ LibPaths->clear();
+
+ GetHexagonLibraryPaths(
+ Args,
+ GetGCCLibAndIncVersion(),
+ GetTargetCPU(Args),
+ InstalledDir,
+ LibPaths);
}
Hexagon_TC::~Hexagon_TC() {
@@ -1531,7 +1596,22 @@ void Hexagon_TC::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
addSystemInclude(DriverArgs, CC1Args, IncludeDir.str());
}
-static Arg *GetLastHexagonArchArg (const ArgList &Args)
+ToolChain::CXXStdlibType
+Hexagon_TC::GetCXXStdlibType(const ArgList &Args) const {
+ Arg *A = Args.getLastArg(options::OPT_stdlib_EQ);
+ if (!A)
+ return ToolChain::CST_Libstdcxx;
+
+ StringRef Value = A->getValue();
+ if (Value != "libstdc++") {
+ getDriver().Diag(diag::err_drv_invalid_stdlib_name)
+ << A->getAsString(Args);
+ }
+
+ return ToolChain::CST_Libstdcxx;
+}
+
+static Arg *GetLastHexagonArchArg(const ArgList &Args)
{
Arg *A = NULL;
diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h
index f505a00..cc4de6c 100644
--- a/lib/Driver/ToolChains.h
+++ b/lib/Driver/ToolChains.h
@@ -528,6 +528,7 @@ public:
ArgStringList &CC1Args) const;
virtual void AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const;
+ virtual CXXStdlibType GetCXXStdlibType(const ArgList &Args) const;
StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 2c6227d..36b5191 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -3497,68 +3497,158 @@ void hexagon::Link::ConstructJob(Compilation &C, const JobAction &JA,
const ArgList &Args,
const char *LinkingOutput) const {
- const Driver &D = getToolChain().getDriver();
+ const toolchains::Hexagon_TC& ToolChain =
+ static_cast<const toolchains::Hexagon_TC&>(getToolChain());
+ const Driver &D = ToolChain.getDriver();
+
ArgStringList CmdArgs;
- for (ArgList::const_iterator
- it = Args.begin(), ie = Args.end(); it != ie; ++it) {
- Arg *A = *it;
- if (forwardToGCC(A->getOption())) {
- // Don't forward any -g arguments to assembly steps.
- if (isa<AssembleJobAction>(JA) &&
- A->getOption().matches(options::OPT_g_Group))
- continue;
+ //----------------------------------------------------------------------------
+ //
+ //----------------------------------------------------------------------------
+ bool hasStaticArg = Args.hasArg(options::OPT_static);
+ bool buildingLib = Args.hasArg(options::OPT_shared);
+ bool incStdLib = !Args.hasArg(options::OPT_nostdlib);
+ bool incStartFiles = !Args.hasArg(options::OPT_nostartfiles);
+ bool incDefLibs = !Args.hasArg(options::OPT_nodefaultlibs);
+ bool useShared = buildingLib && !hasStaticArg;
+
+ //----------------------------------------------------------------------------
+ // Silence warnings for various options
+ //----------------------------------------------------------------------------
- // It is unfortunate that we have to claim here, as this means
- // we will basically never report anything interesting for
- // platforms using a generic gcc, even if we are just using gcc
- // to get to the assembler.
- A->claim();
- A->render(Args, CmdArgs);
- }
- }
+ Args.ClaimAllArgs(options::OPT_g_Group);
+ Args.ClaimAllArgs(options::OPT_emit_llvm);
+ Args.ClaimAllArgs(options::OPT_w); // Other warning options are already
+ // handled somewhere else.
+ Args.ClaimAllArgs(options::OPT_static_libgcc);
- RenderExtraToolArgs(JA, CmdArgs);
+ //----------------------------------------------------------------------------
+ //
+ //----------------------------------------------------------------------------
+ for (std::vector<std::string>::const_iterator i = ToolChain.ExtraOpts.begin(),
+ e = ToolChain.ExtraOpts.end();
+ i != e; ++i)
+ CmdArgs.push_back(i->c_str());
std::string MarchString = toolchains::Hexagon_TC::GetTargetCPU(Args);
CmdArgs.push_back(Args.MakeArgString("-m" + MarchString));
- CmdArgs.push_back("-mqdsp6-compat");
+ if (buildingLib) {
+ CmdArgs.push_back("-shared");
+ CmdArgs.push_back("-call_shared"); // should be the default, but doing as
+ // hexagon-gcc does
+ }
- const char *GCCName;
- if (C.getDriver().CCCIsCXX)
- GCCName = "hexagon-g++";
- else
- GCCName = "hexagon-gcc";
- const char *Exec =
- Args.MakeArgString(getToolChain().GetProgramPath(GCCName));
+ if (hasStaticArg)
+ CmdArgs.push_back("-static");
- if (Output.isFilename()) {
- CmdArgs.push_back("-o");
- CmdArgs.push_back(Output.getFilename());
+ //----------------------------------------------------------------------------
+ //
+ //----------------------------------------------------------------------------
+ CmdArgs.push_back("-o");
+ CmdArgs.push_back(Output.getFilename());
+
+ const std::string MarchSuffix = "/" + MarchString;
+ const std::string G0Suffix = "/G0";
+ const std::string MarchG0Suffix = MarchSuffix + G0Suffix;
+ const std::string RootDir = toolchains::Hexagon_TC::GetGnuDir(D.InstalledDir)
+ + "/";
+ const std::string StartFilesDir = RootDir
+ + "hexagon/lib"
+ + (buildingLib
+ ? MarchG0Suffix : MarchSuffix);
+
+ //----------------------------------------------------------------------------
+ // moslib
+ //----------------------------------------------------------------------------
+ std::vector<std::string> oslibs;
+ bool hasStandalone= false;
+
+ for (arg_iterator it = Args.filtered_begin(options::OPT_moslib_EQ),
+ ie = Args.filtered_end(); it != ie; ++it) {
+ (*it)->claim();
+ oslibs.push_back((*it)->getValue());
+ hasStandalone = hasStandalone || (oslibs.back() == "standalone");
+ }
+ if (oslibs.empty()) {
+ oslibs.push_back("standalone");
+ hasStandalone = true;
}
- for (InputInfoList::const_iterator
- it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) {
- const InputInfo &II = *it;
+ //----------------------------------------------------------------------------
+ // Start Files
+ //----------------------------------------------------------------------------
+ if (incStdLib && incStartFiles) {
- // Don't try to pass LLVM or AST inputs to a generic gcc.
- if (II.getType() == types::TY_LLVM_IR || II.getType() == types::TY_LTO_IR ||
- II.getType() == types::TY_LLVM_BC || II.getType() == types::TY_LTO_BC)
- D.Diag(clang::diag::err_drv_no_linker_llvm_support)
- << getToolChain().getTripleString();
- else if (II.getType() == types::TY_AST)
- D.Diag(clang::diag::err_drv_no_ast_support)
- << getToolChain().getTripleString();
+ if (!buildingLib) {
+ if (hasStandalone) {
+ CmdArgs.push_back(
+ Args.MakeArgString(StartFilesDir + "/crt0_standalone.o"));
+ }
+ CmdArgs.push_back(Args.MakeArgString(StartFilesDir + "/crt0.o"));
+ }
+ std::string initObj = useShared ? "/initS.o" : "/init.o";
+ CmdArgs.push_back(Args.MakeArgString(StartFilesDir + initObj));
+ }
+
+ //----------------------------------------------------------------------------
+ // Library Search Paths
+ //----------------------------------------------------------------------------
+ const ToolChain::path_list &LibPaths = ToolChain.getFilePaths();
+ for (ToolChain::path_list::const_iterator
+ i = LibPaths.begin(),
+ e = LibPaths.end();
+ i != e;
+ ++i)
+ CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + *i));
- if (II.isFilename())
- CmdArgs.push_back(II.getFilename());
- else
- // Don't render as input, we need gcc to do the translations. FIXME: Pranav: What is this ?
- II.getInputArg().render(Args, CmdArgs);
+ //----------------------------------------------------------------------------
+ //
+ //----------------------------------------------------------------------------
+ Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
+ Args.AddAllArgs(CmdArgs, options::OPT_e);
+ Args.AddAllArgs(CmdArgs, options::OPT_s);
+ Args.AddAllArgs(CmdArgs, options::OPT_t);
+ Args.AddAllArgs(CmdArgs, options::OPT_u_Group);
+
+ AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs);
+
+ //----------------------------------------------------------------------------
+ // Libraries
+ //----------------------------------------------------------------------------
+ if (incStdLib && incDefLibs) {
+ if (D.CCCIsCXX) {
+ ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
+ CmdArgs.push_back("-lm");
+ }
+
+ CmdArgs.push_back("--start-group");
+
+ if (!buildingLib) {
+ for(std::vector<std::string>::iterator i = oslibs.begin(),
+ e = oslibs.end(); i != e; ++i)
+ CmdArgs.push_back(Args.MakeArgString("-l" + *i));
+ CmdArgs.push_back("-lc");
+ }
+ CmdArgs.push_back("-lgcc");
+
+ CmdArgs.push_back("--end-group");
+ }
+
+ //----------------------------------------------------------------------------
+ // End files
+ //----------------------------------------------------------------------------
+ if (incStdLib && incStartFiles) {
+ std::string finiObj = useShared ? "/finiS.o" : "/fini.o";
+ CmdArgs.push_back(Args.MakeArgString(StartFilesDir + finiObj));
}
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ std::string Linker = ToolChain.GetProgramPath("hexagon-ld");
+ C.addCommand(
+ new Command(
+ JA, *this,
+ Args.MakeArgString(Linker), CmdArgs));
}
// Hexagon tools end.
diff --git a/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-ld b/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-ld
new file mode 100755
index 0000000..331ef4a
--- /dev/null
+++ b/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-ld
@@ -0,0 +1 @@
+# placeholder for testing purposes
\ No newline at end of file
diff --git a/test/Driver/hexagon-toolchain.c b/test/Driver/hexagon-toolchain.c
index e9438c8..cd9a78b 100644
--- a/test/Driver/hexagon-toolchain.c
+++ b/test/Driver/hexagon-toolchain.c
@@ -80,7 +80,7 @@
// RUN: | FileCheck -check-prefix=CHECK007 %s
// CHECK007: "-cc1" {{.*}} "-target-cpu" "hexagonv3"
// CHECK007-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"{{.*}} "-march=v3"
-// CHECK007-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-gcc"{{.*}} "-mv3"
+// CHECK007-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-ld"{{.*}} "-mv3"
// RUN: %clang -### -target hexagon-unknown-linux \
// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
@@ -89,7 +89,7 @@
// RUN: | FileCheck -check-prefix=CHECK008 %s
// CHECK008: "-cc1" {{.*}} "-target-cpu" "hexagonv5"
// CHECK008-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"{{.*}} "-march=v5"
-// CHECK008-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-gcc"{{.*}} "-mv5"
+// CHECK008-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-ld"{{.*}} "-mv5"
// RUN: %clang -### -target hexagon-unknown-linux \
// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
@@ -98,7 +98,7 @@
// RUN: | FileCheck -check-prefix=CHECK009 %s
// CHECK009: "-cc1" {{.*}} "-target-cpu" "hexagonv2"
// CHECK009-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"{{.*}} "-march=v2"
-// CHECK009-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-gcc"{{.*}} "-mv2"
+// CHECK009-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-ld"{{.*}} "-mv2"
// RUN: %clang -### -target hexagon-unknown-linux \
// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
@@ -106,4 +106,330 @@
// RUN: | FileCheck -check-prefix=CHECK010 %s
// CHECK010: "-cc1" {{.*}} "-target-cpu" "hexagonv4"
// CHECK010-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"{{.*}} "-march=v4"
-// CHECK010-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-gcc"{{.*}} "-mv4"
+// CHECK010-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-ld"{{.*}} "-mv4"
+
+// -----------------------------------------------------------------------------
+// Test Linker related args
+// -----------------------------------------------------------------------------
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Defaults for C
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK011 %s
+// CHECK011: "{{.*}}clang" "-cc1"
+// CHECK011-NEXT: "[[GNU_DIR:.*]]/bin/hexagon-as"{{.*}}
+// CHECK011-NEXT: "[[GNU_DIR]]/bin/hexagon-ld"
+// CHECK011-NOT: "-static"
+// CHECK011-NOT: "-shared"
+// CHECK011: "[[GNU_DIR]]/hexagon/lib/v4/crt0_standalone.o"
+// CHECK011: "[[GNU_DIR]]/hexagon/lib/v4/crt0.o"
+// CHECK011: "[[GNU_DIR]]/hexagon/lib/v4/init.o"
+// CHECK011: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0/v4"
+// CHECK011: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0"
+// CHECK011: "-L[[GNU_DIR]]/lib/gcc"
+// CHECK011: "-L[[GNU_DIR]]/hexagon/lib/v4"
+// CHECK011: "-L[[GNU_DIR]]/hexagon/lib"
+// CHECK011: "{{[^"]+}}.o"
+// CHECK011: "--start-group" "-lstandalone" "-lc" "-lgcc" "--end-group"
+// CHECK011: "[[GNU_DIR]]/hexagon/lib/v4/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Defaults for C++
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK012 %s
+// CHECK012: "{{.*}}clang" "-cc1"
+// CHECK012-NEXT: "[[GNU_DIR:.*]]/bin/hexagon-as"{{.*}}
+// CHECK012-NEXT: "[[GNU_DIR]]/bin/hexagon-ld"
+// CHECK012-NOT: "-static"
+// CHECK012-NOT: "-shared"
+// CHECK012: "[[GNU_DIR]]/hexagon/lib/v4/crt0_standalone.o"
+// CHECK012: "[[GNU_DIR]]/hexagon/lib/v4/crt0.o"
+// CHECK012: "[[GNU_DIR]]/hexagon/lib/v4/init.o"
+// CHECK012: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0/v4"
+// CHECK012: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0"
+// CHECK012: "-L[[GNU_DIR]]/lib/gcc"
+// CHECK012: "-L[[GNU_DIR]]/hexagon/lib/v4"
+// CHECK012: "-L[[GNU_DIR]]/hexagon/lib"
+// CHECK012: "{{[^"]+}}.o"
+// CHECK012: "-lstdc++" "-lm"
+// CHECK012: "--start-group" "-lstandalone" "-lc" "-lgcc" "--end-group"
+// CHECK012: "[[GNU_DIR]]/hexagon/lib/v4/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Additional Libraries (-L)
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -Lone -L two -L three \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK013 %s
+// CHECK013: "{{.*}}clang" "-cc1"
+// CHECK013-NEXT: "[[GNU_DIR:.*]]/bin/hexagon-as"{{.*}}
+// CHECK013-NEXT: "[[GNU_DIR]]/bin/hexagon-ld"
+// CHECK013: "[[GNU_DIR]]/hexagon/lib/v4/crt0_standalone.o"
+// CHECK013: "[[GNU_DIR]]/hexagon/lib/v4/crt0.o"
+// CHECK013: "[[GNU_DIR]]/hexagon/lib/v4/init.o"
+// CHECK013: "-Lone" "-Ltwo" "-Lthree"
+// CHECK013: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0/v4"
+// CHECK013: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0"
+// CHECK013: "-L[[GNU_DIR]]/lib/gcc"
+// CHECK013: "-L[[GNU_DIR]]/hexagon/lib/v4"
+// CHECK013: "-L[[GNU_DIR]]/hexagon/lib"
+// CHECK013: "{{[^"]+}}.o"
+// CHECK013: "--start-group" "-lstandalone" "-lc" "-lgcc" "--end-group"
+// CHECK013: "[[GNU_DIR]]/hexagon/lib/v4/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -static, -shared
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -static \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK014 %s
+// CHECK014: "{{.*}}clang" "-cc1"
+// CHECK014-NEXT: "[[GNU_DIR:.*]]/bin/hexagon-as"{{.*}}
+// CHECK014-NEXT: "[[GNU_DIR]]/bin/hexagon-ld"
+// CHECK014: "-static"
+// CHECK014: "[[GNU_DIR]]/hexagon/lib/v4/crt0_standalone.o"
+// CHECK014: "[[GNU_DIR]]/hexagon/lib/v4/crt0.o"
+// CHECK014: "[[GNU_DIR]]/hexagon/lib/v4/init.o"
+// CHECK014: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0/v4"
+// CHECK014: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0"
+// CHECK014: "-L[[GNU_DIR]]/lib/gcc"
+// CHECK014: "-L[[GNU_DIR]]/hexagon/lib/v4"
+// CHECK014: "-L[[GNU_DIR]]/hexagon/lib"
+// CHECK014: "{{[^"]+}}.o"
+// CHECK014: "--start-group" "-lstandalone" "-lc" "-lgcc" "--end-group"
+// CHECK014: "[[GNU_DIR]]/hexagon/lib/v4/fini.o"
+
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -shared \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK015 %s
+// CHECK015: "{{.*}}clang" "-cc1"
+// CHECK015-NEXT: "[[GNU_DIR:.*]]/bin/hexagon-as"{{.*}}
+// CHECK015-NEXT: "[[GNU_DIR]]/bin/hexagon-ld"
+// CHECK015: "-shared" "-call_shared"
+// CHECK015-NOT: crt0_standalone.o
+// CHECK015-NOT: crt0.o
+// CHECK015: "[[GNU_DIR]]/hexagon/lib/v4/G0/initS.o"
+// CHECK015: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0/v4/G0"
+// CHECK015: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0/G0"
+// CHECK015: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0/v4"
+// CHECK015: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0"
+// CHECK015: "-L[[GNU_DIR]]/lib/gcc"
+// CHECK015: "-L[[GNU_DIR]]/hexagon/lib/v4/G0"
+// CHECK015: "-L[[GNU_DIR]]/hexagon/lib/G0"
+// CHECK015: "-L[[GNU_DIR]]/hexagon/lib/v4"
+// CHECK015: "-L[[GNU_DIR]]/hexagon/lib"
+// CHECK015: "{{[^"]+}}.o"
+// CHECK015: "--start-group"
+// CHECK015-NOT: "-lstandalone"
+// CHECK015-NOT: "-lc"
+// CHECK015: "-lgcc"
+// CHECK015: "--end-group"
+// CHECK015: "[[GNU_DIR]]/hexagon/lib/v4/G0/finiS.o"
+
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -shared \
+// RUN: -static \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK016 %s
+// CHECK016: "{{.*}}clang" "-cc1"
+// CHECK016-NEXT: "[[GNU_DIR:.*]]/bin/hexagon-as"{{.*}}
+// CHECK016-NEXT: "[[GNU_DIR]]/bin/hexagon-ld"
+// CHECK016: "-shared" "-call_shared" "-static"
+// CHECK016-NOT: crt0_standalone.o
+// CHECK016-NOT: crt0.o
+// CHECK016: "[[GNU_DIR]]/hexagon/lib/v4/G0/init.o"
+// CHECK016: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0/v4/G0"
+// CHECK016: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0/G0"
+// CHECK016: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0/v4"
+// CHECK016: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0"
+// CHECK016: "-L[[GNU_DIR]]/lib/gcc"
+// CHECK016: "-L[[GNU_DIR]]/hexagon/lib/v4/G0"
+// CHECK016: "-L[[GNU_DIR]]/hexagon/lib/G0"
+// CHECK016: "-L[[GNU_DIR]]/hexagon/lib/v4"
+// CHECK016: "-L[[GNU_DIR]]/hexagon/lib"
+// CHECK016: "{{[^"]+}}.o"
+// CHECK016: "--start-group"
+// CHECK016-NOT: "-lstandalone"
+// CHECK016-NOT: "-lc"
+// CHECK016: "-lgcc"
+// CHECK016: "--end-group"
+// CHECK016: "[[GNU_DIR]]/hexagon/lib/v4/G0/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -nostdlib, -nostartfiles, -nodefaultlibs
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -nostdlib \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK017 %s
+// CHECK017: "{{.*}}clang" "-cc1"
+// CHECK017-NEXT: "[[GNU_DIR:.*]]/bin/hexagon-as"{{.*}}
+// CHECK017-NEXT: "[[GNU_DIR]]/bin/hexagon-ld"
+// CHECK017-NOT: crt0_standalone.o
+// CHECK017-NOT: crt0.o
+// CHECK017-NOT: init.o
+// CHECK017: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0/v4"
+// CHECK017: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0"
+// CHECK017: "-L[[GNU_DIR]]/lib/gcc"
+// CHECK017: "-L[[GNU_DIR]]/hexagon/lib/v4"
+// CHECK017: "-L[[GNU_DIR]]/hexagon/lib"
+// CHECK017: "{{[^"]+}}.o"
+// CHECK017-NOT: "-lstdc++"
+// CHECK017-NOT: "-lm"
+// CHECK017-NOT: "--start-group"
+// CHECK017-NOT: "-lstandalone"
+// CHECK017-NOT: "-lc"
+// CHECK017-NOT: "-lgcc"
+// CHECK017-NOT: "--end-group"
+// CHECK017-NOT: fini.o
+
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -nostartfiles \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK018 %s
+// CHECK018: "{{.*}}clang" "-cc1"
+// CHECK018-NEXT: "[[GNU_DIR:.*]]/bin/hexagon-as"{{.*}}
+// CHECK018-NEXT: "[[GNU_DIR]]/bin/hexagon-ld"
+// CHECK018-NOT: crt0_standalone.o
+// CHECK018-NOT: crt0.o
+// CHECK018-NOT: init.o
+// CHECK018: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0/v4"
+// CHECK018: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0"
+// CHECK018: "-L[[GNU_DIR]]/lib/gcc"
+// CHECK018: "-L[[GNU_DIR]]/hexagon/lib/v4"
+// CHECK018: "-L[[GNU_DIR]]/hexagon/lib"
+// CHECK018: "{{[^"]+}}.o"
+// CHECK018: "-lstdc++"
+// CHECK018: "-lm"
+// CHECK018: "--start-group"
+// CHECK018: "-lstandalone"
+// CHECK018: "-lc"
+// CHECK018: "-lgcc"
+// CHECK018: "--end-group"
+// CHECK018-NOT: fini.o
+
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -nodefaultlibs \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK019 %s
+// CHECK019: "{{.*}}clang" "-cc1"
+// CHECK019-NEXT: "[[GNU_DIR:.*]]/bin/hexagon-as"{{.*}}
+// CHECK019-NEXT: "[[GNU_DIR]]/bin/hexagon-ld"
+// CHECK019: "[[GNU_DIR]]/hexagon/lib/v4/crt0_standalone.o"
+// CHECK019: "[[GNU_DIR]]/hexagon/lib/v4/crt0.o"
+// CHECK019: "[[GNU_DIR]]/hexagon/lib/v4/init.o"
+// CHECK019: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0/v4"
+// CHECK019: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0"
+// CHECK019: "-L[[GNU_DIR]]/lib/gcc"
+// CHECK019: "-L[[GNU_DIR]]/hexagon/lib/v4"
+// CHECK019: "-L[[GNU_DIR]]/hexagon/lib"
+// CHECK019: "{{[^"]+}}.o"
+// CHECK019-NOT: "-lstdc++"
+// CHECK019-NOT: "-lm"
+// CHECK019-NOT: "--start-group"
+// CHECK019-NOT: "-lstandalone"
+// CHECK019-NOT: "-lc"
+// CHECK019-NOT: "-lgcc"
+// CHECK019-NOT: "--end-group"
+// CHECK019: "[[GNU_DIR]]/hexagon/lib/v4/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -moslib
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -moslib=first -moslib=second \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK020 %s
+// CHECK020: "{{.*}}clang" "-cc1"
+// CHECK020-NEXT: "[[GNU_DIR:.*]]/bin/hexagon-as"{{.*}}
+// CHECK020-NEXT: "[[GNU_DIR]]/bin/hexagon-ld"
+// CHECK020-NOT: "-static"
+// CHECK020-NOT: "-shared"
+// CHECK020-NOT: crt0_standalone.o
+// CHECK020: "[[GNU_DIR]]/hexagon/lib/v4/crt0.o"
+// CHECK020: "[[GNU_DIR]]/hexagon/lib/v4/init.o"
+// CHECK020: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0/v4"
+// CHECK020: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0"
+// CHECK020: "-L[[GNU_DIR]]/lib/gcc"
+// CHECK020: "-L[[GNU_DIR]]/hexagon/lib/v4"
+// CHECK020: "-L[[GNU_DIR]]/hexagon/lib"
+// CHECK020: "{{[^"]+}}.o"
+// CHECK020: "--start-group"
+// CHECK020: "-lfirst" "-lsecond"
+// CHECK020-NOT: "-lstandalone"
+// CHECK020: "-lc" "-lgcc" "--end-group"
+// CHECK020: "[[GNU_DIR]]/hexagon/lib/v4/fini.o"
+
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -moslib=first -moslib=second -moslib=standalone\
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK021 %s
+// CHECK021: "{{.*}}clang" "-cc1"
+// CHECK021-NEXT: "[[GNU_DIR:.*]]/bin/hexagon-as"{{.*}}
+// CHECK021-NEXT: "[[GNU_DIR]]/bin/hexagon-ld"
+// CHECK021-NOT: "-static"
+// CHECK021-NOT: "-shared"
+// CHECK021: "[[GNU_DIR]]/hexagon/lib/v4/crt0_standalone.o"
+// CHECK021: "[[GNU_DIR]]/hexagon/lib/v4/crt0.o"
+// CHECK021: "[[GNU_DIR]]/hexagon/lib/v4/init.o"
+// CHECK021: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0/v4"
+// CHECK021: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0"
+// CHECK021: "-L[[GNU_DIR]]/lib/gcc"
+// CHECK021: "-L[[GNU_DIR]]/hexagon/lib/v4"
+// CHECK021: "-L[[GNU_DIR]]/hexagon/lib"
+// CHECK021: "{{[^"]+}}.o"
+// CHECK021: "--start-group"
+// CHECK021: "-lfirst" "-lsecond"
+// CHECK021: "-lstandalone"
+// CHECK021: "-lc" "-lgcc" "--end-group"
+// CHECK021: "[[GNU_DIR]]/hexagon/lib/v4/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Other args to pass to linker
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -s \
+// RUN: -Tbss 0xdead -Tdata 0xbeef -Ttext 0xcafe \
+// RUN: -t \
+// RUN: -e start_here \
+// RUN: -uFoo -undefined Bar \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK022 %s
+// CHECK022: "{{.*}}clang" "-cc1"
+// CHECK022-NEXT: "[[GNU_DIR:.*]]/bin/hexagon-as"{{.*}}
+// CHECK022-NEXT: "[[GNU_DIR]]/bin/hexagon-ld"
+// CHECK022: "[[GNU_DIR]]/hexagon/lib/v4/crt0_standalone.o"
+// CHECK022: "[[GNU_DIR]]/hexagon/lib/v4/crt0.o"
+// CHECK022: "[[GNU_DIR]]/hexagon/lib/v4/init.o"
+// CHECK022: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0/v4"
+// CHECK022: "-L[[GNU_DIR]]/lib/gcc/hexagon/4.4.0"
+// CHECK022: "-L[[GNU_DIR]]/lib/gcc"
+// CHECK022: "-L[[GNU_DIR]]/hexagon/lib/v4"
+// CHECK022: "-L[[GNU_DIR]]/hexagon/lib"
+// CHECK022: "-Tbss" "0xdead" "-Tdata" "0xbeef" "-Ttext" "0xcafe"
+// CHECK022: "-s"
+// CHECK022: "-t"
+// CHECK022: "-u" "Foo" "-undefined" "Bar"
+// CHECK022: "{{[^"]+}}.o"
+// CHECK022: "-lstdc++" "-lm"
+// CHECK022: "--start-group" "-lstandalone" "-lc" "-lgcc" "--end-group"
+// CHECK022: "[[GNU_DIR]]/hexagon/lib/v4/fini.o"
--
1.7.8.3
More information about the cfe-commits
mailing list