summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorSteven Wu <stevenwu@apple.com>2019-01-11 21:16:04 +0000
committerSteven Wu <stevenwu@apple.com>2019-01-11 21:16:04 +0000
commitc3399db63d159fe28ce4d5e23c3dd9e305ad8523 (patch)
treef957967c775a73e6a35a2c65f862d32946833236 /clang/lib
parent8da9a7538e6a7549b8b34f903f53bfbf378f4030 (diff)
downloadbcm5719-llvm-c3399db63d159fe28ce4d5e23c3dd9e305ad8523.tar.gz
bcm5719-llvm-c3399db63d159fe28ce4d5e23c3dd9e305ad8523.zip
[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 llvm-svn: 350970
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Driver/Driver.cpp11
-rw-r--r--clang/lib/Driver/ToolChains/Darwin.cpp21
2 files changed, 25 insertions, 7 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 977bff5bf71..4186fe28af4 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4478,6 +4478,17 @@ std::string Driver::GetTemporaryPath(StringRef Prefix, StringRef Suffix) const {
return Path.str();
}
+std::string Driver::GetTemporaryDirectory(StringRef Prefix) const {
+ SmallString<128> Path;
+ std::error_code EC = llvm::sys::fs::createUniqueDirectory(Prefix, Path);
+ if (EC) {
+ Diag(clang::diag::err_unable_to_make_temp) << EC.message();
+ return "";
+ }
+
+ return Path.str();
+}
+
std::string Driver::GetClPchPath(Compilation &C, StringRef BaseName) const {
SmallString<128> Output;
if (Arg *FpArg = C.getArgs().getLastArg(options::OPT__SLASH_Fp)) {
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index 50ecd13e698..c395c9a4430 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/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);
OpenPOWER on IntegriCloud