[clang] Don't assume location of compiler-rt for OpenBSD (#92183)
authorJohn Ericson <John.Ericson@Obsidian.Systems>
Wed, 15 May 2024 16:43:55 +0000 (12:43 -0400)
committerTom Stellard <tstellar@redhat.com>
Fri, 17 May 2024 23:26:37 +0000 (16:26 -0700)
If the `/usr/lib/...` path where compiler-rt is conventionally installed
on OpenBSD does not exist, fall back to the regular logic to find it.

This is a minimal change to allow OpenBSD cross compilation from a
toolchain that doesn't adopt all of OpenBSD's monorepo's conventions.

(cherry picked from commit be10746f3a4381456eb5082a968766201c17ab5d)

clang/lib/Driver/ToolChains/OpenBSD.cpp

index fd6aa4d7e68447b211bf5eca67b30c16968a1b35..00b6c520fcdd7265183249e9e67aea316ff97843 100644 (file)
@@ -371,7 +371,8 @@ std::string OpenBSD::getCompilerRT(const ArgList &Args, StringRef Component,
   if (Component == "builtins") {
     SmallString<128> Path(getDriver().SysRoot);
     llvm::sys::path::append(Path, "/usr/lib/libcompiler_rt.a");
-    return std::string(Path);
+    if (getVFS().exists(Path))
+      return std::string(Path);
   }
   SmallString<128> P(getDriver().ResourceDir);
   std::string CRTBasename =