[cfe-commits] r169512 - in /cfe/trunk: include/clang/Driver/Options.td lib/Driver/ToolChains.cpp lib/Driver/ToolChains.h lib/Driver/Tools.cpp test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-ld test/Driver/hexagon-toolchain.c

Matthew Curtis mcurtis at codeaurora.org
Thu Dec 6 07:46:08 PST 2012


Author: mcurtis
Date: Thu Dec  6 09:46:07 2012
New Revision: 169512

URL: http://llvm.org/viewvc/llvm-project?rev=169512&view=rev
Log:
Hexagon TC: Reimplement Link::ConstructJob to call
 linker directly

Rather than calling gcc.

Added:
    cfe/trunk/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-ld   (with props)
Modified:
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/lib/Driver/ToolChains.cpp
    cfe/trunk/lib/Driver/ToolChains.h
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/test/Driver/hexagon-toolchain.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=169512&r1=169511&r2=169512&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Dec  6 09:46:07 2012
@@ -845,6 +845,7 @@
 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>;

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=169512&r1=169511&r2=169512&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Dec  6 09:46:07 2012
@@ -1419,6 +1419,57 @@
   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) {
@@ -1442,6 +1493,20 @@
       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() {
@@ -1521,7 +1586,22 @@
   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;
 

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=169512&r1=169511&r2=169512&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Thu Dec  6 09:46:07 2012
@@ -526,6 +526,7 @@
                                          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; }
 

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=169512&r1=169511&r2=169512&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Dec  6 09:46:07 2012
@@ -3528,68 +3528,158 @@
                                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;
-
-      // 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);
-    }
-  }
+  //----------------------------------------------------------------------------
+  //
+  //----------------------------------------------------------------------------
+  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
+  //----------------------------------------------------------------------------
 
-  RenderExtraToolArgs(JA, 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);
+
+  //----------------------------------------------------------------------------
+  //
+  //----------------------------------------------------------------------------
+  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;
+  }
+
+  //----------------------------------------------------------------------------
+  // Start Files
+  //----------------------------------------------------------------------------
+  if (incStdLib && incStartFiles) {
+
+    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));
   }
 
-  for (InputInfoList::const_iterator
-         it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) {
-    const InputInfo &II = *it;
+  //----------------------------------------------------------------------------
+  // 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));
 
-    // 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();
+  //----------------------------------------------------------------------------
+  //
+  //----------------------------------------------------------------------------
+  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);
 
-    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);
+  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");
   }
-  C.addCommand(new Command(JA, *this, Exec, CmdArgs));
 
+  //----------------------------------------------------------------------------
+  // End files
+  //----------------------------------------------------------------------------
+  if (incStdLib && incStartFiles) {
+    std::string finiObj = useShared ? "/finiS.o" : "/fini.o";
+    CmdArgs.push_back(Args.MakeArgString(StartFilesDir + finiObj));
+  }
+
+  std::string Linker = ToolChain.GetProgramPath("hexagon-ld");
+  C.addCommand(
+    new Command(
+      JA, *this,
+      Args.MakeArgString(Linker), CmdArgs));
 }
 // Hexagon tools end.
 

Added: cfe/trunk/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-ld
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-ld?rev=169512&view=auto
==============================================================================
--- cfe/trunk/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-ld (added)
+++ cfe/trunk/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-ld Thu Dec  6 09:46:07 2012
@@ -0,0 +1 @@
+# placeholder for testing purposes
\ No newline at end of file

Propchange: cfe/trunk/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-ld
------------------------------------------------------------------------------
    svn:executable = *

Modified: cfe/trunk/test/Driver/hexagon-toolchain.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-toolchain.c?rev=169512&r1=169511&r2=169512&view=diff
==============================================================================
--- cfe/trunk/test/Driver/hexagon-toolchain.c (original)
+++ cfe/trunk/test/Driver/hexagon-toolchain.c Thu Dec  6 09:46:07 2012
@@ -83,7 +83,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 \
@@ -92,7 +92,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 \
@@ -101,7 +101,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 \
@@ -109,4 +109,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"





More information about the cfe-commits mailing list