Skip to content

Commit 2129cc1

Browse files
committed
[clang][Darwin] Error out when missing requested libarclite library
Starting with the SDKs provided with Xcode 14.3, this library no longer exists. Before this change this results in an opaque linker error in the case that your deployment target is low enough that this library is added. This produces a more useful error message in that case. Differential Revision: https://reviews.llvm.org/D150988
1 parent 11b5b2a commit 2129cc1

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,9 @@ def warn_drv_darwin_sdk_invalid_settings : Warning<
619619
"SDK settings were ignored as 'SDKSettings.json' could not be parsed">,
620620
InGroup<DiagGroup<"darwin-sdk-settings">>;
621621

622+
def err_drv_darwin_sdk_missing_arclite : Error<
623+
"SDK does not contain 'libarclite' at the path '%0'; try increasing the minimum deployment target">;
624+
622625
def err_drv_trivial_auto_var_init_stop_after_missing_dependency : Error<
623626
"'-ftrivial-auto-var-init-stop-after=*' is used without "
624627
"'-ftrivial-auto-var-init=zero' or '-ftrivial-auto-var-init=pattern'">;

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,9 @@ void DarwinClang::AddLinkARCArgs(const ArgList &Args,
12211221
P += "macosx";
12221222
P += ".a";
12231223

1224+
if (!getVFS().exists(P))
1225+
getDriver().Diag(clang::diag::err_drv_darwin_sdk_missing_arclite) << P;
1226+
12241227
CmdArgs.push_back(Args.MakeArgString(P));
12251228
}
12261229

clang/test/Driver/arclite-link-external-toolchain.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
// RUN: -isysroot %t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk \
55
// RUN: %s 2>&1 | FileCheck %s
66

7+
// CHECK: error: SDK does not contain 'libarclite' at the path '
8+
// CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a';
9+
// CHECK: try increasing the minimum deployment target
710
// CHECK: -lfoo
811
// CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a

clang/test/Driver/arclite-link.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
// RUN: touch %t.o
2-
// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo -mmacosx-version-min=10.10 %t.o 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
2+
// RUN: mkdir -p %t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
3+
// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo -mmacosx-version-min=10.10 %t.o \
4+
// RUN: -isysroot %t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
35
// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.11 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
46
// RUN: %clang -### -target i386-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
57
// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -nostdlib %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOSTDLIB %s
68

9+
// CHECK-ARCLITE-OSX: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a';
10+
// CHECK-ARCLITE-OSX: try increasing the minimum deployment target
711
// CHECK-ARCLITE-OSX: -lfoo
812
// CHECK-ARCLITE-OSX: libarclite_macosx.a
913
// CHECK-ARCLITE-OSX: -framework

0 commit comments

Comments
 (0)