aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorAlex Rønne Petersen <alex@alexrp.com>2025-08-05 22:32:35 +0200
committerAlex Rønne Petersen <alex@alexrp.com>2025-08-06 06:15:13 +0200
commit7ee6dab39fac7aa12fa9fd952bb2bdc28d5eabe8 (patch)
treeb97957e62077e78f6bf49836babcdb84b4ff772f /src/Sema.zig
parent9a158c1dae531f2a4e5667569bed38c27cbd4d57 (diff)
downloadzig-7ee6dab39fac7aa12fa9fd952bb2bdc28d5eabe8.tar.gz
zig-7ee6dab39fac7aa12fa9fd952bb2bdc28d5eabe8.zip
Revert "Sema: Stop adding Windows implib link inputs for `extern "..."` syntax."
This reverts commit b461d07a5464aec86c533434dab0b58edfffb331. After some discussion in the team, we've decided that this is too disruptive, especially because the linker errors are less than helpful. That's a fixable problem, so we might reconsider this in the future, but revert it for now.
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 5816990eb2..41e1444420 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -8906,6 +8906,14 @@ fn resolveGenericBody(
return sema.resolveConstDefinedValue(block, src, result, reason);
}
+/// Given a library name, examines if the library name should end up in
+/// `link.File.Options.windows_libs` table (for example, libc is always
+/// specified via dedicated flag `link_libc` instead),
+/// and puts it there if it doesn't exist.
+/// It also dupes the library name which can then be saved as part of the
+/// respective `Decl` (either `ExternFn` or `Var`).
+/// The liveness of the duped library name is tied to liveness of `Zcu`.
+/// To deallocate, call `deinit` on the respective `Decl` (`ExternFn` or `Var`).
pub fn handleExternLibName(
sema: *Sema,
block: *Block,
@@ -8955,6 +8963,11 @@ pub fn handleExternLibName(
.{ lib_name, lib_name },
);
}
+ comp.addLinkLib(lib_name) catch |err| {
+ return sema.fail(block, src_loc, "unable to add link lib '{s}': {s}", .{
+ lib_name, @errorName(err),
+ });
+ };
}
}