@@ -224,6 +224,27 @@ static bool wantsObjCRuntime(const llvm::Triple &triple) {
224
224
llvm_unreachable (" unknown Darwin OS" );
225
225
}
226
226
227
+ static void findARCLiteLibPath (const toolchains::Darwin &TC,
228
+ llvm::SmallVectorImpl<char > &ARCLiteLib) {
229
+ auto & D = TC.getDriver ();
230
+ llvm::sys::path::append (ARCLiteLib, D.getSwiftProgramPath ());
231
+
232
+ llvm::sys::path::remove_filename (ARCLiteLib); // 'swift'
233
+ llvm::sys::path::remove_filename (ARCLiteLib); // 'bin'
234
+ llvm::sys::path::append (ARCLiteLib, " lib" , " arc" );
235
+
236
+ if (!llvm::sys::fs::is_directory (ARCLiteLib)) {
237
+ // If we don't have a 'lib/arc/' directory, find the "arclite" library
238
+ // relative to the Clang in the active Xcode.
239
+ ARCLiteLib.clear ();
240
+ if (findXcodeClangPath (ARCLiteLib)) {
241
+ llvm::sys::path::remove_filename (ARCLiteLib); // 'clang'
242
+ llvm::sys::path::remove_filename (ARCLiteLib); // 'bin'
243
+ llvm::sys::path::append (ARCLiteLib, " lib" , " arc" );
244
+ }
245
+ }
246
+ }
247
+
227
248
ToolChain::InvocationInfo
228
249
toolchains::Darwin::constructInvocation (const DynamicLinkJobAction &job,
229
250
const JobContext &context) const {
@@ -235,7 +256,6 @@ toolchains::Darwin::constructInvocation(const DynamicLinkJobAction &job,
235
256
llvm::report_fatal_error (" -static-executable is not supported on Darwin" );
236
257
}
237
258
238
- const Driver &D = getDriver ();
239
259
const llvm::Triple &Triple = getTriple ();
240
260
241
261
// Configure the toolchain.
@@ -313,21 +333,8 @@ toolchains::Darwin::constructInvocation(const DynamicLinkJobAction &job,
313
333
if (context.Args .hasFlag (options::OPT_link_objc_runtime,
314
334
options::OPT_no_link_objc_runtime,
315
335
/* Default=*/ wantsObjCRuntime (Triple))) {
316
- llvm::SmallString<128 > ARCLiteLib (D.getSwiftProgramPath ());
317
- llvm::sys::path::remove_filename (ARCLiteLib); // 'swift'
318
- llvm::sys::path::remove_filename (ARCLiteLib); // 'bin'
319
- llvm::sys::path::append (ARCLiteLib, " lib" , " arc" );
320
-
321
- if (!llvm::sys::fs::is_directory (ARCLiteLib)) {
322
- // If we don't have a 'lib/arc/' directory, find the "arclite" library
323
- // relative to the Clang in the active Xcode.
324
- ARCLiteLib.clear ();
325
- if (findXcodeClangPath (ARCLiteLib)) {
326
- llvm::sys::path::remove_filename (ARCLiteLib); // 'clang'
327
- llvm::sys::path::remove_filename (ARCLiteLib); // 'bin'
328
- llvm::sys::path::append (ARCLiteLib, " lib" , " arc" );
329
- }
330
- }
336
+ llvm::SmallString<128 > ARCLiteLib;
337
+ findARCLiteLibPath (*this , ARCLiteLib);
331
338
332
339
if (!ARCLiteLib.empty ()) {
333
340
llvm::sys::path::append (ARCLiteLib, " libarclite_" );
@@ -340,9 +347,6 @@ toolchains::Darwin::constructInvocation(const DynamicLinkJobAction &job,
340
347
// Arclite depends on CoreFoundation.
341
348
Arguments.push_back (" -framework" );
342
349
Arguments.push_back (" CoreFoundation" );
343
- } else {
344
- // FIXME: We should probably diagnose this, but this is not a place where
345
- // we can emit diagnostics. Silently ignore it for now.
346
350
}
347
351
}
348
352
@@ -585,6 +589,23 @@ bool toolchains::Darwin::shouldStoreInvocationInDebugInfo() const {
585
589
return false ;
586
590
}
587
591
592
+ static void validateLinkObjcRuntimeARCLiteLib (const toolchains::Darwin &TC,
593
+ DiagnosticEngine &diags,
594
+ const llvm::opt::ArgList &args) {
595
+ auto Triple = TC.getTriple ();
596
+ if (args.hasFlag (options::OPT_link_objc_runtime,
597
+ options::OPT_no_link_objc_runtime,
598
+ /* Default=*/ wantsObjCRuntime (Triple))) {
599
+ llvm::SmallString<128 > ARCLiteLib;
600
+ findARCLiteLibPath (TC, ARCLiteLib);
601
+
602
+ if (ARCLiteLib.empty ()) {
603
+ diags.diagnose (SourceLoc (),
604
+ diag::warn_arclite_not_found_when_link_objc_runtime);
605
+ }
606
+ }
607
+ }
608
+
588
609
static void validateDeploymentTarget (const toolchains::Darwin &TC,
589
610
DiagnosticEngine &diags,
590
611
const llvm::opt::ArgList &args) {
@@ -621,6 +642,9 @@ static void validateDeploymentTarget(const toolchains::Darwin &TC,
621
642
void
622
643
toolchains::Darwin::validateArguments (DiagnosticEngine &diags,
623
644
const llvm::opt::ArgList &args) const {
645
+ // Validating arclite library path when link-objc-runtime.
646
+ validateLinkObjcRuntimeARCLiteLib (*this , diags, args);
647
+
624
648
// Validating apple platforms deployment targets.
625
649
validateDeploymentTarget (*this , diags, args);
626
650
0 commit comments