[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
Tue Jun 3 21:10:50 PDT 2025
================
@@ -1645,14 +1645,15 @@ 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,
+ // it never went into the SDK.
+ // Linking against libgcc_s.1 isn't needed for iOS 5.0+ or macOS 10.6+
+ if (isTargetIOSBased() && isIPhoneOSVersionLT(5, 0) &&
+ !isTargetIOSSimulator() && getTriple().getArch() != llvm::Triple::aarch64)
+ CmdArgs.push_back("-lgcc_s.1");
+ else if (isTargetMacOSBased() && isMacosxVersionLT(10, 6) &&
+ getTriple().getArch() != llvm::Triple::aarch64)
----------------
Un1q32 wrote:
Could also do one big if statement.
```c++
if (getTriple().getArch() != llvm::Triple::aarch64 &&
((isTargetIOSBased() && isIPhoneOSVersionLT(5, 0) &&
!isTargetIOSSimulator()) ||
(isTargetMacOSBased() && isMacosxVersionLT(10, 6))))
CmdArgs.push_back("-lgcc_s.1");
```
https://github.com/llvm/llvm-project/pull/141401
More information about the cfe-commits
mailing list