[clang] 3caa32b - [Driver] Use Component in OpenBSD::getCompilerRT to find libraries
Frederic Cambus via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 26 12:12:31 PDT 2022
Author: Greg Steuck
Date: 2022-06-26T21:05:39+02:00
New Revision: 3caa32b26f5a1d4f2e3c9c3f1540a30fe06abe38
URL: https://github.com/llvm/llvm-project/commit/3caa32b26f5a1d4f2e3c9c3f1540a30fe06abe38
DIFF: https://github.com/llvm/llvm-project/commit/3caa32b26f5a1d4f2e3c9c3f1540a30fe06abe38.diff
LOG: [Driver] Use Component in OpenBSD::getCompilerRT to find libraries
Clang uses runtime libraries for some advanced features like
sanitizers. Different systems have different preferences about file
placement. OpenBSD with this change will use this name for ASan:
/usr/lib/clang/15.0.0/lib/libclang_rt.asan.a
Already committed to OpenBSD repository then amended to cover the
case of development tree.
Differential Revision: https://reviews.llvm.org/D109051
Added:
Modified:
clang/lib/Driver/ToolChains/OpenBSD.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/OpenBSD.cpp b/clang/lib/Driver/ToolChains/OpenBSD.cpp
index 62c430b66e5f7..54cf3cc89caf7 100644
--- a/clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ b/clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -17,6 +17,7 @@
#include "clang/Driver/SanitizerArgs.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Path.h"
+#include "llvm/Support/VirtualFileSystem.h"
using namespace clang::driver;
using namespace clang::driver::tools;
@@ -334,12 +335,21 @@ void OpenBSD::AddCXXStdlibLibArgs(const ArgList &Args,
CmdArgs.push_back(Profiling ? "-lpthread_p" : "-lpthread");
}
-std::string OpenBSD::getCompilerRT(const ArgList &Args,
- StringRef Component,
+std::string OpenBSD::getCompilerRT(const ArgList &Args, StringRef Component,
FileType Type) const {
- SmallString<128> Path(getDriver().SysRoot);
- llvm::sys::path::append(Path, "/usr/lib/libcompiler_rt.a");
- return std::string(Path.str());
+ if (Component == "builtins") {
+ SmallString<128> Path(getDriver().SysRoot);
+ llvm::sys::path::append(Path, "/usr/lib/libcompiler_rt.a");
+ return std::string(Path.str());
+ }
+ SmallString<128> P(getDriver().ResourceDir);
+ std::string CRTBasename =
+ buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/false);
+ llvm::sys::path::append(P, "lib", CRTBasename);
+ // Checks if this is the base system case which uses a
diff erent location.
+ if (getVFS().exists(P))
+ return std::string(P.str());
+ return ToolChain::getCompilerRT(Args, Component, Type);
}
Tool *OpenBSD::buildAssembler() const {
More information about the cfe-commits
mailing list