@@ -202,6 +202,19 @@ static bool findXcodeClangPath(llvm::SmallVectorImpl<char> &path) {
202
202
return !path.empty ();
203
203
}
204
204
205
+ static bool findXcodeClangLibPath (const Twine &libName,
206
+ llvm::SmallVectorImpl<char > &path) {
207
+ assert (path.empty ());
208
+
209
+ if (!findXcodeClangPath (path)) {
210
+ return false ;
211
+ }
212
+ llvm::sys::path::remove_filename (path); // 'clang'
213
+ llvm::sys::path::remove_filename (path); // 'bin'
214
+ llvm::sys::path::append (path, " lib" , libName);
215
+ return true ;
216
+ }
217
+
205
218
static void addVersionString (const ArgList &inputArgs, ArgStringList &arguments,
206
219
unsigned major, unsigned minor, unsigned micro) {
207
220
llvm::SmallString<8 > buf;
@@ -239,12 +252,15 @@ toolchains::Darwin::addLinkerInputArgs(InvocationInfo &II,
239
252
Arguments.push_back (" -filelist" );
240
253
Arguments.push_back (context.getTemporaryFilePath (" inputs" , " LinkFileList" ));
241
254
II.FilelistInfos .push_back (
242
- {Arguments.back (), file_types::TY_Object ,
255
+ {Arguments.back (), context. OI . CompilerOutputType ,
243
256
FilelistInfo::WhichFiles::InputJobsAndSourceInputActions});
244
257
} else {
245
258
addPrimaryInputsOfType (Arguments, context.Inputs , context.Args ,
246
259
file_types::TY_Object);
260
+ addPrimaryInputsOfType (Arguments, context.Inputs , context.Args ,
261
+ file_types::TY_LLVM_BC);
247
262
addInputsOfType (Arguments, context.InputActions , file_types::TY_Object);
263
+ addInputsOfType (Arguments, context.InputActions , file_types::TY_LLVM_BC);
248
264
}
249
265
250
266
@@ -274,11 +290,7 @@ static void findARCLiteLibPath(const toolchains::Darwin &TC,
274
290
// If we don't have a 'lib/arc/' directory, find the "arclite" library
275
291
// relative to the Clang in the active Xcode.
276
292
ARCLiteLib.clear ();
277
- if (findXcodeClangPath (ARCLiteLib)) {
278
- llvm::sys::path::remove_filename (ARCLiteLib); // 'clang'
279
- llvm::sys::path::remove_filename (ARCLiteLib); // 'bin'
280
- llvm::sys::path::append (ARCLiteLib, " lib" , " arc" );
281
- }
293
+ findXcodeClangLibPath (" arc" , ARCLiteLib);
282
294
}
283
295
}
284
296
@@ -307,6 +319,15 @@ toolchains::Darwin::addArgsToLinkARCLite(ArgStringList &Arguments,
307
319
}
308
320
}
309
321
322
+ void toolchains::Darwin::addLTOLibArgs (ArgStringList &Arguments,
323
+ const JobContext &context) const {
324
+ llvm::SmallString<128 > LTOLibPath;
325
+ if (findXcodeClangLibPath (" libLTO.dylib" , LTOLibPath)) {
326
+ Arguments.push_back (" -lto_library" );
327
+ Arguments.push_back (context.Args .MakeArgString (LTOLibPath));
328
+ }
329
+ }
330
+
310
331
void
311
332
toolchains::Darwin::addSanitizerArgs (ArgStringList &Arguments,
312
333
const DynamicLinkJobAction &job,
@@ -761,6 +782,10 @@ toolchains::Darwin::constructInvocation(const DynamicLinkJobAction &job,
761
782
762
783
addArgsToLinkARCLite (Arguments, context);
763
784
785
+ if (job.shouldPerformLTO ()) {
786
+ addLTOLibArgs (Arguments, context);
787
+ }
788
+
764
789
for (const Arg *arg :
765
790
context.Args .filtered (options::OPT_F, options::OPT_Fsystem)) {
766
791
Arguments.push_back (" -F" );
@@ -828,14 +853,17 @@ toolchains::Darwin::constructInvocation(const StaticLinkJobAction &job,
828
853
if (context.shouldUseInputFileList ()) {
829
854
Arguments.push_back (" -filelist" );
830
855
Arguments.push_back (context.getTemporaryFilePath (" inputs" , " LinkFileList" ));
831
- II.FilelistInfos .push_back ({Arguments.back (), file_types::TY_Object ,
856
+ II.FilelistInfos .push_back ({Arguments.back (), context. OI . CompilerOutputType ,
832
857
FilelistInfo::WhichFiles::InputJobs});
833
858
} else {
834
859
addPrimaryInputsOfType (Arguments, context.Inputs , context.Args ,
835
860
file_types::TY_Object);
861
+ addPrimaryInputsOfType (Arguments, context.Inputs , context.Args ,
862
+ file_types::TY_LLVM_BC);
836
863
}
837
864
838
865
addInputsOfType (Arguments, context.InputActions , file_types::TY_Object);
866
+ addInputsOfType (Arguments, context.InputActions , file_types::TY_LLVM_BC);
839
867
840
868
Arguments.push_back (" -o" );
841
869
0 commit comments