| ... | ... | @@ -129,6 +129,7 @@ pub const ResolveError = error{ |
| 129 | 129 | LldCannotIncrementallyLink, |
| 130 | 130 | LtoRequiresLld, |
| 131 | 131 | SanitizeThreadRequiresLibCpp, |
| 132 | LibCRequiresLibUnwind, |
| 132 | 133 | LibCppRequiresLibUnwind, |
| 133 | 134 | OsRequiresLibC, |
| 134 | 135 | LibCppRequiresLibC, |
| ... | ... | @@ -312,8 +313,8 @@ pub fn resolve(options: Options) ResolveError!Config { |
| 312 | 313 | break :b false; |
| 313 | 314 | }; |
| 314 | 315 | |
| 315 | | const link_libunwind = b: { |
| 316 | | if (link_libcpp and target_util.libcNeedsLibUnwind(target)) { |
| 316 | var link_libunwind = b: { |
| 317 | if (link_libcpp and target_util.libCxxNeedsLibUnwind(target)) { |
| 317 | 318 | if (options.link_libunwind == false) return error.LibCppRequiresLibUnwind; |
| 318 | 319 | break :b true; |
| 319 | 320 | } |
| ... | ... | @@ -352,7 +353,7 @@ pub fn resolve(options: Options) ResolveError!Config { |
| 352 | 353 | break :b .static; |
| 353 | 354 | } |
| 354 | 355 | if (explicitly_exe_or_dyn_lib and link_libc and |
| 355 | | (target.isGnuLibC() or target_util.osRequiresLibC(target))) |
| 356 | (target_util.osRequiresLibC(target) or (target.isGnuLibC() and !options.resolved_target.is_native_abi))) |
| 356 | 357 | { |
| 357 | 358 | if (options.link_mode == .static) return error.LibCRequiresDynamicLinking; |
| 358 | 359 | break :b .dynamic; |
| ... | ... | @@ -367,11 +368,11 @@ pub fn resolve(options: Options) ResolveError!Config { |
| 367 | 368 | |
| 368 | 369 | if (options.link_mode) |link_mode| break :b link_mode; |
| 369 | 370 | |
| 370 | | if (explicitly_exe_or_dyn_lib and link_libc and |
| 371 | | options.resolved_target.is_native_abi and target.abi.isMusl()) |
| 371 | if (explicitly_exe_or_dyn_lib and link_libc and options.resolved_target.is_native_abi and |
| 372 | (target.isGnuLibC() or target.isMuslLibC())) |
| 372 | 373 | { |
| 373 | 374 | // If targeting the system's native ABI and the system's libc is |
| 374 | | // musl, link dynamically by default. |
| 375 | // glibc or musl, link dynamically by default. |
| 375 | 376 | break :b .dynamic; |
| 376 | 377 | } |
| 377 | 378 | |
| ... | ... | @@ -379,6 +380,13 @@ pub fn resolve(options: Options) ResolveError!Config { |
| 379 | 380 | break :b .static; |
| 380 | 381 | }; |
| 381 | 382 | |
| 383 | // This is done here to avoid excessive duplicated logic due to the complex dependencies between these options. |
| 384 | if (options.output_mode == .Exe and link_libc and target_util.libCNeedsLibUnwind(target, link_mode)) { |
| 385 | if (options.link_libunwind == false) return error.LibCRequiresLibUnwind; |
| 386 | |
| 387 | link_libunwind = true; |
| 388 | } |
| 389 | |
| 382 | 390 | const import_memory = options.import_memory orelse (options.output_mode == .Obj); |
| 383 | 391 | const export_memory = b: { |
| 384 | 392 | if (link_mode == .dynamic) { |