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

>From a7dd704507b2c2b139cb2dced91274da38aa948a Mon Sep 17 00:00:00 2001
From: Kushal Pal <[email protected]>
Date: Mon, 25 May 2026 16:41:40 +0530
Subject: [PATCH] [Clang][Hexagon] Use flat library directory layout for
 Picolibc

For the non-Picolibc Hexagon ELF toolchain, variant libraries are
organized in a nested directory hierarchy:
  lib/<cpu>/G0/pic/
For Picolibc, switch to a flat parallel layout where the CPU version,
G0, and pic qualifiers are encoded as a single hyphen-separated
directory name:
  lib/<cpu>-G0-pic/   (PIC + G0)
  lib/<cpu>-G0/       (G0 only)
  lib/<cpu>/          (base)
This applies to both the library search paths (-L flags, via
getHexagonLibraryPaths) and the start-file directory (crt0 lookup,
via getLibraryDir). The non-Picolibc toolchain is unaffected.
The flat layout is easier to package (no deeply nested install trees),
self-documenting, and closer to how other embedded toolchains
expose multilib variants as parallel directories.
Update hexagon-toolchain-picolibc.c to reflect the new paths, and add
--sysroot tests that verify include paths, library search paths, and
start-file selection for the base, G0, and G0-pic variants.

Signed-off-by: Kushal Pal <[email protected]>
---
 clang/lib/Driver/ToolChains/Hexagon.cpp       | 46 +++++++--
 .../test/Driver/hexagon-toolchain-picolibc.c  | 93 ++++++++++++++++---
 2 files changed, 114 insertions(+), 25 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp 
b/clang/lib/Driver/ToolChains/Hexagon.cpp
index fd2ec694abb2f..a528298712dd3 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -599,14 +599,29 @@ void HexagonToolChain::getLibraryDir(const ArgList &Args,
     llvm::sys::path::append(Dir, "lib");
   }
   std::string CpuVer = GetTargetCPUVersion(Args).str();
-  llvm::sys::path::append(Dir, CpuVer);
-  if (auto G = toolchains::HexagonToolChain::getSmallDataThreshold(Args))
-    if (*G == 0)
-      llvm::sys::path::append(Dir, "G0");
+  bool IsPicolibc = GetCStdlibType(Args) == ToolChain::CST_Picolibc;
+  bool IsG0 =
+      toolchains::HexagonToolChain::getSmallDataThreshold(Args).value_or(1) ==
+      0;
   bool IsStatic = Args.hasArg(options::OPT_static);
   bool IsShared = Args.hasArg(options::OPT_shared);
-  if (IsShared && !IsStatic)
-    llvm::sys::path::append(Dir, "pic");
+  bool IsPic = Args.hasArg(options::OPT_fpic, options::OPT_fPIC);
+  if (IsPicolibc) {
+    // Flat layout: lib/v68-G0-pic, lib/v68-G0, lib/v68
+    std::string Variant = CpuVer;
+    if (IsG0)
+      Variant += "-G0";
+    if (IsPic || IsShared)
+      Variant += "-pic";
+    llvm::sys::path::append(Dir, Variant);
+  } else {
+    // Nested layout (non-Picolibc): lib/v68/G0/pic
+    llvm::sys::path::append(Dir, CpuVer);
+    if (IsG0)
+      llvm::sys::path::append(Dir, "G0");
+    if (IsShared && !IsStatic)
+      llvm::sys::path::append(Dir, "pic");
+  }
 }
 
 void HexagonToolChain::getBaseIncludeDir(const ArgList &Args,
@@ -676,14 +691,25 @@ void HexagonToolChain::getHexagonLibraryPaths(const 
ArgList &Args,
   if (auto G = getSmallDataThreshold(Args))
     HasG0 = *G == 0;
 
+  bool IsPicolibc = GetCStdlibType(Args) == ToolChain::CST_Picolibc;
   const std::string CpuVer = GetTargetCPUVersion(Args).str();
   for (auto &Dir : RootDirs) {
     std::string LibDir = Dir + "/lib";
     std::string LibDirCpu = LibDir + '/' + CpuVer;
-    if (HasG0) {
-      if (HasPIC)
-        LibPaths.push_back(LibDirCpu + "/G0/pic");
-      LibPaths.push_back(LibDirCpu + "/G0");
+    if (IsPicolibc) {
+      // Flat layout: lib/v68-G0-pic, lib/v68-G0, lib/v68
+      if (HasG0) {
+        if (HasPIC)
+          LibPaths.push_back(LibDir + "/" + CpuVer + "-G0-pic");
+        LibPaths.push_back(LibDir + "/" + CpuVer + "-G0");
+      }
+    } else {
+      // Nested layout (non-Picolibc): lib/v68/G0/pic, lib/v68/G0
+      if (HasG0) {
+        if (HasPIC)
+          LibPaths.push_back(LibDirCpu + "/G0/pic");
+        LibPaths.push_back(LibDirCpu + "/G0");
+      }
     }
     LibPaths.push_back(LibDirCpu);
     LibPaths.push_back(LibDir);
diff --git a/clang/test/Driver/hexagon-toolchain-picolibc.c 
b/clang/test/Driver/hexagon-toolchain-picolibc.c
index 5d56ae8ff56ed..c5fdcb84d0956 100644
--- a/clang/test/Driver/hexagon-toolchain-picolibc.c
+++ b/clang/test/Driver/hexagon-toolchain-picolibc.c
@@ -20,11 +20,18 @@
 // 
-----------------------------------------------------------------------------
 // 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 \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin -mcpu=hexagonv68 \
+// RUN:   -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-STARTUP
+// CHECK-STARTUP: 
"{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v68{{/|\\\\}}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"
+//
+// RUN: %clang --target=hexagon-none-elf --cstdlib=picolibc \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin -mcpu=hexagonv68 
-G0 \
+// RUN:   -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-STARTUP-G0
+// CHECK-STARTUP-G0: 
"{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v68-G0{{/|\\\\}}crt0-semihost.o"
 // 
-----------------------------------------------------------------------------
 // Passing  -nostdlib, -nostartfiles, -nodefaultlibs, -nolibc
 // 
-----------------------------------------------------------------------------
@@ -58,7 +65,7 @@
 // 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: 
"{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v60{{/|\\\\}}crt0-semihost.o"
 // CHECK-NODEFAULTLIBS-NOT: "-lc++"
 // CHECK-NODEFAULTLIBS-NOT: "-lm"
 // CHECK-NODEFAULTLIBS-NOT: "--start-group"
@@ -72,7 +79,7 @@
 // RUN:   -nolibc %s 2>&1 | FileCheck -check-prefix=CHECK-NOLIBC %s
 // CHECK-NOLIBC: "-cc1"
 // CHECK-NOLIBC: {{hexagon-link|ld}}
-// CHECK-NOLIBC: "{{.*}}crt0-semihost.o"
+// CHECK-NOLIBC: 
"{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v60{{/|\\\\}}crt0-semihost.o"
 // CHECK-NOLIBC-SAME: "-lc++"
 // CHECK-NOLIBC-SAME: "-lm"
 // CHECK-NOLIBC-SAME: "--start-group"
@@ -108,19 +115,20 @@
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
 // RUN:   -mcpu=hexagonv68 -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-LIBPATHS %s
 // CHECK-LIBPATHS: 
"-L{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v68"
-// CHECK-LIBPATHS-NOT: 
"-L{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v68{{/|\\\\}}G0"
+// CHECK-LIBPATHS-NOT: 
"-L{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v68-G0"
 
 // RUN: %clang --target=hexagon-none-elf --cstdlib=picolibc \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
 // RUN:   -mcpu=hexagonv68 -G0 -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-LIBPATHS-G0 %s
-// CHECK-LIBPATHS-G0: 
"-L{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v68{{/|\\\\}}G0"
+// CHECK-LIBPATHS-G0: 
"-L{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v68-G0"
 // CHECK-LIBPATHS-G0: 
"-L{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v68"
 
 // RUN: %clang --target=hexagon-none-elf --cstdlib=picolibc \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
 // RUN:   -mcpu=hexagonv68 -fpic -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-LIBPATHS-PIC %s
-// CHECK-LIBPATHS-PIC: 
"-L{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v68{{/|\\\\}}G0{{/|\\\\}}pic"
-// CHECK-LIBPATHS-PIC: 
"-L{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v68{{/|\\\\}}G0"
+// CHECK-LIBPATHS-PIC: 
"{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v68-G0-pic{{/|\\\\}}crt0-semihost.o"
+// CHECK-LIBPATHS-PIC: 
"-L{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v68-G0-pic"
+// CHECK-LIBPATHS-PIC: 
"-L{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v68-G0"
 // CHECK-LIBPATHS-PIC: 
"-L{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v68"
 
 // 
=============================================================================
@@ -145,12 +153,19 @@
 // 
-----------------------------------------------------------------------------
 // H2 start files: crt0-noflash-hosted.o (not crt0-semihost.o)
 // 
-----------------------------------------------------------------------------
-// RUN: %clang --target=hexagon-h2-elf --cstdlib=picolibc -### %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-H2-STARTUP
-// CHECK-H2-STARTUP: "{{.*}}crt0-noflash-hosted.o"
+// RUN: %clang --target=hexagon-h2-elf --cstdlib=picolibc \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin -mcpu=hexagonv68 \
+// RUN:   -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-H2-STARTUP
+// CHECK-H2-STARTUP: 
"{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-h2-elf{{/|\\\\}}lib{{/|\\\\}}v68{{/|\\\\}}crt0-noflash-hosted.o"
 // CHECK-H2-STARTUP-NOT: "{{.*}}crt0-semihost.o"
 
 // RUN: %clang --target=hexagon-h2-elf --cstdlib=picolibc -nostartfiles -### 
%s 2>&1 | FileCheck %s --check-prefix=CHECK-H2-NOSTART
 // CHECK-H2-NOSTART-NOT: "{{.*}}crt0-noflash-hosted.o"
+//
+// RUN: %clang --target=hexagon-h2-elf --cstdlib=picolibc \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin -mcpu=hexagonv68 
-G0 \
+// RUN:   -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-H2-STARTUP-G0
+// CHECK-H2-STARTUP-G0: 
"{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-h2-elf{{/|\\\\}}lib{{/|\\\\}}v68-G0{{/|\\\\}}crt0-noflash-hosted.o"
 
 // 
-----------------------------------------------------------------------------
 // H2: -nostdlib, -nostartfiles, -nodefaultlibs, -nolibc
@@ -186,7 +201,7 @@
 // RUN:   -nodefaultlibs %s 2>&1 | FileCheck 
-check-prefix=CHECK-H2-NODEFAULTLIBS %s
 // CHECK-H2-NODEFAULTLIBS: "-cc1"
 // CHECK-H2-NODEFAULTLIBS: {{hexagon-link|ld}}
-// CHECK-H2-NODEFAULTLIBS: "{{.*}}crt0-noflash-hosted.o"
+// CHECK-H2-NODEFAULTLIBS: 
"{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-h2-elf{{/|\\\\}}lib{{/|\\\\}}v68{{/|\\\\}}crt0-noflash-hosted.o"
 // CHECK-H2-NODEFAULTLIBS-NOT: "-lc++"
 // CHECK-H2-NODEFAULTLIBS-NOT: "-lm"
 // CHECK-H2-NODEFAULTLIBS-NOT: "--start-group"
@@ -202,7 +217,7 @@
 // RUN:   -nolibc %s 2>&1 | FileCheck -check-prefix=CHECK-H2-NOLIBC %s
 // CHECK-H2-NOLIBC: "-cc1"
 // CHECK-H2-NOLIBC: {{hexagon-link|ld}}
-// CHECK-H2-NOLIBC: "{{.*}}crt0-noflash-hosted.o"
+// CHECK-H2-NOLIBC: 
"{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-h2-elf{{/|\\\\}}lib{{/|\\\\}}v68{{/|\\\\}}crt0-noflash-hosted.o"
 // CHECK-H2-NOLIBC-SAME: "-lc++"
 // CHECK-H2-NOLIBC-SAME: "-lm"
 // CHECK-H2-NOLIBC-SAME: "--start-group"
@@ -221,7 +236,7 @@
 // CHECK-H2-RTLIB-NOT: "-lgcc"
 
 // 
-----------------------------------------------------------------------------
-// H2: libunwind linked for C++ but not C
+// H2: libunwind linked for C++ by default
 // 
-----------------------------------------------------------------------------
 // RUN: %clangxx --target=hexagon-h2-elf --cstdlib=picolibc -### %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-H2-CXX-UNWIND
 // CHECK-H2-CXX-UNWIND: "-lunwind"
@@ -233,10 +248,58 @@
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
 // RUN:   -mcpu=hexagonv68 -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-H2-LIBPATHS %s
 // CHECK-H2-LIBPATHS: 
"-L{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-h2-elf{{/|\\\\}}lib{{/|\\\\}}v68"
-// CHECK-H2-LIBPATHS-NOT: 
"-L{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-h2-elf{{/|\\\\}}lib{{/|\\\\}}v68{{/|\\\\}}G0"
+// CHECK-H2-LIBPATHS-NOT: 
"-L{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-h2-elf{{/|\\\\}}lib{{/|\\\\}}v68-G0"
 
 // RUN: %clang --target=hexagon-h2-elf --cstdlib=picolibc \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
 // RUN:   -mcpu=hexagonv68 -G0 -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-H2-LIBPATHS-G0 %s
-// CHECK-H2-LIBPATHS-G0: 
"-L{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-h2-elf{{/|\\\\}}lib{{/|\\\\}}v68{{/|\\\\}}G0"
+// CHECK-H2-LIBPATHS-G0: 
"-L{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-h2-elf{{/|\\\\}}lib{{/|\\\\}}v68-G0"
 // CHECK-H2-LIBPATHS-G0: 
"-L{{.*}}{{/|\\\\}}Inputs{{/|\\\\}}hexagon_tree{{/|\\\\}}Tools{{/|\\\\}}bin{{/|\\\\}}..{{/|\\\\}}target{{/|\\\\}}picolibc{{/|\\\\}}hexagon-unknown-h2-elf{{/|\\\\}}lib{{/|\\\\}}v68"
+
+// 
=============================================================================
+// --sysroot tests: verify includes, library paths, and start files when an
+// explicit sysroot is provided together with --cstdlib=picolibc.
+// The sysroot path is synthetic (/my/picolibc/sysroot); no real directory is
+// needed because the driver emits the paths unconditionally.
+// 
=============================================================================
+
+// 
-----------------------------------------------------------------------------
+// Base (no G0 / no pic): include paths (C and C++), lib/v68, crt0-semihost.o
+// Use the existing Inputs sysroot so that include/c++/v1 exists on disk and
+// the driver emits the C++ include path.
+// 
-----------------------------------------------------------------------------
+// RUN: %clangxx --target=hexagon-none-elf --cstdlib=picolibc \
+// RUN:   
--sysroot=%S/Inputs/hexagon_tree/Tools/target/picolibc/hexagon-unknown-none-elf 
\
+// RUN:   -mcpu=hexagonv68 -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-SYSROOT %s
+// CHECK-SYSROOT: "-isysroot" "{{.*}}{{/|\\\\}}hexagon-unknown-none-elf"
+// CHECK-SYSROOT: "-internal-isystem" 
"{{.*}}{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}v1"
+// CHECK-SYSROOT: "-internal-externc-isystem" 
"{{.*}}{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}include"
+// CHECK-SYSROOT: 
"{{.*}}{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v68{{/|\\\\}}crt0-semihost.o"
+// CHECK-SYSROOT: 
"-L{{.*}}{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v68"
+// CHECK-SYSROOT: "-L{{.*}}{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib"
+// CHECK-SYSROOT-NOT: 
"-L{{.*}}{{/|\\\\}}hexagon-unknown-none-elf{{/|\\\\}}lib{{/|\\\\}}v68-G0"
+
+// 
-----------------------------------------------------------------------------
+// G0: crt0-semihost.o from lib/v68-G0, search paths lib/v68-G0 then lib/v68
+// 
-----------------------------------------------------------------------------
+// RUN: %clang --target=hexagon-none-elf --cstdlib=picolibc \
+// RUN:   --sysroot=/my/picolibc/sysroot \
+// RUN:   -mcpu=hexagonv68 -G0 -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-SYSROOT-G0 %s
+// CHECK-SYSROOT-G0: 
"/my/picolibc/sysroot{{/|\\\\}}lib{{/|\\\\}}v68-G0{{/|\\\\}}crt0-semihost.o"
+// CHECK-SYSROOT-G0: "-L/my/picolibc/sysroot{{/|\\\\}}lib{{/|\\\\}}v68-G0"
+// CHECK-SYSROOT-G0: "-L/my/picolibc/sysroot{{/|\\\\}}lib{{/|\\\\}}v68"
+// CHECK-SYSROOT-G0: "-L/my/picolibc/sysroot{{/|\\\\}}lib"
+// CHECK-SYSROOT-G0-NOT: 
"-L/my/picolibc/sysroot{{/|\\\\}}lib{{/|\\\\}}v68-G0-pic"
+
+// 
-----------------------------------------------------------------------------
+// G0-pic (-fpic): search paths lib/v68-G0-pic, lib/v68-G0, lib/v68
+// -fpic implies both G0 and pic, so crt0 comes from lib/v68-G0-pic
+// 
-----------------------------------------------------------------------------
+// RUN: %clang --target=hexagon-none-elf --cstdlib=picolibc \
+// RUN:   --sysroot=/my/picolibc/sysroot \
+// RUN:   -mcpu=hexagonv68 -fpic -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-SYSROOT-PIC %s
+// CHECK-SYSROOT-PIC: 
"/my/picolibc/sysroot{{/|\\\\}}lib{{/|\\\\}}v68-G0-pic{{/|\\\\}}crt0-semihost.o"
+// CHECK-SYSROOT-PIC: "-L/my/picolibc/sysroot{{/|\\\\}}lib{{/|\\\\}}v68-G0-pic"
+// CHECK-SYSROOT-PIC: "-L/my/picolibc/sysroot{{/|\\\\}}lib{{/|\\\\}}v68-G0"
+// CHECK-SYSROOT-PIC: "-L/my/picolibc/sysroot{{/|\\\\}}lib{{/|\\\\}}v68"
+// CHECK-SYSROOT-PIC: "-L/my/picolibc/sysroot{{/|\\\\}}lib"

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

Reply via email to