diff options
author | Steven Wu <stevenwu@apple.com> | 2019-01-11 21:16:04 +0000 |
---|---|---|
committer | Steven Wu <stevenwu@apple.com> | 2019-01-11 21:16:04 +0000 |
commit | 27e3ee93074f6cdadfda79bfee6406bc540b88ea (patch) | |
tree | ac78bf5aa6863c2238d83da1ed610f0a56f3ec9b /lib/Driver/ToolChains/Darwin.cpp | |
parent | 4c57533ba3d00d3c41b96258eb7b6a4755b55b38 (diff) |
[Darwin][Driver] Don't pass a file as object_path_lto during ThinLTO
Summary:
After r327851, Driver::GetTemporaryPath will create the file rather than
just create a potientially unqine filename. If clang driver pass the
file as parameter as -object_path_lto, ld64 will pass it back to libLTO
as GeneratedObjectsDirectory, which is going to cause a LLVM ERROR if it
is not a directory.
Now during thinLTO, pass a temp directory path to linker instread.
rdar://problem/47194182
Reviewers: arphaman, dexonsmith
Reviewed By: arphaman
Subscribers: mehdi_amini, inglorion, jkorous, cfe-commits
Differential Revision: https://reviews.llvm.org/D56608
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@350970 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ToolChains/Darwin.cpp')
-rw-r--r-- | lib/Driver/ToolChains/Darwin.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/Driver/ToolChains/Darwin.cpp b/lib/Driver/ToolChains/Darwin.cpp index 50ecd13e69..c395c9a443 100644 --- a/lib/Driver/ToolChains/Darwin.cpp +++ b/lib/Driver/ToolChains/Darwin.cpp @@ -224,13 +224,20 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Args, options::OPT_fno_application_extension, false)) CmdArgs.push_back("-application_extension"); - if (D.isUsingLTO()) { - // If we are using LTO, then automatically create a temporary file path for - // the linker to use, so that it's lifetime will extend past a possible - // dsymutil step. - if (Version[0] >= 116 && NeedsTempPath(Inputs)) { - const char *TmpPath = C.getArgs().MakeArgString( - D.GetTemporaryPath("cc", types::getTypeTempSuffix(types::TY_Object))); + if (D.isUsingLTO() && Version[0] >= 116 && NeedsTempPath(Inputs)) { + std::string TmpPathName; + if (D.getLTOMode() == LTOK_Full) { + // If we are using full LTO, then automatically create a temporary file + // path for the linker to use, so that it's lifetime will extend past a + // possible dsymutil step. + TmpPathName = + D.GetTemporaryPath("cc", types::getTypeTempSuffix(types::TY_Object)); + } else if (D.getLTOMode() == LTOK_Thin) + // If we are using thin LTO, then create a directory instead. + TmpPathName = D.GetTemporaryDirectory("thinlto"); + + if (!TmpPathName.empty()) { + auto *TmpPath = C.getArgs().MakeArgString(TmpPathName); C.addTempFile(TmpPath); CmdArgs.push_back("-object_path_lto"); CmdArgs.push_back(TmpPath); |