@@ -198,6 +198,26 @@ static void addVersionString(const ArgList &inputArgs, ArgStringList &arguments,
198
198
arguments.push_back (inputArgs.MakeArgString (os.str ()));
199
199
}
200
200
201
+ // / Returns true if the compiler depends on features provided by the ObjC
202
+ // / runtime that are not present on the deployment target indicated by
203
+ // / \p triple.
204
+ static bool wantsObjCRuntime (const llvm::Triple &triple) {
205
+ assert ((!triple.isTvOS () || triple.isiOS ()) &&
206
+ " tvOS is considered a kind of iOS" );
207
+
208
+ // When updating the versions listed here, please record the most recent
209
+ // feature being depended on and when it was introduced:
210
+ //
211
+ // - The hook to override class_getImageName (macOS 10.14 and equivalent)
212
+ if (triple.isiOS ())
213
+ return triple.isOSVersionLT (12 );
214
+ if (triple.isMacOSX ())
215
+ return triple.isMacOSXVersionLT (10 , 14 );
216
+ if (triple.isWatchOS ())
217
+ return triple.isOSVersionLT (5 );
218
+ llvm_unreachable (" unknown Darwin OS" );
219
+ }
220
+
201
221
ToolChain::InvocationInfo
202
222
toolchains::Darwin::constructInvocation (const LinkJobAction &job,
203
223
const JobContext &context) const {
@@ -282,15 +302,9 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job,
282
302
if (llvm::sys::fs::exists (CompilerRTPath))
283
303
Arguments.push_back (context.Args .MakeArgString (CompilerRTPath));
284
304
285
- bool wantsObjCRuntime = false ;
286
- if (Triple.isiOS ())
287
- wantsObjCRuntime = Triple.isOSVersionLT (9 );
288
- else if (Triple.isMacOSX ())
289
- wantsObjCRuntime = Triple.isMacOSXVersionLT (10 , 11 );
290
-
291
305
if (context.Args .hasFlag (options::OPT_link_objc_runtime,
292
306
options::OPT_no_link_objc_runtime,
293
- /* Default=*/ wantsObjCRuntime)) {
307
+ /* Default=*/ wantsObjCRuntime (Triple) )) {
294
308
llvm::SmallString<128 > ARCLiteLib (D.getSwiftProgramPath ());
295
309
llvm::sys::path::remove_filename (ARCLiteLib); // 'swift'
296
310
llvm::sys::path::remove_filename (ARCLiteLib); // 'bin'
0 commit comments