| ... | @@ -871,6 +871,7 @@ fn buildOutputType( | ... | @@ -871,6 +871,7 @@ fn buildOutputType( |
| 871 | var emit_h: Emit = .no; | 871 | var emit_h: Emit = .no; |
| 872 | var soname: SOName = undefined; | 872 | var soname: SOName = undefined; |
| 873 | var want_compiler_rt: ?bool = null; | 873 | var want_compiler_rt: ?bool = null; |
| | 874 | var zig_cc_explicitly_link_compiler_rt = false; |
| 874 | var want_ubsan_rt: ?bool = null; | 875 | var want_ubsan_rt: ?bool = null; |
| 875 | var linker_script: ?[]const u8 = null; | 876 | var linker_script: ?[]const u8 = null; |
| 876 | var version_script: ?[]const u8 = null; | 877 | var version_script: ?[]const u8 = null; |
| ... | @@ -2000,8 +2001,8 @@ fn buildOutputType( | ... | @@ -2000,8 +2001,8 @@ fn buildOutputType( |
| 2000 | try create_module.cli_link_inputs.append(arena, .{ .dso_exact = .{ | 2001 | try create_module.cli_link_inputs.append(arena, .{ .dso_exact = .{ |
| 2001 | .name = it.only_arg, | 2002 | .name = it.only_arg, |
| 2002 | } }); | 2003 | } }); |
| 2003 | } else { | 2004 | } else switch (target_util.classifyCompilerRtLibName(it.only_arg)) { |
| 2004 | try create_module.cli_link_inputs.append(arena, .{ .name_query = .{ | 2005 | .none => try create_module.cli_link_inputs.append(arena, .{ .name_query = .{ |
| 2005 | .name = it.only_arg, | 2006 | .name = it.only_arg, |
| 2006 | .query = .{ | 2007 | .query = .{ |
| 2007 | .must_link = must_link, | 2008 | .must_link = must_link, |
| ... | @@ -2011,7 +2012,21 @@ fn buildOutputType( | ... | @@ -2011,7 +2012,21 @@ fn buildOutputType( |
| 2011 | .search_strategy = lib_search_strategy, | 2012 | .search_strategy = lib_search_strategy, |
| 2012 | .allow_so_scripts = allow_so_scripts, | 2013 | .allow_so_scripts = allow_so_scripts, |
| 2013 | }, | 2014 | }, |
| 2014 | } }); | 2015 | } }), |
| | 2016 | .only_compiler_rt => { |
| | 2017 | // We need this variable separately from `want_compiler_rt` because of |
| | 2018 | // invocations such as `zig cc -lcompiler_rt -nostdlib`. If we just set |
| | 2019 | // `want_compiler_rt = true` here, processing of the later `-nostdlib` |
| | 2020 | // would undo that. |
| | 2021 | zig_cc_explicitly_link_compiler_rt = true; |
| | 2022 | }, |
| | 2023 | .only_libunwind => { |
| | 2024 | create_module.opts.link_libunwind = true; |
| | 2025 | }, |
| | 2026 | .both => { |
| | 2027 | zig_cc_explicitly_link_compiler_rt = true; |
| | 2028 | create_module.opts.link_libunwind = true; |
| | 2029 | }, |
| 2015 | } | 2030 | } |
| 2016 | }, | 2031 | }, |
| 2017 | .ignore => {}, | 2032 | .ignore => {}, |
| ... | @@ -3547,7 +3562,7 @@ fn buildOutputType( | ... | @@ -3547,7 +3562,7 @@ fn buildOutputType( |
| 3547 | .framework_dirs = create_module.framework_dirs.items, | 3562 | .framework_dirs = create_module.framework_dirs.items, |
| 3548 | .frameworks = resolved_frameworks.items, | 3563 | .frameworks = resolved_frameworks.items, |
| 3549 | .windows_lib_names = create_module.windows_libs.keys(), | 3564 | .windows_lib_names = create_module.windows_libs.keys(), |
| 3550 | .want_compiler_rt = want_compiler_rt, | 3565 | .want_compiler_rt = if (zig_cc_explicitly_link_compiler_rt) true else want_compiler_rt, |
| 3551 | .want_ubsan_rt = want_ubsan_rt, | 3566 | .want_ubsan_rt = want_ubsan_rt, |
| 3552 | .hash_style = hash_style, | 3567 | .hash_style = hash_style, |
| 3553 | .linker_script = linker_script, | 3568 | .linker_script = linker_script, |
| ... | @@ -3979,15 +3994,6 @@ fn createModule( | ... | @@ -3979,15 +3994,6 @@ fn createModule( |
| 3979 | continue; | 3994 | continue; |
| 3980 | } | 3995 | } |
| 3981 | | 3996 | |
| 3982 | switch (target_util.classifyCompilerRtLibName(lib_name)) { | | |
| 3983 | .none => {}, | | |
| 3984 | .only_libunwind, .both => { | | |
| 3985 | create_module.opts.link_libunwind = true; | | |
| 3986 | continue; | | |
| 3987 | }, | | |
| 3988 | .only_compiler_rt => continue, | | |
| 3989 | } | | |
| 3990 | | | |
| 3991 | if (target.isMinGW()) { | 3997 | if (target.isMinGW()) { |
| 3992 | const exists = mingw.libExists(arena, io, target, create_module.dirs.zig_lib, lib_name) catch |err| | 3998 | const exists = mingw.libExists(arena, io, target, create_module.dirs.zig_lib, lib_name) catch |err| |
| 3993 | fatal("failed to check zig installation for DLL import libs: {t}", .{err}); | 3999 | fatal("failed to check zig installation for DLL import libs: {t}", .{err}); |