sunfish created this revision. Herald added subscribers: cfe-commits, dexonsmith, aheejin, jgravelle-google, inglorion, sbc100, mehdi_amini, dberris, dschuff. Herald added a project: clang.
This allows LTO-enabled builds of compiler-rt to be used. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D70687 Files: clang/lib/Driver/ToolChains/WebAssembly.cpp clang/lib/Driver/ToolChains/WebAssembly.h Index: clang/lib/Driver/ToolChains/WebAssembly.h =================================================================== --- clang/lib/Driver/ToolChains/WebAssembly.h +++ clang/lib/Driver/ToolChains/WebAssembly.h @@ -71,6 +71,7 @@ const char *getDefaultLinker() const override { return "wasm-ld"; } Tool *buildLinker() const override; + std::string getCompilerRTPath() const; }; } // end namespace toolchains Index: clang/lib/Driver/ToolChains/WebAssembly.cpp =================================================================== --- clang/lib/Driver/ToolChains/WebAssembly.cpp +++ clang/lib/Driver/ToolChains/WebAssembly.cpp @@ -155,6 +155,19 @@ } } +std::string WebAssembly::getCompilerRTPath() const { + // If we're doing LTO and we have an LTO library available, use it. + const auto &D = getDriver(); + if (D.isUsingLTO()) { + auto Dir = AppendLTOLibDir(ToolChain::getCompilerRTPath()); + if (llvm::sys::fs::exists(Dir)) + return Dir; + } + + // Otherwise just use the default. + return ToolChain::getCompilerRTPath(); +} + bool WebAssembly::IsMathErrnoDefault() const { return false; } bool WebAssembly::IsObjCNonFragileABIDefault() const { return true; }
Index: clang/lib/Driver/ToolChains/WebAssembly.h =================================================================== --- clang/lib/Driver/ToolChains/WebAssembly.h +++ clang/lib/Driver/ToolChains/WebAssembly.h @@ -71,6 +71,7 @@ const char *getDefaultLinker() const override { return "wasm-ld"; } Tool *buildLinker() const override; + std::string getCompilerRTPath() const; }; } // end namespace toolchains Index: clang/lib/Driver/ToolChains/WebAssembly.cpp =================================================================== --- clang/lib/Driver/ToolChains/WebAssembly.cpp +++ clang/lib/Driver/ToolChains/WebAssembly.cpp @@ -155,6 +155,19 @@ } } +std::string WebAssembly::getCompilerRTPath() const { + // If we're doing LTO and we have an LTO library available, use it. + const auto &D = getDriver(); + if (D.isUsingLTO()) { + auto Dir = AppendLTOLibDir(ToolChain::getCompilerRTPath()); + if (llvm::sys::fs::exists(Dir)) + return Dir; + } + + // Otherwise just use the default. + return ToolChain::getCompilerRTPath(); +} + bool WebAssembly::IsMathErrnoDefault() const { return false; } bool WebAssembly::IsObjCNonFragileABIDefault() const { return true; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits