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(
20012001 try create_module.cli_link_inputs.append(arena, .{ .dso_exact = .{
20022002 .name = it.only_arg,
20032003 } });
2004 } else switch (target_util.classifyCompilerRtLibName(it.only_arg)) {
2005 .none => try create_module.cli_link_inputs.append(arena, .{ .name_query = .{
2006 .name = it.only_arg,
2007 .query = .{
2008 .must_link = must_link,
2009 .needed = needed,
2010 .weak = false,
2011 .preferred_mode = lib_preferred_mode,
2012 .search_strategy = lib_search_strategy,
2013 .allow_so_scripts = allow_so_scripts,
2004 } else {
2005 const compiler_rt_classification = target_util.classifyCompilerRtLibName(it.only_arg);
2006 switch (compiler_rt_classification) {
2007 .only_compiler_rt, .both => {
2008 // We need this variable separately from `want_compiler_rt` because of
2009 // invocations such as `zig cc -lcompiler_rt -nostdlib`. If we just set
2010 // `want_compiler_rt = true` here, processing of the later `-nostdlib`
2011 // would undo that.
2012 zig_cc_explicitly_link_compiler_rt = true;
20142013 },
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 },
2014 .none, .only_libunwind => {},
2015 }
2016 if (compiler_rt_classification != .only_compiler_rt) {
2017 // The case in which this arg wants to link libunwind is handled in createModule.
2018 try create_module.cli_link_inputs.append(arena, .{ .name_query = .{
2019 .name = it.only_arg,
2020 .query = .{
2021 .must_link = must_link,
2022 .needed = needed,
2023 .weak = false,
2024 .preferred_mode = lib_preferred_mode,
2025 .search_strategy = lib_search_strategy,
2026 .allow_so_scripts = allow_so_scripts,
2027 },
2028 } });
2029 }
20302030 }
20312031 },
20322032 .ignore => {},
......@@ -3994,6 +3994,15 @@ fn createModule(
39943994 continue;
39953995 }
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
39974006 if (target.isMinGW()) {
39984007 const exists = mingw.libExists(arena, io, target, create_module.dirs.zig_lib, lib_name) catch |err|
39994008 fatal("failed to check zig installation for DLL import libs: {t}", .{err});