File clang-improve-distro-detection.patch of Package rocm-llvm
diff --git a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp
index a7e7f169d..471d09396 100644
--- a/clang/lib/Driver/Distro.cpp
+++ b/clang/lib/Driver/Distro.cpp
@@ -34,17 +34,19 @@ static Distro::DistroType DetectOsRelease(llvm::vfs::FileSystem &VFS) {
// Obviously this can be improved a lot.
for (StringRef Line : Lines)
- if (Version == Distro::UnknownDistro && Line.starts_with("ID="))
- Version = llvm::StringSwitch<Distro::DistroType>(Line.substr(3))
- .Case("alpine", Distro::AlpineLinux)
- .Case("fedora", Distro::Fedora)
- .Case("gentoo", Distro::Gentoo)
- .Case("arch", Distro::ArchLinux)
+ if (Version == Distro::UnknownDistro && Line.starts_with("ID=")) {
+ StringRef DistroId = Line.substr(3).trim('"');
+ Version = llvm::StringSwitch<Distro::DistroType>(DistroId)
+ .StartsWithLower("alpine", Distro::AlpineLinux)
+ .StartsWithLower("fedora", Distro::Fedora)
+ .StartsWithLower("gentoo", Distro::Gentoo)
+ .StartsWithLower("arch", Distro::ArchLinux)
// On SLES, /etc/os-release was introduced in SLES 11.
- .Case("sles", Distro::OpenSUSE)
- .Case("opensuse", Distro::OpenSUSE)
- .Case("exherbo", Distro::Exherbo)
+ .StartsWithLower("sles", Distro::OpenSUSE)
+ .StartsWithLower("opensuse", Distro::OpenSUSE)
+ .StartsWithLower("exherbo", Distro::Exherbo)
.Default(Distro::UnknownDistro);
+ }
return Version;
}
@@ -228,7 +230,7 @@ static Distro::DistroType GetDistro(llvm::vfs::FileSystem &VFS,
if (onRealFS) {
// If we're backed by a real file system, perform
// the detection only once and save the result.
- static Distro::DistroType LinuxDistro = DetectDistro(VFS);
+ static Distro::DistroType LinuxDistro = Distro::OpenSUSE; // DetectDistro(VFS);
return LinuxDistro;
}
// This is mostly for passing tests which uses llvm::vfs::InMemoryFileSystem,
diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
index b8efd64cd..6ea191a98 100644
--- a/clang/test/Driver/linux-ld.c
+++ b/clang/test/Driver/linux-ld.c
@@ -1006,7 +1006,7 @@
// RUN: --target=armv7-linux-android23 \
// RUN: | FileCheck --check-prefix=CHECK-ANDROID-HASH-STYLE-M %s
// CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
-// CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
+// CHECK-ANDROID-HASH-STYLE-M: "--hash-style={{gnu|both}}"
// RUN: %clang -### %s -no-pie 2>&1 --target=mips64-linux-gnuabin32 \
// RUN: | FileCheck --check-prefix=CHECK-MIPS64EL-GNUABIN32 %s