[clang] [Clang] Link libgcc_s.1.dylib when building for macOS 10.5 and older (PR #141401)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 4 18:00:12 PDT 2025


================
@@ -1645,14 +1645,14 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
     CmdArgs.push_back("-lSystem");
 
   // Select the dynamic runtime library and the target specific static library.
-  if (isTargetIOSBased()) {
-    // If we are compiling as iOS / simulator, don't attempt to link libgcc_s.1,
-    // it never went into the SDK.
-    // Linking against libgcc_s.1 isn't needed for iOS 5.0+
-    if (isIPhoneOSVersionLT(5, 0) && !isTargetIOSSimulator() &&
-        getTriple().getArch() != llvm::Triple::aarch64)
-      CmdArgs.push_back("-lgcc_s.1");
-  }
+  // If we are compiling as iOS / simulator, don't attempt to link libgcc_s.1,
----------------
Un1q32 wrote:

How does this look?
```
Select the dynamic runtime library and the target specific static library.
Some old Darwin versions put builtins, libunwind, and some other stuff in
libgcc_s.1.dylib. Newer versions moved those functions to libSystem, and
made libgcc_s.1.dylib a stub. We need libgcc_s on versions before MacOS X
10.6 and iOS 5. We also make sure to never link libgcc_s on aarch64,
since libgcc_s was made obsolete before it's existence.
```

https://github.com/llvm/llvm-project/pull/141401


More information about the cfe-commits mailing list