@@ -199,6 +199,19 @@ static bool findXcodeClangPath(llvm::SmallVectorImpl<char> &path) {
199
199
return !path.empty ();
200
200
}
201
201
202
+ static bool findXcodeClangLibPath (const Twine &libName,
203
+ llvm::SmallVectorImpl<char > &path) {
204
+ assert (path.empty ());
205
+
206
+ if (!findXcodeClangPath (path)) {
207
+ return false ;
208
+ }
209
+ llvm::sys::path::remove_filename (path); // 'clang'
210
+ llvm::sys::path::remove_filename (path); // 'bin'
211
+ llvm::sys::path::append (path, " lib" , libName);
212
+ return true ;
213
+ }
214
+
202
215
static void addVersionString (const ArgList &inputArgs, ArgStringList &arguments,
203
216
unsigned major, unsigned minor, unsigned micro) {
204
217
llvm::SmallString<8 > buf;
@@ -236,12 +249,15 @@ toolchains::Darwin::addLinkerInputArgs(InvocationInfo &II,
236
249
Arguments.push_back (" -filelist" );
237
250
Arguments.push_back (context.getTemporaryFilePath (" inputs" , " LinkFileList" ));
238
251
II.FilelistInfos .push_back (
239
- {Arguments.back (), file_types::TY_Object ,
252
+ {Arguments.back (), context. OI . CompilerOutputType ,
240
253
FilelistInfo::WhichFiles::InputJobsAndSourceInputActions});
241
254
} else {
242
255
addPrimaryInputsOfType (Arguments, context.Inputs , context.Args ,
243
256
file_types::TY_Object);
257
+ addPrimaryInputsOfType (Arguments, context.Inputs , context.Args ,
258
+ file_types::TY_LLVM_BC);
244
259
addInputsOfType (Arguments, context.InputActions , file_types::TY_Object);
260
+ addInputsOfType (Arguments, context.InputActions , file_types::TY_LLVM_BC);
245
261
}
246
262
247
263
@@ -271,11 +287,7 @@ static void findARCLiteLibPath(const toolchains::Darwin &TC,
271
287
// If we don't have a 'lib/arc/' directory, find the "arclite" library
272
288
// relative to the Clang in the active Xcode.
273
289
ARCLiteLib.clear ();
274
- if (findXcodeClangPath (ARCLiteLib)) {
275
- llvm::sys::path::remove_filename (ARCLiteLib); // 'clang'
276
- llvm::sys::path::remove_filename (ARCLiteLib); // 'bin'
277
- llvm::sys::path::append (ARCLiteLib, " lib" , " arc" );
278
- }
290
+ findXcodeClangLibPath (" arc" , ARCLiteLib);
279
291
}
280
292
}
281
293
@@ -304,6 +316,15 @@ toolchains::Darwin::addArgsToLinkARCLite(ArgStringList &Arguments,
304
316
}
305
317
}
306
318
319
+ void toolchains::Darwin::addLTOLibArgs (ArgStringList &Arguments,
320
+ const JobContext &context) const {
321
+ llvm::SmallString<128 > LTOLibPath;
322
+ if (findXcodeClangLibPath (" libLTO.dylib" , LTOLibPath)) {
323
+ Arguments.push_back (" -lto_library" );
324
+ Arguments.push_back (context.Args .MakeArgString (LTOLibPath));
325
+ }
326
+ }
327
+
307
328
void
308
329
toolchains::Darwin::addSanitizerArgs (ArgStringList &Arguments,
309
330
const DynamicLinkJobAction &job,
@@ -705,6 +726,10 @@ toolchains::Darwin::constructInvocation(const DynamicLinkJobAction &job,
705
726
706
727
addArgsToLinkARCLite (Arguments, context);
707
728
729
+ if (job.shouldPerformLTO ()) {
730
+ addLTOLibArgs (Arguments, context);
731
+ }
732
+
708
733
for (const Arg *arg :
709
734
context.Args .filtered (options::OPT_F, options::OPT_Fsystem)) {
710
735
Arguments.push_back (" -F" );
@@ -777,14 +802,17 @@ toolchains::Darwin::constructInvocation(const StaticLinkJobAction &job,
777
802
if (context.shouldUseInputFileList ()) {
778
803
Arguments.push_back (" -filelist" );
779
804
Arguments.push_back (context.getTemporaryFilePath (" inputs" , " LinkFileList" ));
780
- II.FilelistInfos .push_back ({Arguments.back (), file_types::TY_Object ,
805
+ II.FilelistInfos .push_back ({Arguments.back (), context. OI . CompilerOutputType ,
781
806
FilelistInfo::WhichFiles::InputJobs});
782
807
} else {
783
808
addPrimaryInputsOfType (Arguments, context.Inputs , context.Args ,
784
809
file_types::TY_Object);
810
+ addPrimaryInputsOfType (Arguments, context.Inputs , context.Args ,
811
+ file_types::TY_LLVM_BC);
785
812
}
786
813
787
814
addInputsOfType (Arguments, context.InputActions , file_types::TY_Object);
815
+ addInputsOfType (Arguments, context.InputActions , file_types::TY_LLVM_BC);
788
816
789
817
Arguments.push_back (" -o" );
790
818
0 commit comments