https://github.com/quic-k updated 
https://github.com/llvm/llvm-project/pull/183257

>From d49059da4aff5981507068a8f434b6619dcd8b58 Mon Sep 17 00:00:00 2001
From: Kushal Pal <[email protected]>
Date: Tue, 24 Feb 2026 12:01:02 +0530
Subject: [PATCH 1/2] [Clang] Add clang driver option --cstdlib

Introduce clang flag --cstdlib based on RFC:
https://discourse.llvm.org/t/rfc-add-command-line-option-for-selecting-c-library/87335

This flag accepts a string i.e. the name of the C library that user
wants to use. For now, valid options are picolibc, newlib, llvm-libc.
Toolchain drivers can handle this flag as per need or ignore it.

Signed-off-by: Kushal Pal <[email protected]>
---
 .../clang/Basic/DiagnosticDriverKinds.td      |  2 ++
 clang/include/clang/Driver/ToolChain.h        | 13 ++++++++++
 clang/include/clang/Options/Options.td        |  5 ++++
 clang/lib/Driver/ToolChain.cpp                | 25 +++++++++++++++++++
 4 files changed, 45 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 90a92b1602231..1ef1fee4e02e6 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -187,6 +187,8 @@ def err_drv_incompatible_unwindlib : Error<
   "--rtlib=libgcc requires --unwindlib=libgcc">;
 def err_drv_incompatible_options : Error<
   "the combination of '%0' and '%1' is incompatible">;
+def err_drv_invalid_cstdlib_name : Error<
+  "invalid C library name in argument '%0'">;
 def err_drv_invalid_stdlib_name : Error<
   "invalid library name in argument '%0'">;
 def err_drv_invalid_output_with_multiple_archs : Error<
diff --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index 665f7f91ecfcd..9068c5477bcbd 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -109,6 +109,13 @@ class ToolChain {
     UNW_Libgcc
   };
 
+  enum CStdLibType {
+    CST_Newlib,
+    CST_Picolibc,
+    CST_LLVMLibC,
+    CST_System,
+  };
+
   enum class UnwindTableLevel {
     None,
     Synchronous,
@@ -194,6 +201,7 @@ class ToolChain {
   mutable std::optional<CXXStdlibType> cxxStdlibType;
   mutable std::optional<RuntimeLibType> runtimeLibType;
   mutable std::optional<UnwindLibType> unwindLibType;
+  mutable std::optional<CStdLibType> cStdLibType;
 
 protected:
   MultilibSet Multilibs;
@@ -729,6 +737,11 @@ class ToolChain {
   // given compilation arguments.
   virtual UnwindLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const;
 
+  // Determine the C standard library to use with the given
+  // compilation arguments. Defaults to CST_System when no --cstdlib= flag
+  // is provided.
+  virtual CStdLibType GetCStdlibType(const llvm::opt::ArgList &Args) const;
+
   // Detect the highest available version of libc++ in include path.
   virtual std::string detectLibcxxVersion(StringRef IncludePath) const;
 
diff --git a/clang/include/clang/Options/Options.td 
b/clang/include/clang/Options/Options.td
index 4ac812e92e2cb..3c01157d3d8c9 100644
--- a/clang/include/clang/Options/Options.td
+++ b/clang/include/clang/Options/Options.td
@@ -6454,6 +6454,10 @@ def std_EQ : Joined<["-", "--"], "std=">,
 def stdlib_EQ : Joined<["-", "--"], "stdlib=">,
   Visibility<[ClangOption, CC1Option]>,
   HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">;
+def cstdlib_EQ : Joined<["--"], "cstdlib=">,
+  Visibility<[ClangOption]>,
+  HelpText<"C standard library to use">,
+  Values<"newlib,picolibc,llvm-libc,system">;
 def stdlibxx_isystem : JoinedOrSeparate<["-"], "stdlib++-isystem">,
   Group<clang_i_Group>,
   HelpText<"Use directory as the C++ standard library include path">,
@@ -6706,6 +6710,7 @@ def _version : Flag<["--"], "version">,
 def _signed_char : Flag<["--"], "signed-char">, Alias<fsigned_char>;
 def _std : Separate<["--"], "std">, Alias<std_EQ>;
 def _stdlib : Separate<["--"], "stdlib">, Alias<stdlib_EQ>;
+def _cstdlib : Separate<["--"], "cstdlib">, Alias<cstdlib_EQ>;
 def _target_help : Flag<["--"], "target-help">;
 def _trace_includes : Flag<["--"], "trace-includes">, Alias<H>;
 def _undefine_macro_EQ : Joined<["--"], "undefine-macro=">, Alias<U>;
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 4b902b4db0c23..23f332dc8a79b 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -1413,6 +1413,31 @@ ToolChain::CXXStdlibType 
ToolChain::GetCXXStdlibType(const ArgList &Args) const{
   return *cxxStdlibType;
 }
 
+ToolChain::CStdLibType ToolChain::GetCStdlibType(const ArgList &Args) const {
+  if (cStdLibType)
+    return *cStdLibType;
+
+  const Arg *A = Args.getLastArg(options::OPT_cstdlib_EQ);
+  StringRef LibName = A ? A->getValue() : "system";
+
+  if (LibName == "newlib")
+    cStdLibType = ToolChain::CST_Newlib;
+  else if (LibName == "picolibc")
+    cStdLibType = ToolChain::CST_Picolibc;
+  else if (LibName == "llvm-libc")
+    cStdLibType = ToolChain::CST_LLVMLibC;
+  else if (LibName == "system")
+    cStdLibType = ToolChain::CST_System;
+  else {
+    if (A)
+      getDriver().Diag(diag::err_drv_invalid_cstdlib_name)
+          << A->getAsString(Args);
+    cStdLibType = ToolChain::CST_System;
+  }
+
+  return *cStdLibType;
+}
+
 /// Utility function to add a system framework directory to CC1 arguments.
 void ToolChain::addSystemFrameworkInclude(const llvm::opt::ArgList &DriverArgs,
                                           llvm::opt::ArgStringList &CC1Args,

>From a7887c4d121dd7041185069574669e8183408415 Mon Sep 17 00:00:00 2001
From: Kushal Pal <[email protected]>
Date: Tue, 9 Dec 2025 11:42:18 +0530
Subject: [PATCH 2/2] [Clang][Hexagon] Use --cstdlib flag to choose Picolibc

Update the Hexagon toolchain to use --cstdlib flag to allow users to
choose Picolibc as the C library.
This allows proper selection of C library when targeting
Hexagon environments.

Signed-off-by: Kushal Pal <[email protected]>
---
 clang/lib/Driver/ToolChains/Hexagon.cpp       | 178 ++++++++++++++++--
 clang/lib/Driver/ToolChains/Hexagon.h         |   8 +
 .../test/Driver/hexagon-toolchain-picolibc.c  |  90 +++++++++
 3 files changed, 263 insertions(+), 13 deletions(-)
 create mode 100644 clang/test/Driver/hexagon-toolchain-picolibc.c

diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp 
b/clang/lib/Driver/ToolChains/Hexagon.cpp
index f3e5a0438a768..022b9e6876656 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -13,6 +13,7 @@
 #include "clang/Driver/InputInfo.h"
 #include "clang/Options/Options.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -259,6 +260,90 @@ void hexagon::Linker::RenderExtraToolArgs(const JobAction 
&JA,
                                           ArgStringList &CmdArgs) const {
 }
 
+static void constructHexagonPicolibcLinkArgs(
+    Compilation &C, const JobAction &JA,
+    const toolchains::HexagonToolChain &HTC, const InputInfo &Output,
+    const InputInfoList &Inputs, const ArgList &Args, ArgStringList &CmdArgs,
+    const char *LinkingOutput) {
+  const Driver &D = HTC.getDriver();
+  bool IsShared = 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);
+  StringRef CpuVer = toolchains::HexagonToolChain::GetTargetCPUVersion(Args);
+  auto OsType = HTC.getOS();
+  bool UseG0 = false;
+  if (auto G = toolchains::HexagonToolChain::getSmallDataThreshold(Args)) {
+    CmdArgs.push_back(Args.MakeArgString("-G" + Twine(*G)));
+    UseG0 = *G == 0;
+  }
+
+  CmdArgs.push_back("--eh-frame-hdr");
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+
+  // Inputs
+  Args.addAllArgs(CmdArgs, {options::OPT_T_Group, options::OPT_s,
+                            options::OPT_t, options::OPT_u_Group});
+  AddLinkerInputs(HTC, Inputs, Args, CmdArgs, JA);
+
+  
//----------------------------------------------------------------------------
+  // Start Files
+  
//----------------------------------------------------------------------------
+  const std::string MCpuSuffix = "/" + CpuVer.str();
+  const std::string MCpuG0Suffix = MCpuSuffix + "/G0";
+  const std::string RootDir =
+      HTC.getHexagonTargetDir(D.Dir, D.PrefixDirs) + "/";
+  std::string NormalizedTriple =
+      HTC.getTriple().normalize(llvm::Triple::CanonicalForm::FOUR_IDENT);
+  const std::string StartSubDir =
+      NormalizedTriple + "/lib" + (UseG0 ? MCpuG0Suffix : MCpuSuffix);
+
+  if (IncStdLib && IncStartFiles) {
+    if (!IsShared) {
+      if (OsType == "none" || OsType == "unknown") {
+        std::string Crt0 =
+            RootDir + "/picolibc/" + StartSubDir + "/crt0-semihost.o";
+        CmdArgs.push_back(Args.MakeArgString(Crt0));
+      }
+    }
+  }
+
+  
//----------------------------------------------------------------------------
+  // Library Search Paths
+  
//----------------------------------------------------------------------------
+  const ToolChain::path_list &LibPaths = HTC.getFilePaths();
+  for (const auto &LibPath : LibPaths)
+    CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+  
//----------------------------------------------------------------------------
+  // Libraries
+  
//----------------------------------------------------------------------------
+  if (IncStdLib && IncDefLibs) {
+    if (D.CCCIsCXX()) {
+      if (HTC.ShouldLinkCXXStdlib(Args))
+        HTC.AddCXXStdlibLibArgs(Args, CmdArgs);
+      CmdArgs.push_back("-lm");
+    }
+
+    CmdArgs.push_back("--start-group");
+
+    if (!IsShared) {
+      // add OS libraries to link
+      std::vector<std::string> OsLibs{};
+      if (OsType == "none" || OsType == "unknown") {
+        OsLibs.push_back("semihost");
+      }
+      for (StringRef Lib : OsLibs)
+        CmdArgs.push_back(Args.MakeArgString("-l" + Lib));
+      if (!Args.hasArg(options::OPT_nolibc))
+        CmdArgs.push_back("-lc");
+    }
+    // Force compiler-rt for Picolibc
+    CmdArgs.push_back("-lclang_rt.builtins");
+    CmdArgs.push_back("--end-group");
+  }
+}
+
 static void
 constructHexagonLinkArgs(Compilation &C, const JobAction &JA,
                          const toolchains::HexagonToolChain &HTC,
@@ -423,8 +508,8 @@ constructHexagonLinkArgs(Compilation &C, const JobAction 
&JA,
       CmdArgs.push_back(Args.MakeArgString(Crt0));
     }
     std::string Init = UseShared
-          ? Find(RootDir, StartSubDir + "/pic", "/initS.o")
-          : Find(RootDir, StartSubDir, "/init.o");
+                           ? Find(RootDir, StartSubDir + "/pic", "/initS.o")
+                           : Find(RootDir, StartSubDir, "/init.o");
     CmdArgs.push_back(Args.MakeArgString(Init));
   }
 
@@ -486,8 +571,12 @@ void hexagon::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   auto &HTC = static_cast<const toolchains::HexagonToolChain&>(getToolChain());
 
   ArgStringList CmdArgs;
-  constructHexagonLinkArgs(C, JA, HTC, Output, Inputs, Args, CmdArgs,
-                           LinkingOutput);
+  if (HTC.GetCStdlibType(Args) == "picolibc")
+    constructHexagonPicolibcLinkArgs(C, JA, HTC, Output, Inputs, Args, CmdArgs,
+                                     LinkingOutput);
+  else
+    constructHexagonLinkArgs(C, JA, HTC, Output, Inputs, Args, CmdArgs,
+                             LinkingOutput);
 
   const char *Exec = Args.MakeArgString(HTC.GetLinkerPath());
   C.addCommand(std::make_unique<Command>(JA, *this,
@@ -569,16 +658,38 @@ void HexagonToolChain::getHexagonLibraryPaths(const 
ArgList &Args,
     HasG0 = *G == 0;
 
   const std::string CpuVer = GetTargetCPUVersion(Args).str();
-  for (auto &Dir : RootDirs) {
-    std::string LibDir = Dir + "/hexagon/lib";
-    std::string LibDirCpu = LibDir + '/' + CpuVer;
+  // Special-case Picolibc baremetal layout:
+  //   <install>/../target/<normalized-triple>/lib/<vXX>/G0[/pic]
+  if (GetCStdlibType(Args) == "picolibc") {
+    std::string SubDir = '/' + CpuVer;
+    // Force G0 for Picolibc
+    HasG0 = true;
     if (HasG0) {
       if (HasPIC)
-        LibPaths.push_back(LibDirCpu + "/G0/pic");
-      LibPaths.push_back(LibDirCpu + "/G0");
+        SubDir += "/G0/pic";
+      else
+        SubDir += "/G0";
+    }
+    if (getTriple().getOS() != llvm::Triple::Linux) {
+      for (auto &Dir : RootDirs) {
+        auto NormalizedTriple = getTriple().normalize();
+        std::string LibDir = Dir + "/picolibc/" + NormalizedTriple + "/lib";
+        LibPaths.push_back(LibDir + SubDir);
+      }
+    }
+    return;
+  } else {
+    for (auto &Dir : RootDirs) {
+      std::string LibDir = Dir + "/hexagon/lib";
+      std::string LibDirCpu = LibDir + '/' + CpuVer;
+      if (HasG0) {
+        if (HasPIC)
+          LibPaths.push_back(LibDirCpu + "/G0/pic");
+        LibPaths.push_back(LibDirCpu + "/G0");
+      }
+      LibPaths.push_back(LibDirCpu);
+      LibPaths.push_back(LibDir);
     }
-    LibPaths.push_back(LibDirCpu);
-    LibPaths.push_back(LibDir);
   }
 }
 
@@ -623,7 +734,9 @@ void HexagonToolChain::AddCXXStdlibLibArgs(const ArgList 
&Args,
     if (Args.hasArg(options::OPT_fexperimental_library))
       CmdArgs.push_back("-lc++experimental");
     CmdArgs.push_back("-lc++abi");
-    if (UNW != ToolChain::UNW_None)
+    // For Picolibc baremetal, always link libunwind with libc++ regardless of
+    // -unwindlib setting; libunwind is the only supported unwinding library.
+    if (UNW != ToolChain::UNW_None || GetCStdlibType(Args) == "picolibc")
       CmdArgs.push_back("-lunwind");
     break;
 
@@ -697,6 +810,17 @@ void HexagonToolChain::AddClangSystemIncludeArgs(const 
ArgList &DriverArgs,
 
   const Driver &D = getDriver();
   SmallString<128> ResourceDirInclude(D.ResourceDir);
+  // Picolibc headers live under target/picolibc/<triple>/include.
+  if (GetCStdlibType(DriverArgs) == "picolibc") {
+    if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+      return;
+    std::string TargetDir = getHexagonTargetDir(D.Dir, D.PrefixDirs);
+    std::string NormalizedTriple = getTriple().normalize();
+    addExternCSystemInclude(DriverArgs, CC1Args,
+                            TargetDir + "/picolibc/" + NormalizedTriple +
+                                "/include");
+    return;
+  }
   if (!IsELF) {
     llvm::sys::path::append(ResourceDirInclude, "include");
     if (!DriverArgs.hasArg(options::OPT_nobuiltininc) &&
@@ -755,11 +879,39 @@ void HexagonToolChain::addLibStdCxxIncludePaths(
                            DriverArgs, CC1Args);
 }
 
+void HexagonToolChain::AddClangCXXStdlibIncludeArgs(
+    const llvm::opt::ArgList &DriverArgs,
+    llvm::opt::ArgStringList &CC1Args) const {
+  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
+      DriverArgs.hasArg(options::OPT_nostdincxx))
+    return;
+  // Add libc++ headers for Picolibc
+  const Driver &D = getDriver();
+  if (GetCStdlibType(DriverArgs) == "picolibc" &&
+      getTriple().getOS() != llvm::Triple::Linux) {
+    StringRef InstallDir = D.Dir;
+    addExternCSystemInclude(DriverArgs, CC1Args,
+                            InstallDir + "/../target/picolibc/" +
+                                getTriple().normalize() + "/include/c++/v1");
+    return;
+  }
+  // Otherwise delegate to the chosen C++ stdlib include path helper.
+  switch (GetCXXStdlibType(DriverArgs)) {
+  case ToolChain::CST_Libcxx:
+    addLibCxxIncludePaths(DriverArgs, CC1Args);
+    break;
+  case ToolChain::CST_Libstdcxx:
+    addLibStdCxxIncludePaths(DriverArgs, CC1Args);
+    break;
+    llvm_unreachable("Unexpected C++ stdlib type");
+  }
+}
+
 ToolChain::CXXStdlibType
 HexagonToolChain::GetCXXStdlibType(const ArgList &Args) const {
   Arg *A = Args.getLastArg(options::OPT_stdlib_EQ);
   if (!A) {
-    if (getTriple().isMusl())
+    if (getTriple().isMusl() || GetCStdlibType(Args) == "picolibc")
       return ToolChain::CST_Libcxx;
     else
       return ToolChain::CST_Libstdcxx;
diff --git a/clang/lib/Driver/ToolChains/Hexagon.h 
b/clang/lib/Driver/ToolChains/Hexagon.h
index ad47fc735e4b8..cb7d2e702232a 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.h
+++ b/clang/lib/Driver/ToolChains/Hexagon.h
@@ -36,6 +36,11 @@ class LLVM_LIBRARY_VISIBILITY Assembler final : public Tool {
                     const InputInfo &Output, const InputInfoList &Inputs,
                     const llvm::opt::ArgList &TCArgs,
                     const char *LinkingOutput) const override;
+  void ConstructJobForPicolibc(Compilation &C, const JobAction &JA,
+                               const InputInfo &Output,
+                               const InputInfoList &Inputs,
+                               const llvm::opt::ArgList &TCArgs,
+                               const char *LinkingOutput) const;
 };
 
 class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
@@ -81,6 +86,9 @@ class LLVM_LIBRARY_VISIBILITY HexagonToolChain : public Linux 
{
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
                             llvm::opt::ArgStringList &CC1Args) const override;
+  void AddClangCXXStdlibIncludeArgs(
+      const llvm::opt::ArgList &DriverArgs,
+      llvm::opt::ArgStringList &CC1Args) const override;
   void addLibStdCxxIncludePaths(
       const llvm::opt::ArgList &DriverArgs,
       llvm::opt::ArgStringList &CC1Args) const override;
diff --git a/clang/test/Driver/hexagon-toolchain-picolibc.c 
b/clang/test/Driver/hexagon-toolchain-picolibc.c
new file mode 100644
index 0000000000000..40cc3c42177a7
--- /dev/null
+++ b/clang/test/Driver/hexagon-toolchain-picolibc.c
@@ -0,0 +1,90 @@
+// UNSUPPORTED: system-windows
+// REQUIRES: hexagon-registered-target
+
+// 
-----------------------------------------------------------------------------
+// Test standard include paths
+// 
-----------------------------------------------------------------------------
+// RUN: %clang -### --target=hexagon-none-elf --cstdlib=picolibc \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin %s 2>&1 | 
FileCheck -check-prefix=CHECK-C-INCLUDES %s
+// CHECK-C-INCLUDES: "-cc1" {{.*}} "-internal-externc-isystem" 
"{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/picolibc/hexagon-unknown-none-elf/include"
+
+// RUN: %clangxx -### --target=hexagon-none-elf --cstdlib=picolibc \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin %s 2>&1 | 
FileCheck -check-prefix=CHECK-CXX-INCLUDES %s
+// CHECK-CXX-INCLUDES: "-cc1" {{.*}} "-internal-externc-isystem" 
"{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/picolibc/hexagon-unknown-none-elf/include/c++/v1"
+// CHECK-CXX-INCLUDES: "-internal-externc-isystem" 
"{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/picolibc/hexagon-unknown-none-elf/include"
+// 
-----------------------------------------------------------------------------
+// Passing start files for Picolibc
+// 
-----------------------------------------------------------------------------
+// RUN: %clang --target=hexagon-none-elf --cstdlib=picolibc -### %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-STARTUP
+// CHECK-STARTUP: "{{.*}}crt0-semihost.o"
+//
+// RUN: %clang --target=hexagon-none-elf --cstdlib=picolibc -nostartfiles -### 
%s 2>&1 | FileCheck %s --check-prefix=CHECK-NOSTART
+// CHECK-NOSTART-NOT: "{{.*}}crt0-semihost.o"
+// 
-----------------------------------------------------------------------------
+// Passing  -nostdlib, -nostartfiles, -nodefaultlibs, -nolibc
+// 
-----------------------------------------------------------------------------
+// RUN: %clangxx -### --target=hexagon-none-elf --cstdlib=picolibc \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   -nostdlib %s 2>&1 | FileCheck -check-prefix=CHECK-NOSTDLIB %s
+// CHECK-NOSTDLIB: "-cc1"
+// CHECK-NOSTDLIB: {{hexagon-link|ld}}
+// CHECK-NOSTDLIB-NOT: {{.*}}crt0-semihost.o
+// CHECK-NOSTDLIB-NOT: "-lc++"
+// CHECK-NOSTDLIB-NOT: "-lm"
+// CHECK-NOSTDLIB-NOT: "--start-group"
+// CHECK-NOSTDLIB-NOT: "-lsemihost"
+// CHECK-NOSTDLIB-NOT: "-lc"
+// CHECK-NOSTDLIB-NOT: "-l{{(gcc|clang_rt\.builtins)}}"
+// CHECK-NOSTDLIB-NOT: "--end-group"
+
+// RUN: %clangxx -### --target=hexagon-none-elf --cstdlib=picolibc \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   -nostartfiles %s 2>&1 | FileCheck -check-prefix=CHECK-NOSTARTFILES %s
+// CHECK-NOSTARTFILES: "-cc1"
+// CHECK-NOSTARTFILES: {{hexagon-link|ld}}
+// CHECK-NOSTARTFILES-NOT: {{.*}}crt0-semihost.o
+// CHECK-NOSTARTFILES: "-lc++" "-lc++abi" "-lunwind" "-lm" "--start-group" 
"-lsemihost" "-lc" "-lclang_rt.builtins" "--end-group"
+
+// RUN: %clangxx -### --target=hexagon-none-elf --cstdlib=picolibc \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   -nodefaultlibs %s 2>&1 | FileCheck -check-prefix=CHECK-NODEFAULTLIBS 
%s
+// CHECK-NODEFAULTLIBS: "-cc1"
+// CHECK-NODEFAULTLIBS: {{hexagon-link|ld}}
+// CHECK-NODEFAULTLIBS: "{{.*}}crt0-semihost.o"
+// CHECK-NODEFAULTLIBS-NOT: "-lc++"
+// CHECK-NODEFAULTLIBS-NOT: "-lm"
+// CHECK-NODEFAULTLIBS-NOT: "--start-group"
+// CHECK-NODEFAULTLIBS-NOT: "-lsemihost"
+// CHECK-NODEFAULTLIBS-NOT: "-lc"
+// CHECK-NODEFAULTLIBS-NOT: "-lclang_rt.builtins"
+// CHECK-NODEFAULTLIBS-NOT: "--end-group"
+
+// RUN: %clangxx -### --target=hexagon-none-elf --cstdlib=picolibc \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin -mcpu=hexagonv60 \
+// RUN:   -nolibc %s 2>&1 | FileCheck -check-prefix=CHECK-NOLIBC %s
+// CHECK-NOLIBC: "-cc1"
+// CHECK-NOLIBC: hexagon-link
+// CHECK-NOLIBC-SAME: "{{.*}}crt0-semihost.o"
+// CHECK-NOLIBC-SAME: "-lc++"
+// CHECK-NOLIBC-SAME: "-lm"
+// CHECK-NOLIBC-SAME: "--start-group"
+// CHECK-NOLIBC-SAME: "-lsemihost"
+// CHECK-NOLIBC-NOT: "-lc"
+// CHECK-NOLIBC-SAME: "-lclang_rt.builtins"
+// CHECK-NOLIBC-SAME: "--end-group"
+// 
-----------------------------------------------------------------------------
+// Force compiler-rt when Picolibc is selected
+// 
-----------------------------------------------------------------------------
+// RUN: %clang --target=hexagon-none-elf --cstdlib=picolibc -### %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-RTLIB
+// RUN: %clangxx --target=hexagon-none-elf --cstdlib=picolibc -### %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-RTLIB
+// CHECK-RTLIB: "-lclang_rt.builtins"
+// 
-----------------------------------------------------------------------------
+// Force libunwind when Picolibc is selected
+// 
-----------------------------------------------------------------------------
+// RUN: %clang --target=hexagon-none-elf --cstdlib=picolibc -### %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-C-UNWIND
+// RUN: %clangxx --target=hexagon-none-elf --cstdlib=picolibc -### %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-CXX-UNWIND
+// CHECK-C-UNWIND-NOT: "-lunwind"
+// CHECK-CXX-UNWIND: "-lunwind"

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to