diff options
| author | Dan Gohman <sunfish@mozilla.com> | 2019-11-25 09:28:31 -0800 |
|---|---|---|
| committer | Dan Gohman <sunfish@mozilla.com> | 2019-11-25 10:29:51 -0800 |
| commit | 872a53ef9489fcfbb48c6f8dd30bd9a9a026934f (patch) | |
| tree | d6e439ae180a50e94f500523c2f6b4ee38aa201b /clang/lib/Driver | |
| parent | 09555ce07176d279e8ba8bdb74bb8dbff0a3cb82 (diff) | |
| download | bcm5719-llvm-872a53ef9489fcfbb48c6f8dd30bd9a9a026934f.tar.gz bcm5719-llvm-872a53ef9489fcfbb48c6f8dd30bd9a9a026934f.zip | |
[WebAssembly] Change the llvm-lto dir to use the LLVM Version
Using the version instead of the VCS revision, which isn't available
when LLVM_APPEND_VC_REV is set. The bitcode format should be
backwards-compatible at least within a minor version, so the version
string should be sufficient.
Differential Revision: https://reviews.llvm.org/D70677
Diffstat (limited to 'clang/lib/Driver')
| -rw-r--r-- | clang/lib/Driver/ToolChains/WebAssembly.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp index a2a9dff79e5..55b82592c09 100644 --- a/clang/lib/Driver/ToolChains/WebAssembly.cpp +++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp @@ -118,6 +118,14 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA, } } +/// Given a base library directory, append path components to form the +/// LTO directory. +static std::string AppendLTOLibDir(const std::string &Dir) { + // The version allows the path to be keyed to the specific version of + // LLVM in used, as the bitcode format is not stable. + return Dir + "/llvm-lto/" LLVM_VERSION_STRING; +} + WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args) : ToolChain(D, Triple, Args) { @@ -126,26 +134,24 @@ WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple, getProgramPaths().push_back(getDriver().getInstalledDir()); + auto SysRoot = getDriver().SysRoot; if (getTriple().getOS() == llvm::Triple::UnknownOS) { // Theoretically an "unknown" OS should mean no standard libraries, however // it could also mean that a custom set of libraries is in use, so just add // /lib to the search path. Disable multiarch in this case, to discourage // paths containing "unknown" from acquiring meanings. - getFilePaths().push_back(getDriver().SysRoot + "/lib"); + getFilePaths().push_back(SysRoot + "/lib"); } else { const std::string MultiarchTriple = - getMultiarchTriple(getDriver(), Triple, getDriver().SysRoot); + getMultiarchTriple(getDriver(), Triple, SysRoot); if (D.isUsingLTO()) { - auto LLVMRevision = getLLVMRevision(); - if (!LLVMRevision.empty()) { - // For LTO, enable use of lto-enabled sysroot libraries too, if available. - // Note that the directory is keyed to the LLVM revision, as LLVM's - // bitcode format is not stable. - getFilePaths().push_back(getDriver().SysRoot + "/lib/" + MultiarchTriple + - "/llvm-lto/" + LLVMRevision); - } + // For LTO, enable use of lto-enabled sysroot libraries too, if available. + // Note that the directory is keyed to the LLVM revision, as LLVM's + // bitcode format is not stable. + auto Dir = AppendLTOLibDir(SysRoot + "/lib/" + MultiarchTriple); + getFilePaths().push_back(Dir); } - getFilePaths().push_back(getDriver().SysRoot + "/lib/" + MultiarchTriple); + getFilePaths().push_back(SysRoot + "/lib/" + MultiarchTriple); } } |

