[llvm] [clang] Hurd: Add x86_64 support (PR #78065)
Samuel Thibault via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 14 10:24:15 PST 2024
https://github.com/sthibaul updated https://github.com/llvm/llvm-project/pull/78065
>From fefe6175fa21c668f58d69b0acc9abb89af981ab Mon Sep 17 00:00:00 2001
From: Samuel Thibault <samuel.thibault at ens-lyon.org>
Date: Sun, 14 Jan 2024 19:01:52 +0100
Subject: [PATCH 1/3] hurd: Fix indent
---
clang/test/Driver/hurd.cpp | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/clang/test/Driver/hurd.cpp b/clang/test/Driver/hurd.cpp
index 1c4ba16af063d7e..8934997b107aed6 100644
--- a/clang/test/Driver/hurd.cpp
+++ b/clang/test/Driver/hurd.cpp
@@ -2,8 +2,8 @@
// RUN: %clang -### %s --target=i686-pc-hurd-gnu --sysroot=%S/Inputs/basic_hurd_tree \
// RUN: --stdlib=platform 2>&1 | FileCheck --check-prefix=CHECK %s
-// CHECK: "-cc1"
-// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK: "-cc1"
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10"
/// Debian specific - the path component after 'include' is i386-gnu even
/// though the installation is i686-gnu.
@@ -29,9 +29,9 @@
// RUN: %clang -### %s --target=i686-pc-hurd-gnu --sysroot=%S/Inputs/basic_hurd_tree \
// RUN: --stdlib=platform -static 2>&1 | FileCheck --check-prefix=CHECK-STATIC %s
-// CHECK-STATIC: "-cc1"
-// CHECK-STATIC: "-static-define"
-// CHECK-STATIC: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-STATIC: "-cc1"
+// CHECK-STATIC: "-static-define"
+// CHECK-STATIC: "-isysroot" "[[SYSROOT:[^"]+]]"
// CHECK-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../include/c++/10"
/// Debian specific - the path component after 'include' is i386-gnu even
/// though the installation is i686-gnu.
@@ -57,9 +57,9 @@
// RUN: %clang -### %s --target=i686-pc-hurd-gnu --sysroot=%S/Inputs/basic_hurd_tree \
// RUN: -shared 2>&1 | FileCheck --check-prefix=CHECK-SHARED %s
-// CHECK-SHARED: "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-SHARED: "{{.*}}/usr/lib/gcc/i686-gnu/10/crtbeginS.o"
-// CHECK-SHARED: "-L
+// CHECK-SHARED: "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-SHARED: "{{.*}}/usr/lib/gcc/i686-gnu/10/crtbeginS.o"
+// CHECK-SHARED: "-L
// CHECK-SHARED-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/10"
// CHECK-SHARED-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/i686-gnu/10/../../../../lib32"
// CHECK-SHARED-SAME: {{^}} "-L[[SYSROOT]]/lib/i386-gnu"
>From 1f4e490c8160c36e0cba130f4587f8ab0b4cfecb Mon Sep 17 00:00:00 2001
From: Samuel Thibault <samuel.thibault at ens-lyon.org>
Date: Sun, 14 Jan 2024 19:02:30 +0100
Subject: [PATCH 2/3] hurd: Strengthen test
---
clang/test/Driver/hurd.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/Driver/hurd.cpp b/clang/test/Driver/hurd.cpp
index 8934997b107aed6..f76d2cd73a01662 100644
--- a/clang/test/Driver/hurd.cpp
+++ b/clang/test/Driver/hurd.cpp
@@ -43,7 +43,7 @@
// CHECK-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
// CHECK-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
// CHECK-STATIC: "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-STATIC: "-static"
+// CHECK-STATIC-SAME: "-static"
// CHECK-STATIC: "{{.*}}/usr/lib/gcc/i686-gnu/10/crtbeginT.o"
// CHECK-STATIC: "-L
// CHECK-STATIC-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/i686-gnu/10"
>From 156ed9e34ba1cd6f6e83e485842a37d1c132450e Mon Sep 17 00:00:00 2001
From: Samuel Thibault <samuel.thibault at ens-lyon.org>
Date: Sat, 13 Jan 2024 20:16:03 +0100
Subject: [PATCH 3/3] Hurd: Add x86_64 support
---
clang/lib/Basic/Targets.cpp | 2 +
clang/lib/Driver/ToolChains/Gnu.cpp | 27 ++++++-
clang/lib/Driver/ToolChains/Hurd.cpp | 16 +++-
.../usr/lib/gcc/x86_64-gnu/10/crtbegin.o | 0
.../usr/x86_64-gnu/bin/as | 0
.../usr/x86_64-gnu/bin/ld | 0
.../usr/x86_64-gnu/lib/.keep | 0
.../basic_hurd_tree/lib/x86_64-gnu/.keep | 0
.../Driver/Inputs/basic_hurd_tree/lib64/.keep | 0
.../usr/include/x86_64-gnu/.keep | 0
.../usr/include/x86_64-gnu/c++/10/.keep | 0
.../usr/lib/gcc/x86_64-gnu/10/crtbegin.o | 0
.../usr/lib/gcc/x86_64-gnu/10/crtbeginS.o | 0
.../usr/lib/gcc/x86_64-gnu/10/crtbeginT.o | 0
.../basic_hurd_tree/usr/lib/x86_64-gnu/.keep | 0
.../Inputs/basic_hurd_tree/usr/lib64/.keep | 0
clang/test/Driver/hurd.cpp | 79 +++++++++++++++++++
llvm/unittests/TargetParser/TripleTest.cpp | 6 ++
18 files changed, 127 insertions(+), 3 deletions(-)
create mode 100644 clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/x86_64-gnu/10/crtbegin.o
create mode 100755 clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/x86_64-gnu/bin/as
create mode 100755 clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/x86_64-gnu/bin/ld
create mode 100644 clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/x86_64-gnu/lib/.keep
create mode 100644 clang/test/Driver/Inputs/basic_hurd_tree/lib/x86_64-gnu/.keep
create mode 100644 clang/test/Driver/Inputs/basic_hurd_tree/lib64/.keep
create mode 100644 clang/test/Driver/Inputs/basic_hurd_tree/usr/include/x86_64-gnu/.keep
create mode 100644 clang/test/Driver/Inputs/basic_hurd_tree/usr/include/x86_64-gnu/c++/10/.keep
create mode 100644 clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/x86_64-gnu/10/crtbegin.o
create mode 100644 clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/x86_64-gnu/10/crtbeginS.o
create mode 100644 clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/x86_64-gnu/10/crtbeginT.o
create mode 100644 clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/x86_64-gnu/.keep
create mode 100644 clang/test/Driver/Inputs/basic_hurd_tree/usr/lib64/.keep
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index ea002bb464fcc58..e3283510c6aac78 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -644,6 +644,8 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
return std::make_unique<PS4OSTargetInfo<X86_64TargetInfo>>(Triple, Opts);
case llvm::Triple::PS5:
return std::make_unique<PS5OSTargetInfo<X86_64TargetInfo>>(Triple, Opts);
+ case llvm::Triple::Hurd:
+ return std::make_unique<HurdTargetInfo<X86_64TargetInfo>>(Triple, Opts);
default:
return std::make_unique<X86_64TargetInfo>(Triple, Opts);
}
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index 771240dac7a83e2..891a0278af8f021 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2485,7 +2485,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
static const char *const X86Triples[] = {
"i586-linux-gnu", "i686-linux-gnu", "i686-pc-linux-gnu",
"i386-redhat-linux6E", "i686-redhat-linux", "i386-redhat-linux",
- "i586-suse-linux", "i686-montavista-linux", "i686-gnu",
+ "i586-suse-linux", "i686-montavista-linux",
};
static const char *const LoongArch64LibDirs[] = {"/lib64", "/lib"};
@@ -2652,6 +2652,31 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
return;
}
+ if (TargetTriple.isOSHurd()) {
+ static const char *const X86_64HurdTriples[] = {"x86_64-gnu"};
+ static const char *const X86HurdTriples[] = {"i686-gnu"};
+
+ switch (TargetTriple.getArch()) {
+ case llvm::Triple::x86_64:
+ LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
+ TripleAliases.append(begin(X86_64HurdTriples), end(X86_64HurdTriples));
+ BiarchLibDirs.append(begin(X86LibDirs), end(X86LibDirs));
+ BiarchTripleAliases.append(begin(X86HurdTriples), end(X86HurdTriples));
+ break;
+ case llvm::Triple::x86:
+ LibDirs.append(begin(X86LibDirs), end(X86LibDirs));
+ TripleAliases.append(begin(X86HurdTriples), end(X86HurdTriples));
+ BiarchLibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
+ BiarchTripleAliases.append(begin(X86_64HurdTriples),
+ end(X86_64HurdTriples));
+ break;
+ default:
+ break;
+ }
+
+ return;
+ }
+
switch (TargetTriple.getArch()) {
case llvm::Triple::aarch64:
LibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs));
diff --git a/clang/lib/Driver/ToolChains/Hurd.cpp b/clang/lib/Driver/ToolChains/Hurd.cpp
index 7a4c2bb7ede1d5f..5074eda5f415596 100644
--- a/clang/lib/Driver/ToolChains/Hurd.cpp
+++ b/clang/lib/Driver/ToolChains/Hurd.cpp
@@ -30,13 +30,21 @@ using tools::addPathIfExists;
std::string Hurd::getMultiarchTriple(const Driver &D,
const llvm::Triple &TargetTriple,
StringRef SysRoot) const {
- if (TargetTriple.getArch() == llvm::Triple::x86) {
+ switch (TargetTriple.getArch()) {
+ default:
+ break;
+
+ case llvm::Triple::x86:
// We use the existence of '/lib/<triple>' as a directory to detect some
// common hurd triples that don't quite match the Clang triple for both
// 32-bit and 64-bit targets. Multiarch fixes its install triples to these
// regardless of what the actual target triple is.
if (D.getVFS().exists(SysRoot + "/lib/i386-gnu"))
return "i386-gnu";
+ break;
+
+ case llvm::Triple::x86_64:
+ return "x86_64-gnu";
}
// For most architectures, just use whatever we have rather than trying to be
@@ -126,8 +134,12 @@ Tool *Hurd::buildAssembler() const {
}
std::string Hurd::getDynamicLinker(const ArgList &Args) const {
- if (getArch() == llvm::Triple::x86)
+ switch (getArch()) {
+ case llvm::Triple::x86:
return "/lib/ld.so";
+ case llvm::Triple::x86_64:
+ return "/lib/ld-x86-64.so.1";
+ }
llvm_unreachable("unsupported architecture");
}
diff --git a/clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/x86_64-gnu/10/crtbegin.o b/clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/x86_64-gnu/10/crtbegin.o
new file mode 100644
index 000000000000000..e69de29bb2d1d64
diff --git a/clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/x86_64-gnu/bin/as b/clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/x86_64-gnu/bin/as
new file mode 100755
index 000000000000000..e69de29bb2d1d64
diff --git a/clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/x86_64-gnu/bin/ld b/clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/x86_64-gnu/bin/ld
new file mode 100755
index 000000000000000..e69de29bb2d1d64
diff --git a/clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/x86_64-gnu/lib/.keep b/clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/x86_64-gnu/lib/.keep
new file mode 100644
index 000000000000000..e69de29bb2d1d64
diff --git a/clang/test/Driver/Inputs/basic_hurd_tree/lib/x86_64-gnu/.keep b/clang/test/Driver/Inputs/basic_hurd_tree/lib/x86_64-gnu/.keep
new file mode 100644
index 000000000000000..e69de29bb2d1d64
diff --git a/clang/test/Driver/Inputs/basic_hurd_tree/lib64/.keep b/clang/test/Driver/Inputs/basic_hurd_tree/lib64/.keep
new file mode 100644
index 000000000000000..e69de29bb2d1d64
diff --git a/clang/test/Driver/Inputs/basic_hurd_tree/usr/include/x86_64-gnu/.keep b/clang/test/Driver/Inputs/basic_hurd_tree/usr/include/x86_64-gnu/.keep
new file mode 100644
index 000000000000000..e69de29bb2d1d64
diff --git a/clang/test/Driver/Inputs/basic_hurd_tree/usr/include/x86_64-gnu/c++/10/.keep b/clang/test/Driver/Inputs/basic_hurd_tree/usr/include/x86_64-gnu/c++/10/.keep
new file mode 100644
index 000000000000000..e69de29bb2d1d64
diff --git a/clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/x86_64-gnu/10/crtbegin.o b/clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/x86_64-gnu/10/crtbegin.o
new file mode 100644
index 000000000000000..e69de29bb2d1d64
diff --git a/clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/x86_64-gnu/10/crtbeginS.o b/clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/x86_64-gnu/10/crtbeginS.o
new file mode 100644
index 000000000000000..e69de29bb2d1d64
diff --git a/clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/x86_64-gnu/10/crtbeginT.o b/clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/x86_64-gnu/10/crtbeginT.o
new file mode 100644
index 000000000000000..e69de29bb2d1d64
diff --git a/clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/x86_64-gnu/.keep b/clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/x86_64-gnu/.keep
new file mode 100644
index 000000000000000..e69de29bb2d1d64
diff --git a/clang/test/Driver/Inputs/basic_hurd_tree/usr/lib64/.keep b/clang/test/Driver/Inputs/basic_hurd_tree/usr/lib64/.keep
new file mode 100644
index 000000000000000..e69de29bb2d1d64
diff --git a/clang/test/Driver/hurd.cpp b/clang/test/Driver/hurd.cpp
index f76d2cd73a01662..3f02bd3d205cb71 100644
--- a/clang/test/Driver/hurd.cpp
+++ b/clang/test/Driver/hurd.cpp
@@ -78,3 +78,82 @@
// CHECK-CROSS: "{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/10/../../../../i686-gnu/bin/ld" {{.*}} "-m" "elf_i386"
// CHECK-CROSS: "{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/10/crtbegin.o"
// CHECK-CROSS: "-L{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/10/../../../../i686-gnu/lib"
+
+// RUN: %clang -### %s --target=x86_64-pc-hurd-gnu --sysroot=%S/Inputs/basic_hurd_tree \
+// RUN: --stdlib=platform 2>&1 | FileCheck --check-prefix=CHECK-64 %s
+// CHECK-64: "-cc1"
+// CHECK-64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-64-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-gnu/10/../../../../include/c++/10"
+/// Debian specific - the path component after 'include' is x86_64-gnu even
+/// though the installation is x86_64-gnu.
+// CHECK-64-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-gnu/10/../../../../include/x86_64-gnu/c++/10"
+// CHECK-64-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-gnu/10/../../../../include/c++/10/backward"
+// CHECK-64-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-64: "-internal-externc-isystem"
+// CHECK-64-SAME: {{^}} "[[SYSROOT]]/usr/include/x86_64-gnu"
+// CHECK-64-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-64-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// CHECK-64: "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-64: "-dynamic-linker" "/lib/ld-x86-64.so.1"
+// CHECK-64: "{{.*}}/usr/lib/gcc/x86_64-gnu/10/crtbegin.o"
+// CHECK-64: "-L
+// CHECK-64-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/x86_64-gnu/10"
+// CHECK-64-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/x86_64-gnu/10/../../../../lib64"
+// CHECK-64-SAME: {{^}} "-L[[SYSROOT]]/lib/x86_64-gnu"
+// CHECK-64-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib64"
+// CHECK-64-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/x86_64-gnu"
+// CHECK-64-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib64"
+// CHECK-64-SAME: {{^}} "-L[[SYSROOT]]/lib"
+// CHECK-64-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
+
+// RUN: %clang -### %s --target=x86_64-pc-hurd-gnu --sysroot=%S/Inputs/basic_hurd_tree \
+// RUN: --stdlib=platform -static 2>&1 | FileCheck --check-prefix=CHECK-64-STATIC %s
+// CHECK-64-STATIC: "-cc1"
+// CHECK-64-STATIC: "-static-define"
+// CHECK-64-STATIC: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-64-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-gnu/10/../../../../include/c++/10"
+/// Debian specific - the path component after 'include' is x86_64-gnu even
+/// though the installation is x86_64-gnu.
+// CHECK-64-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-gnu/10/../../../../include/x86_64-gnu/c++/10"
+// CHECK-64-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-gnu/10/../../../../include/c++/10/backward"
+// CHECK-64-STATIC-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-64-STATIC: "-internal-externc-isystem"
+// CHECK-64-STATIC-SAME: {{^}} "[[SYSROOT]]/usr/include/x86_64-gnu"
+// CHECK-64-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-64-STATIC-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// CHECK-64-STATIC: "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-64-STATIC-SAME: "-static"
+// CHECK-64-STATIC: "{{.*}}/usr/lib/gcc/x86_64-gnu/10/crtbeginT.o"
+// CHECK-64-STATIC: "-L
+// CHECK-64-STATIC-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/x86_64-gnu/10"
+// CHECK-64-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/x86_64-gnu/10/../../../../lib64"
+// CHECK-64-STATIC-SAME: {{^}} "-L[[SYSROOT]]/lib/x86_64-gnu"
+// CHECK-64-STATIC-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib64"
+// CHECK-64-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/x86_64-gnu"
+// CHECK-64-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib64"
+// CHECK-64-STATIC-SAME: {{^}} "-L[[SYSROOT]]/lib"
+// CHECK-64-STATIC-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
+
+// RUN: %clang -### %s --target=x86_64-pc-hurd-gnu --sysroot=%S/Inputs/basic_hurd_tree \
+// RUN: -shared 2>&1 | FileCheck --check-prefix=CHECK-64-SHARED %s
+// CHECK-64-SHARED: "{{.*}}ld" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-64-SHARED: "{{.*}}/usr/lib/gcc/x86_64-gnu/10/crtbeginS.o"
+// CHECK-64-SHARED: "-L
+// CHECK-64-SHARED-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/x86_64-gnu/10"
+// CHECK-64-SHARED-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc/x86_64-gnu/10/../../../../lib64"
+// CHECK-64-SHARED-SAME: {{^}} "-L[[SYSROOT]]/lib/x86_64-gnu"
+// CHECK-64-SHARED-SAME: {{^}} "-L[[SYSROOT]]/lib/../lib64"
+// CHECK-64-SHARED-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/x86_64-gnu"
+// CHECK-64-SHARED-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/../lib64"
+// CHECK-64-SHARED-SAME: {{^}} "-L[[SYSROOT]]/lib"
+// CHECK-64-SHARED-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
+
+// RUN: %clang -### -o %t %s 2>&1 -no-integrated-as -fuse-ld=ld \
+// RUN: --gcc-toolchain=%S/Inputs/basic_cross_hurd_tree/usr \
+// RUN: --target=x86_64-pc-gnu \
+// RUN: | FileCheck --check-prefix=CHECK-64-CROSS %s
+// CHECK-64-CROSS: "-cc1" "-triple" "x86_64-pc-hurd-gnu"
+// CHECK-64-CROSS: "{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/x86_64-gnu/10/../../../../x86_64-gnu/bin/as" "--64"
+// CHECK-64-CROSS: "{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/x86_64-gnu/10/../../../../x86_64-gnu/bin/ld" {{.*}} "-m" "elf_x86_64"
+// CHECK-64-CROSS: "{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/x86_64-gnu/10/crtbegin.o"
+// CHECK-64-CROSS: "-L{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/x86_64-gnu/10/../../../../x86_64-gnu/lib"
diff --git a/llvm/unittests/TargetParser/TripleTest.cpp b/llvm/unittests/TargetParser/TripleTest.cpp
index d3bde2986ea2cd1..e6018a1e0aaa831 100644
--- a/llvm/unittests/TargetParser/TripleTest.cpp
+++ b/llvm/unittests/TargetParser/TripleTest.cpp
@@ -111,6 +111,12 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::Linux, T.getOS());
EXPECT_EQ(Triple::MuslX32, T.getEnvironment());
+ T = Triple("x86_64-pc-hurd-gnu");
+ EXPECT_EQ(Triple::x86_64, T.getArch());
+ EXPECT_EQ(Triple::PC, T.getVendor());
+ EXPECT_EQ(Triple::Hurd, T.getOS());
+ EXPECT_EQ(Triple::GNU, T.getEnvironment());
+
T = Triple("arm-unknown-linux-android16");
EXPECT_EQ(Triple::arm, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
More information about the cfe-commits
mailing list