[PATCH] D109051: Use Component in OpenBSD::getCompilerRT to find libraries
blackgnezdo updated this revision to Diff 386414. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D109051/new/ https://reviews.llvm.org/D109051 Files: clang/lib/Driver/ToolChains/OpenBSD.cpp Index: clang/lib/Driver/ToolChains/OpenBSD.cpp === --- clang/lib/Driver/ToolChains/OpenBSD.cpp +++ 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; @@ -324,12 +325,21 @@ 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 different location. + if (getVFS().exists(P)) +return std::string(P.str()); + return ToolChain::getCompilerRT(Args, Component, Type); } Tool *OpenBSD::buildAssembler() const { Index: clang/lib/Driver/ToolChains/OpenBSD.cpp === --- clang/lib/Driver/ToolChains/OpenBSD.cpp +++ 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; @@ -324,12 +325,21 @@ 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 different location. + if (getVFS().exists(P)) +return std::string(P.str()); + return ToolChain::getCompilerRT(Args, Component, Type); } Tool *OpenBSD::buildAssembler() const { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D109051: Use Component in OpenBSD::getCompilerRT to find libraries
blackgnezdo added a comment. I reformatted with clang-format to address the lint complaint. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D109051/new/ https://reviews.llvm.org/D109051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D109051: Use Component in OpenBSD::getCompilerRT to find libraries
blackgnezdo created this revision. blackgnezdo added a reviewer: brad. Herald added a subscriber: krytarowski. blackgnezdo requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. OpenBSD with this change would use this name for ASan: /usr/lib/clang/11.1.0/lib/libclang_rt.asan.a Already submitted to OpenBSD repository. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D109051 Files: clang/lib/Driver/ToolChains/OpenBSD.cpp Index: clang/lib/Driver/ToolChains/OpenBSD.cpp === --- clang/lib/Driver/ToolChains/OpenBSD.cpp +++ clang/lib/Driver/ToolChains/OpenBSD.cpp @@ -302,9 +302,17 @@ 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()); + } else { +SmallString<128> P(getDriver().ResourceDir); +std::string CRTBasename = +getCompilerRTBasename(Args, Component, Type, /*AddArch=*/false); +llvm::sys::path::append(P, "lib", CRTBasename); +return std::string(P.str()); + } } Tool *OpenBSD::buildAssembler() const { Index: clang/lib/Driver/ToolChains/OpenBSD.cpp === --- clang/lib/Driver/ToolChains/OpenBSD.cpp +++ clang/lib/Driver/ToolChains/OpenBSD.cpp @@ -302,9 +302,17 @@ 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()); + } else { +SmallString<128> P(getDriver().ResourceDir); +std::string CRTBasename = +getCompilerRTBasename(Args, Component, Type, /*AddArch=*/false); +llvm::sys::path::append(P, "lib", CRTBasename); +return std::string(P.str()); + } } Tool *OpenBSD::buildAssembler() const { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D109051: Use Component in OpenBSD::getCompilerRT to find libraries
blackgnezdo added a comment. OpenBSD commit: https://github.com/openbsd/src/commit/0b99cc4d5d8311a90145e8f4c6ae23275c275c52 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D109051/new/ https://reviews.llvm.org/D109051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D109051: Use Component in OpenBSD::getCompilerRT to find libraries
blackgnezdo updated this revision to Diff 370515. blackgnezdo edited the summary of this revision. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D109051/new/ https://reviews.llvm.org/D109051 Files: clang/lib/Driver/ToolChains/OpenBSD.cpp Index: clang/lib/Driver/ToolChains/OpenBSD.cpp === --- clang/lib/Driver/ToolChains/OpenBSD.cpp +++ clang/lib/Driver/ToolChains/OpenBSD.cpp @@ -16,6 +16,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; @@ -304,9 +305,19 @@ 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()); + } else { +SmallString<128> P(getDriver().ResourceDir); +std::string CRTBasename = +buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/false); +llvm::sys::path::append(P, "lib", CRTBasename); +if (getVFS().exists(P)) + return std::string(P.str()); +return ToolChain::getCompilerRT(Args, Component, Type); + } } Tool *OpenBSD::buildAssembler() const { Index: clang/lib/Driver/ToolChains/OpenBSD.cpp === --- clang/lib/Driver/ToolChains/OpenBSD.cpp +++ clang/lib/Driver/ToolChains/OpenBSD.cpp @@ -16,6 +16,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; @@ -304,9 +305,19 @@ 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()); + } else { +SmallString<128> P(getDriver().ResourceDir); +std::string CRTBasename = +buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/false); +llvm::sys::path::append(P, "lib", CRTBasename); +if (getVFS().exists(P)) + return std::string(P.str()); +return ToolChain::getCompilerRT(Args, Component, Type); + } } Tool *OpenBSD::buildAssembler() const { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D109051: Use Component in OpenBSD::getCompilerRT to find libraries
blackgnezdo updated this revision to Diff 370540. blackgnezdo added a comment. Addressed the clang-tidy complaint. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D109051/new/ https://reviews.llvm.org/D109051 Files: clang/lib/Driver/ToolChains/OpenBSD.cpp Index: clang/lib/Driver/ToolChains/OpenBSD.cpp === --- clang/lib/Driver/ToolChains/OpenBSD.cpp +++ clang/lib/Driver/ToolChains/OpenBSD.cpp @@ -16,6 +16,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; @@ -304,9 +305,19 @@ 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 different location. + if (getVFS().exists(P)) +return std::string(P.str()); + return ToolChain::getCompilerRT(Args, Component, Type); } Tool *OpenBSD::buildAssembler() const { Index: clang/lib/Driver/ToolChains/OpenBSD.cpp === --- clang/lib/Driver/ToolChains/OpenBSD.cpp +++ clang/lib/Driver/ToolChains/OpenBSD.cpp @@ -16,6 +16,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; @@ -304,9 +305,19 @@ 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 different location. + if (getVFS().exists(P)) +return std::string(P.str()); + return ToolChain::getCompilerRT(Args, Component, Type); } Tool *OpenBSD::buildAssembler() const { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits