@@ -1642,14 +1642,16 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
16421642 CmdArgs.push_back (" -lSystem" );
16431643
16441644 // Select the dynamic runtime library and the target specific static library.
1645- if (isTargetIOSBased ()) {
1646- // If we are compiling as iOS / simulator, don't attempt to link libgcc_s.1,
1647- // it never went into the SDK.
1648- // Linking against libgcc_s.1 isn't needed for iOS 5.0+
1649- if (isIPhoneOSVersionLT (5 , 0 ) && !isTargetIOSSimulator () &&
1650- getTriple ().getArch () != llvm::Triple::aarch64)
1651- CmdArgs.push_back (" -lgcc_s.1" );
1652- }
1645+ // Some old Darwin versions put builtins, libunwind, and some other stuff in
1646+ // libgcc_s.1.dylib. MacOS X 10.6 and iOS 5 moved those functions to
1647+ // libSystem, and made libgcc_s.1.dylib a stub. We never link libgcc_s when
1648+ // building for aarch64 or iOS simulator, since libgcc_s was made obsolete
1649+ // before either existed.
1650+ if (getTriple ().getArch () != llvm::Triple::aarch64 &&
1651+ ((isTargetIOSBased () && isIPhoneOSVersionLT (5 , 0 ) &&
1652+ !isTargetIOSSimulator ()) ||
1653+ (isTargetMacOSBased () && isMacosxVersionLT (10 , 6 ))))
1654+ CmdArgs.push_back (" -lgcc_s.1" );
16531655 AddLinkRuntimeLib (Args, CmdArgs, " builtins" );
16541656}
16551657
0 commit comments