From 6d951aff7e32b1b0252d341e66517a9a9ee98a2d Mon Sep 17 00:00:00 2001 From: Luuk de Gram Date: Wed, 5 Jan 2022 20:47:04 +0100 Subject: wasm-linker: Only export symbols notated as such This exposes a function from stage2 to stage1 to append symbols to automatically export them. This happends under the following conditions: - Target is wasm - User has not provided --export/--rdynamic flags themselves. --- src/Compilation.zig | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index 40aabcae36..cca07c2a34 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -165,6 +165,10 @@ emit_docs: ?EmitLoc, work_queue_wait_group: WaitGroup, astgen_wait_group: WaitGroup, +/// Exported symbol names. This is only for when the target is wasm. +/// TODO: Remove this when Stage2 becomes the default compiler as it will already have this information. +export_symbol_names: std.ArrayListUnmanaged([]const u8) = .{}, + pub const SemaError = Module.SemaError; pub const CRTFile = struct { @@ -1877,6 +1881,11 @@ pub fn destroy(self: *Compilation) void { self.work_queue_wait_group.deinit(); self.astgen_wait_group.deinit(); + for (self.export_symbol_names.items) |symbol_name| { + self.gpa.free(symbol_name); + } + self.export_symbol_names.deinit(self.gpa); + // This destroys `self`. self.arena_state.promote(gpa).deinit(); } -- cgit v1.2.3