authorgravatar for rpkak@noreply.codeberg.orgrpkak <rpkak@noreply.codeberg.org> 2026-03-13 12:52:37+01:00
committergravatar for rpkak@noreply.codeberg.orgrpkak <rpkak@noreply.codeberg.org> 2026-03-13 13:24:33+01:00
log090ae3042e8e2fec2c2f8797bf78c8f6e6335a30
tree2c01eef965958aad532dfd8ebf1b8239c583241e
parentb15aa0540d03c92c7b822fbebc373bf4e76e3425
signaturebadge-check Signed by SSH key SHA256:A2g6ATENrgLKQcUdthsn72P0njmQxnHSimzwnyJsZzo

Set link_libunwind to true for zig build-exe -lunwind


1 files changed, 34 insertions(+), 25 deletions(-)

src/main.zig+34-25
...@@ -2001,32 +2001,32 @@ fn buildOutputType(...@@ -2001,32 +2001,32 @@ fn buildOutputType(
2001 try create_module.cli_link_inputs.append(arena, .{ .dso_exact = .{2001 try create_module.cli_link_inputs.append(arena, .{ .dso_exact = .{
2002 .name = it.only_arg,2002 .name = it.only_arg,
2003 } });2003 } });
2004 } else switch (target_util.classifyCompilerRtLibName(it.only_arg)) {2004 } else {
2005 .none => try create_module.cli_link_inputs.append(arena, .{ .name_query = .{2005 const compiler_rt_classification = target_util.classifyCompilerRtLibName(it.only_arg);
2006 .name = it.only_arg,2006 switch (compiler_rt_classification) {
2007 .query = .{2007 .only_compiler_rt, .both => {
2008 .must_link = must_link,2008 // We need this variable separately from `want_compiler_rt` because of
2009 .needed = needed,2009 // invocations such as `zig cc -lcompiler_rt -nostdlib`. If we just set
2010 .weak = false,2010 // `want_compiler_rt = true` here, processing of the later `-nostdlib`
2011 .preferred_mode = lib_preferred_mode,2011 // would undo that.
2012 .search_strategy = lib_search_strategy,2012 zig_cc_explicitly_link_compiler_rt = true;
2013 .allow_so_scripts = allow_so_scripts,
2014 },2013 },
2015 } }),2014 .none, .only_libunwind => {},
2016 .only_compiler_rt => {2015 }
2017 // We need this variable separately from `want_compiler_rt` because of2016 if (compiler_rt_classification != .only_compiler_rt) {
2018 // invocations such as `zig cc -lcompiler_rt -nostdlib`. If we just set2017 // The case in which this arg wants to link libunwind is handled in createModule.
2019 // `want_compiler_rt = true` here, processing of the later `-nostdlib`2018 try create_module.cli_link_inputs.append(arena, .{ .name_query = .{
2020 // would undo that.2019 .name = it.only_arg,
2021 zig_cc_explicitly_link_compiler_rt = true;2020 .query = .{
2022 },2021 .must_link = must_link,
2023 .only_libunwind => {2022 .needed = needed,
2024 create_module.opts.link_libunwind = true;2023 .weak = false,
2025 },2024 .preferred_mode = lib_preferred_mode,
2026 .both => {2025 .search_strategy = lib_search_strategy,
2027 zig_cc_explicitly_link_compiler_rt = true;2026 .allow_so_scripts = allow_so_scripts,
2028 create_module.opts.link_libunwind = true;2027 },
2029 },2028 } });
2029 }
2030 }2030 }
2031 },2031 },
2032 .ignore => {},2032 .ignore => {},
...@@ -3994,6 +3994,15 @@ fn createModule(...@@ -3994,6 +3994,15 @@ fn createModule(
3994 continue;3994 continue;
3995 }3995 }
39963996
3997 switch (target_util.classifyCompilerRtLibName(lib_name)) {
3998 .none => {},
3999 .only_libunwind, .both => {
4000 create_module.opts.link_libunwind = true;
4001 continue;
4002 },
4003 .only_compiler_rt => continue,
4004 }
4005
3997 if (target.isMinGW()) {4006 if (target.isMinGW()) {
3998 const exists = mingw.libExists(arena, io, target, create_module.dirs.zig_lib, lib_name) catch |err|4007 const exists = mingw.libExists(arena, io, target, create_module.dirs.zig_lib, lib_name) catch |err|
3999 fatal("failed to check zig installation for DLL import libs: {t}", .{err});4008 fatal("failed to check zig installation for DLL import libs: {t}", .{err});