authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-15 19:25:34-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 17:51:20-07:00
log638db680f4c6380bb193da520f29a7c587bfb719
treec1b813f52c7970b061e928e8c7b9e0d859a82ded
parentb54ad9317591873159594e673953088a21d66e7b

move dll_export_fns and rdynamic to Compilation.Config


8 files changed, 44 insertions(+), 46 deletions(-)

src/Compilation.zig+3-10
...@@ -956,7 +956,6 @@ pub const InitOptions = struct {...@@ -956,7 +956,6 @@ pub const InitOptions = struct {
956 emit_docs: ?EmitLoc = null,956 emit_docs: ?EmitLoc = null,
957 /// `null` means to not emit an import lib.957 /// `null` means to not emit an import lib.
958 emit_implib: ?EmitLoc = null,958 emit_implib: ?EmitLoc = null,
959 dll_export_fns: ?bool = false,
960 /// Normally when using LLD to link, Zig uses a file named "lld.id" in the959 /// Normally when using LLD to link, Zig uses a file named "lld.id" in the
961 /// same directory as the output binary which contains the hash of the link960 /// same directory as the output binary which contains the hash of the link
962 /// operation, allowing Zig to skip linking when the hash would be unchanged.961 /// operation, allowing Zig to skip linking when the hash would be unchanged.
...@@ -989,7 +988,6 @@ pub const InitOptions = struct {...@@ -989,7 +988,6 @@ pub const InitOptions = struct {
989 want_compiler_rt: ?bool = null,988 want_compiler_rt: ?bool = null,
990 want_lto: ?bool = null,989 want_lto: ?bool = null,
991 formatted_panics: ?bool = null,990 formatted_panics: ?bool = null,
992 rdynamic: bool = false,
993 function_sections: bool = false,991 function_sections: bool = false,
994 data_sections: bool = false,992 data_sections: bool = false,
995 no_builtin: bool = false,993 no_builtin: bool = false,
...@@ -1200,8 +1198,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -1200,8 +1198,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
12001198
1201 const link_libc = options.config.link_libc;1199 const link_libc = options.config.link_libc;
12021200
1203 const dll_export_fns = options.dll_export_fns orelse (is_dyn_lib or options.rdynamic);
1204
1205 const libc_dirs = try detectLibCIncludeDirs(1201 const libc_dirs = try detectLibCIncludeDirs(
1206 arena,1202 arena,
1207 options.zig_lib_directory.path.?,1203 options.zig_lib_directory.path.?,
...@@ -1524,10 +1520,8 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -1524,10 +1520,8 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
1524 .gc_sections = options.linker_gc_sections,1520 .gc_sections = options.linker_gc_sections,
1525 .eh_frame_hdr = link_eh_frame_hdr,1521 .eh_frame_hdr = link_eh_frame_hdr,
1526 .emit_relocs = options.link_emit_relocs,1522 .emit_relocs = options.link_emit_relocs,
1527 .rdynamic = options.rdynamic,
1528 .soname = options.soname,1523 .soname = options.soname,
1529 .compatibility_version = options.compatibility_version,1524 .compatibility_version = options.compatibility_version,
1530 .dll_export_fns = dll_export_fns,
1531 .each_lib_rpath = each_lib_rpath,1525 .each_lib_rpath = each_lib_rpath,
1532 .build_id = build_id,1526 .build_id = build_id,
1533 .disable_lld_caching = options.disable_lld_caching or cache_mode == .whole,1527 .disable_lld_caching = options.disable_lld_caching or cache_mode == .whole,
...@@ -1555,7 +1549,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -1555,7 +1549,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
1555 // Synchronize with other matching comments: ZigOnlyHashStuff1549 // Synchronize with other matching comments: ZigOnlyHashStuff
1556 hash.add(use_llvm);1550 hash.add(use_llvm);
1557 hash.add(options.config.use_lib_llvm);1551 hash.add(options.config.use_lib_llvm);
1558 hash.add(dll_export_fns);1552 hash.add(options.config.dll_export_fns);
1559 hash.add(options.config.is_test);1553 hash.add(options.config.is_test);
1560 hash.add(options.config.test_evented_io);1554 hash.add(options.config.test_evented_io);
1561 hash.addOptionalBytes(options.test_filter);1555 hash.addOptionalBytes(options.test_filter);
...@@ -2430,6 +2424,8 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes...@@ -2430,6 +2424,8 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
2430 man.hash.add(comp.config.import_memory);2424 man.hash.add(comp.config.import_memory);
2431 man.hash.add(comp.config.export_memory);2425 man.hash.add(comp.config.export_memory);
2432 man.hash.add(comp.config.shared_memory);2426 man.hash.add(comp.config.shared_memory);
2427 man.hash.add(comp.config.dll_export_fns);
2428 man.hash.add(comp.config.rdynamic);
24332429
2434 if (comp.bin_file) |lf| {2430 if (comp.bin_file) |lf| {
2435 man.hash.add(lf.stack_size);2431 man.hash.add(lf.stack_size);
...@@ -2442,7 +2438,6 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes...@@ -2442,7 +2438,6 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
2442 switch (lf.tag) {2438 switch (lf.tag) {
2443 .elf => {2439 .elf => {
2444 const elf = lf.cast(link.File.Elf).?;2440 const elf = lf.cast(link.File.Elf).?;
2445 man.hash.add(elf.rdynamic);
2446 man.hash.add(elf.eh_frame_hdr);2441 man.hash.add(elf.eh_frame_hdr);
2447 man.hash.add(elf.image_base);2442 man.hash.add(elf.image_base);
2448 man.hash.add(elf.emit_relocs);2443 man.hash.add(elf.emit_relocs);
...@@ -2468,7 +2463,6 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes...@@ -2468,7 +2463,6 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
2468 },2463 },
2469 .wasm => {2464 .wasm => {
2470 const wasm = lf.cast(link.File.Wasm).?;2465 const wasm = lf.cast(link.File.Wasm).?;
2471 man.hash.add(wasm.rdynamic);
2472 man.hash.addOptional(wasm.initial_memory);2466 man.hash.addOptional(wasm.initial_memory);
2473 man.hash.addOptional(wasm.max_memory);2467 man.hash.addOptional(wasm.max_memory);
2474 man.hash.addOptional(wasm.global_base);2468 man.hash.addOptional(wasm.global_base);
...@@ -2485,7 +2479,6 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes...@@ -2485,7 +2479,6 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
2485 },2479 },
2486 .coff => {2480 .coff => {
2487 const coff = lf.cast(link.File.Coff).?;2481 const coff = lf.cast(link.File.Coff).?;
2488 man.hash.add(coff.dll_export_fns);
2489 man.hash.add(coff.image_base);2482 man.hash.add(coff.image_base);
2490 man.hash.addOptional(coff.subsystem);2483 man.hash.addOptional(coff.subsystem);
2491 man.hash.add(coff.tsaware);2484 man.hash.add(coff.tsaware);
src/Compilation/Config.zig+17
...@@ -41,6 +41,8 @@ entry: ?[]const u8,...@@ -41,6 +41,8 @@ entry: ?[]const u8,
41debug_format: DebugFormat,41debug_format: DebugFormat,
42root_strip: bool,42root_strip: bool,
43root_error_tracing: bool,43root_error_tracing: bool,
44dll_export_fns: bool,
45rdynamic: bool,
4446
45pub const CFrontend = enum { clang, aro };47pub const CFrontend = enum { clang, aro };
4648
...@@ -93,6 +95,8 @@ pub const Options = struct {...@@ -93,6 +95,8 @@ pub const Options = struct {
93 shared_memory: ?bool = null,95 shared_memory: ?bool = null,
94 test_evented_io: bool = false,96 test_evented_io: bool = false,
95 debug_format: ?Config.DebugFormat = null,97 debug_format: ?Config.DebugFormat = null,
98 dll_export_fns: ?bool = null,
99 rdynamic: ?bool = null,
96};100};
97101
98pub fn resolve(options: Options) !Config {102pub fn resolve(options: Options) !Config {
...@@ -415,6 +419,17 @@ pub fn resolve(options: Options) !Config {...@@ -415,6 +419,17 @@ pub fn resolve(options: Options) !Config {
415419
416 const any_error_tracing = root_error_tracing or options.any_error_tracing;420 const any_error_tracing = root_error_tracing or options.any_error_tracing;
417421
422 const rdynamic = options.rdynamic orelse false;
423
424 const dll_export_fns = b: {
425 if (options.dll_export_fns) |x| break :b x;
426 if (rdynamic) break :b true;
427 break :b switch (options.output_mode) {
428 .Obj, .Exe => false,
429 .Lib => link_mode == .Dynamic,
430 };
431 };
432
418 return .{433 return .{
419 .output_mode = options.output_mode,434 .output_mode = options.output_mode,
420 .have_zcu = options.have_zcu,435 .have_zcu = options.have_zcu,
...@@ -443,6 +458,8 @@ pub fn resolve(options: Options) !Config {...@@ -443,6 +458,8 @@ pub fn resolve(options: Options) !Config {
443 .wasi_exec_model = wasi_exec_model,458 .wasi_exec_model = wasi_exec_model,
444 .debug_format = debug_format,459 .debug_format = debug_format,
445 .root_strip = root_strip,460 .root_strip = root_strip,
461 .dll_export_fns = dll_export_fns,
462 .rdynamic = rdynamic,
446 };463 };
447}464}
448465
src/codegen/llvm.zig+8-9
...@@ -1672,6 +1672,7 @@ pub const Object = struct {...@@ -1672,6 +1672,7 @@ pub const Object = struct {
1672 // because we call `updateExports` at the end of `updateFunc` and `updateDecl`.1672 // because we call `updateExports` at the end of `updateFunc` and `updateDecl`.
1673 const global_index = self.decl_map.get(decl_index) orelse return;1673 const global_index = self.decl_map.get(decl_index) orelse return;
1674 const decl = mod.declPtr(decl_index);1674 const decl = mod.declPtr(decl_index);
1675 const comp = mod.comp;
1675 if (decl.isExtern(mod)) {1676 if (decl.isExtern(mod)) {
1676 const decl_name = decl_name: {1677 const decl_name = decl_name: {
1677 const decl_name = mod.intern_pool.stringToSlice(decl.name);1678 const decl_name = mod.intern_pool.stringToSlice(decl.name);
...@@ -1696,7 +1697,8 @@ pub const Object = struct {...@@ -1696,7 +1697,8 @@ pub const Object = struct {
1696 try global_index.rename(decl_name, &self.builder);1697 try global_index.rename(decl_name, &self.builder);
1697 global_index.setLinkage(.external, &self.builder);1698 global_index.setLinkage(.external, &self.builder);
1698 global_index.setUnnamedAddr(.default, &self.builder);1699 global_index.setUnnamedAddr(.default, &self.builder);
1699 if (wantDllExports(mod)) global_index.setDllStorageClass(.default, &self.builder);1700 if (comp.config.dll_export_fns)
1701 global_index.setDllStorageClass(.default, &self.builder);
1700 if (self.di_map.get(decl)) |di_node| {1702 if (self.di_map.get(decl)) |di_node| {
1701 const decl_name_slice = decl_name.slice(&self.builder).?;1703 const decl_name_slice = decl_name.slice(&self.builder).?;
1702 if (try decl.isFunction(mod)) {1704 if (try decl.isFunction(mod)) {
...@@ -1762,7 +1764,8 @@ pub const Object = struct {...@@ -1762,7 +1764,8 @@ pub const Object = struct {
1762 );1764 );
1763 try global_index.rename(fqn, &self.builder);1765 try global_index.rename(fqn, &self.builder);
1764 global_index.setLinkage(.internal, &self.builder);1766 global_index.setLinkage(.internal, &self.builder);
1765 if (wantDllExports(mod)) global_index.setDllStorageClass(.default, &self.builder);1767 if (comp.config.dll_export_fns)
1768 global_index.setDllStorageClass(.default, &self.builder);
1766 global_index.setUnnamedAddr(.unnamed_addr, &self.builder);1769 global_index.setUnnamedAddr(.unnamed_addr, &self.builder);
1767 if (decl.val.getVariable(mod)) |decl_var| {1770 if (decl.val.getVariable(mod)) |decl_var| {
1768 const decl_namespace = mod.namespacePtr(decl.src_namespace);1771 const decl_namespace = mod.namespacePtr(decl.src_namespace);
...@@ -1821,7 +1824,9 @@ pub const Object = struct {...@@ -1821,7 +1824,9 @@ pub const Object = struct {
1821 exports: []const *Module.Export,1824 exports: []const *Module.Export,
1822 ) link.File.UpdateExportsError!void {1825 ) link.File.UpdateExportsError!void {
1823 global_index.setUnnamedAddr(.default, &o.builder);1826 global_index.setUnnamedAddr(.default, &o.builder);
1824 if (wantDllExports(mod)) global_index.setDllStorageClass(.dllexport, &o.builder);1827 const comp = mod.comp;
1828 if (comp.config.dll_export_fns)
1829 global_index.setDllStorageClass(.dllexport, &o.builder);
1825 global_index.setLinkage(switch (exports[0].opts.linkage) {1830 global_index.setLinkage(switch (exports[0].opts.linkage) {
1826 .Internal => unreachable,1831 .Internal => unreachable,
1827 .Strong => .external,1832 .Strong => .external,
...@@ -11758,9 +11763,3 @@ fn constraintAllowsRegister(constraint: []const u8) bool {...@@ -11758,9 +11763,3 @@ fn constraintAllowsRegister(constraint: []const u8) bool {
11758 }11763 }
11759 } else return false;11764 } else return false;
11760}11765}
11761
11762fn wantDllExports(zcu: *const Zcu) bool {
11763 const lf = zcu.bin_file.?;
11764 const coff = lf.cast(link.File.Coff) orelse return false;
11765 return coff.dll_export_fns;
11766}
src/link.zig-2
...@@ -88,7 +88,6 @@ pub const File = struct {...@@ -88,7 +88,6 @@ pub const File = struct {
88 image_base: ?u64,88 image_base: ?u64,
89 eh_frame_hdr: bool,89 eh_frame_hdr: bool,
90 emit_relocs: bool,90 emit_relocs: bool,
91 rdynamic: bool,
92 z_nodelete: bool,91 z_nodelete: bool,
93 z_notext: bool,92 z_notext: bool,
94 z_defs: bool,93 z_defs: bool,
...@@ -110,7 +109,6 @@ pub const File = struct {...@@ -110,7 +109,6 @@ pub const File = struct {
110 max_memory: ?u64,109 max_memory: ?u64,
111 export_symbol_names: []const []const u8,110 export_symbol_names: []const []const u8,
112 global_base: ?u64,111 global_base: ?u64,
113 dll_export_fns: bool,
114 each_lib_rpath: bool,112 each_lib_rpath: bool,
115 build_id: std.zig.BuildId,113 build_id: std.zig.BuildId,
116 disable_lld_caching: bool,114 disable_lld_caching: bool,
src/link/Coff.zig-2
...@@ -8,7 +8,6 @@ llvm_object: ?*LlvmObject = null,...@@ -8,7 +8,6 @@ llvm_object: ?*LlvmObject = null,
88
9base: link.File,9base: link.File,
10image_base: u64,10image_base: u64,
11dll_export_fns: bool,
12subsystem: ?std.Target.SubSystem,11subsystem: ?std.Target.SubSystem,
13tsaware: bool,12tsaware: bool,
14nxcompat: bool,13nxcompat: bool,
...@@ -416,7 +415,6 @@ pub fn createEmpty(...@@ -416,7 +415,6 @@ pub fn createEmpty(
416 .Obj => 0,415 .Obj => 0,
417 },416 },
418417
419 .dll_export_fns = options.dll_export_fns,
420 .subsystem = options.subsystem,418 .subsystem = options.subsystem,
421 .tsaware = options.tsaware,419 .tsaware = options.tsaware,
422 .nxcompat = options.nxcompat,420 .nxcompat = options.nxcompat,
src/link/Elf.zig+4-6
...@@ -1,6 +1,5 @@...@@ -1,6 +1,5 @@
1base: link.File,1base: link.File,
2image_base: u64,2image_base: u64,
3rdynamic: bool,
4eh_frame_hdr: bool,3eh_frame_hdr: bool,
5emit_relocs: bool,4emit_relocs: bool,
6z_nodelete: bool,5z_nodelete: bool,
...@@ -370,7 +369,7 @@ pub fn createEmpty(...@@ -370,7 +369,7 @@ pub fn createEmpty(
370 else => 0x1000,369 else => 0x1000,
371 };370 };
372 const is_dyn_lib = output_mode == .Lib and link_mode == .Dynamic;371 const is_dyn_lib = output_mode == .Lib and link_mode == .Dynamic;
373 const default_sym_version: elf.Elf64_Versym = if (is_dyn_lib or options.rdynamic)372 const default_sym_version: elf.Elf64_Versym = if (is_dyn_lib or comp.config.rdynamic)
374 elf.VER_NDX_GLOBAL373 elf.VER_NDX_GLOBAL
375 else374 else
376 elf.VER_NDX_LOCAL;375 elf.VER_NDX_LOCAL;
...@@ -402,7 +401,6 @@ pub fn createEmpty(...@@ -402,7 +401,6 @@ pub fn createEmpty(
402 };401 };
403 },402 },
404403
405 .rdynamic = options.rdynamic,
406 .eh_frame_hdr = options.eh_frame_hdr,404 .eh_frame_hdr = options.eh_frame_hdr,
407 .emit_relocs = options.emit_relocs,405 .emit_relocs = options.emit_relocs,
408 .z_nodelete = options.z_nodelete,406 .z_nodelete = options.z_nodelete,
...@@ -1725,7 +1723,7 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void {...@@ -1725,7 +1723,7 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void {
1725 try argv.append("--eh-frame-hdr");1723 try argv.append("--eh-frame-hdr");
1726 }1724 }
17271725
1728 if (self.rdynamic) {1726 if (comp.config.rdynamic) {
1729 try argv.append("--export-dynamic");1727 try argv.append("--export-dynamic");
1730 }1728 }
17311729
...@@ -2434,7 +2432,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v...@@ -2434,7 +2432,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
2434 man.hash.addOptional(self.sort_section);2432 man.hash.addOptional(self.sort_section);
2435 man.hash.add(self.eh_frame_hdr);2433 man.hash.add(self.eh_frame_hdr);
2436 man.hash.add(self.emit_relocs);2434 man.hash.add(self.emit_relocs);
2437 man.hash.add(self.rdynamic);2435 man.hash.add(comp.config.rdynamic);
2438 man.hash.addListOfBytes(self.lib_dirs);2436 man.hash.addListOfBytes(self.lib_dirs);
2439 man.hash.addListOfBytes(self.base.rpath_list);2437 man.hash.addListOfBytes(self.base.rpath_list);
2440 man.hash.add(self.each_lib_rpath);2438 man.hash.add(self.each_lib_rpath);
...@@ -2637,7 +2635,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v...@@ -2637,7 +2635,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
2637 try argv.append("--emit-relocs");2635 try argv.append("--emit-relocs");
2638 }2636 }
26392637
2640 if (self.rdynamic) {2638 if (comp.config.rdynamic) {
2641 try argv.append("--export-dynamic");2639 try argv.append("--export-dynamic");
2642 }2640 }
26432641
src/link/Wasm.zig+6-7
...@@ -39,7 +39,6 @@ pub const base_tag: link.File.Tag = .wasm;...@@ -39,7 +39,6 @@ pub const base_tag: link.File.Tag = .wasm;
39base: link.File,39base: link.File,
40import_symbols: bool,40import_symbols: bool,
41export_symbol_names: []const []const u8,41export_symbol_names: []const []const u8,
42rdynamic: bool,
43global_base: ?u64,42global_base: ?u64,
44initial_memory: ?u64,43initial_memory: ?u64,
45max_memory: ?u64,44max_memory: ?u64,
...@@ -563,7 +562,6 @@ pub fn createEmpty(...@@ -563,7 +562,6 @@ pub fn createEmpty(
563 .export_table = options.export_table,562 .export_table = options.export_table,
564 .import_symbols = options.import_symbols,563 .import_symbols = options.import_symbols,
565 .export_symbol_names = options.export_symbol_names,564 .export_symbol_names = options.export_symbol_names,
566 .rdynamic = options.rdynamic,
567 .global_base = options.global_base,565 .global_base = options.global_base,
568 .initial_memory = options.initial_memory,566 .initial_memory = options.initial_memory,
569 .max_memory = options.max_memory,567 .max_memory = options.max_memory,
...@@ -2973,8 +2971,9 @@ fn mergeTypes(wasm: *Wasm) !void {...@@ -2973,8 +2971,9 @@ fn mergeTypes(wasm: *Wasm) !void {
2973}2971}
29742972
2975fn setupExports(wasm: *Wasm) !void {2973fn setupExports(wasm: *Wasm) !void {
2976 const gpa = wasm.base.comp.gpa;2974 const comp = wasm.base.comp;
2977 if (wasm.base.comp.config.output_mode == .Obj) return;2975 const gpa = comp.gpa;
2976 if (comp.config.output_mode == .Obj) return;
2978 log.debug("Building exports from symbols", .{});2977 log.debug("Building exports from symbols", .{});
29792978
2980 const force_exp_names = wasm.export_symbol_names;2979 const force_exp_names = wasm.export_symbol_names;
...@@ -2999,7 +2998,7 @@ fn setupExports(wasm: *Wasm) !void {...@@ -2999,7 +2998,7 @@ fn setupExports(wasm: *Wasm) !void {
29992998
3000 for (wasm.resolved_symbols.keys()) |sym_loc| {2999 for (wasm.resolved_symbols.keys()) |sym_loc| {
3001 const symbol = sym_loc.getSymbol(wasm);3000 const symbol = sym_loc.getSymbol(wasm);
3002 if (!symbol.isExported(wasm.rdynamic)) continue;3001 if (!symbol.isExported(comp.config.rdynamic)) continue;
30033002
3004 const sym_name = sym_loc.getName(wasm);3003 const sym_name = sym_loc.getName(wasm);
3005 const export_name = if (wasm.export_names.get(sym_loc)) |name| name else blk: {3004 const export_name = if (wasm.export_names.get(sym_loc)) |name| name else blk: {
...@@ -4789,7 +4788,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !...@@ -4789,7 +4788,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !
4789 try argv.append(arg);4788 try argv.append(arg);
4790 }4789 }
47914790
4792 if (wasm.rdynamic) {4791 if (comp.config.rdynamic) {
4793 try argv.append("--export-dynamic");4792 try argv.append("--export-dynamic");
4794 }4793 }
47954794
...@@ -5288,7 +5287,7 @@ fn markReferences(wasm: *Wasm) !void {...@@ -5288,7 +5287,7 @@ fn markReferences(wasm: *Wasm) !void {
52885287
5289 for (wasm.resolved_symbols.keys()) |sym_loc| {5288 for (wasm.resolved_symbols.keys()) |sym_loc| {
5290 const sym = sym_loc.getSymbol(wasm);5289 const sym = sym_loc.getSymbol(wasm);
5291 if (sym.isExported(wasm.rdynamic) or sym.isNoStrip() or !do_garbage_collect) {5290 if (sym.isExported(comp.config.rdynamic) or sym.isNoStrip() or !do_garbage_collect) {
5292 try wasm.mark(sym_loc);5291 try wasm.mark(sym_loc);
5293 continue;5292 continue;
5294 }5293 }
src/main.zig+6-10
...@@ -786,7 +786,6 @@ fn buildOutputType(...@@ -786,7 +786,6 @@ fn buildOutputType(
786 arg_mode: ArgMode,786 arg_mode: ArgMode,
787) !void {787) !void {
788 var provided_name: ?[]const u8 = null;788 var provided_name: ?[]const u8 = null;
789 var dll_export_fns: ?bool = null;
790 var root_src_file: ?[]const u8 = null;789 var root_src_file: ?[]const u8 = null;
791 var version: std.SemanticVersion = .{ .major = 0, .minor = 0, .patch = 0 };790 var version: std.SemanticVersion = .{ .major = 0, .minor = 0, .patch = 0 };
792 var have_version = false;791 var have_version = false;
...@@ -824,7 +823,6 @@ fn buildOutputType(...@@ -824,7 +823,6 @@ fn buildOutputType(
824 var soname: SOName = undefined;823 var soname: SOName = undefined;
825 var want_native_include_dirs = false;824 var want_native_include_dirs = false;
826 var want_compiler_rt: ?bool = null;825 var want_compiler_rt: ?bool = null;
827 var rdynamic: bool = false;
828 var linker_script: ?[]const u8 = null;826 var linker_script: ?[]const u8 = null;
829 var version_script: ?[]const u8 = null;827 var version_script: ?[]const u8 = null;
830 var disable_c_depfile = false;828 var disable_c_depfile = false;
...@@ -1411,7 +1409,7 @@ fn buildOutputType(...@@ -1411,7 +1409,7 @@ fn buildOutputType(
1411 } else if (mem.eql(u8, arg, "-fno-error-tracing")) {1409 } else if (mem.eql(u8, arg, "-fno-error-tracing")) {
1412 mod_opts.error_tracing = false;1410 mod_opts.error_tracing = false;
1413 } else if (mem.eql(u8, arg, "-rdynamic")) {1411 } else if (mem.eql(u8, arg, "-rdynamic")) {
1414 rdynamic = true;1412 create_module.opts.rdynamic = true;
1415 } else if (mem.eql(u8, arg, "-fsoname")) {1413 } else if (mem.eql(u8, arg, "-fsoname")) {
1416 soname = .yes_default_value;1414 soname = .yes_default_value;
1417 } else if (mem.startsWith(u8, arg, "-fsoname=")) {1415 } else if (mem.startsWith(u8, arg, "-fsoname=")) {
...@@ -1472,9 +1470,9 @@ fn buildOutputType(...@@ -1472,9 +1470,9 @@ fn buildOutputType(
1472 lib_preferred_mode = .Static;1470 lib_preferred_mode = .Static;
1473 lib_search_strategy = .no_fallback;1471 lib_search_strategy = .no_fallback;
1474 } else if (mem.eql(u8, arg, "-fdll-export-fns")) {1472 } else if (mem.eql(u8, arg, "-fdll-export-fns")) {
1475 dll_export_fns = true;1473 create_module.opts.dll_export_fns = true;
1476 } else if (mem.eql(u8, arg, "-fno-dll-export-fns")) {1474 } else if (mem.eql(u8, arg, "-fno-dll-export-fns")) {
1477 dll_export_fns = false;1475 create_module.opts.dll_export_fns = false;
1478 } else if (mem.eql(u8, arg, "--show-builtin")) {1476 } else if (mem.eql(u8, arg, "--show-builtin")) {
1479 show_builtin = true;1477 show_builtin = true;
1480 emit_bin = .no;1478 emit_bin = .no;
...@@ -1882,7 +1880,7 @@ fn buildOutputType(...@@ -1882,7 +1880,7 @@ fn buildOutputType(
1882 create_module.opts.link_mode = .Dynamic;1880 create_module.opts.link_mode = .Dynamic;
1883 is_shared_lib = true;1881 is_shared_lib = true;
1884 },1882 },
1885 .rdynamic => rdynamic = true,1883 .rdynamic => create_module.opts.rdynamic = true,
1886 .wl => {1884 .wl => {
1887 var split_it = mem.splitScalar(u8, it.only_arg, ',');1885 var split_it = mem.splitScalar(u8, it.only_arg, ',');
1888 while (split_it.next()) |linker_arg| {1886 while (split_it.next()) |linker_arg| {
...@@ -2136,7 +2134,7 @@ fn buildOutputType(...@@ -2136,7 +2134,7 @@ fn buildOutputType(
2136 mem.eql(u8, arg, "--export-dynamic") or2134 mem.eql(u8, arg, "--export-dynamic") or
2137 mem.eql(u8, arg, "-export-dynamic"))2135 mem.eql(u8, arg, "-export-dynamic"))
2138 {2136 {
2139 rdynamic = true;2137 create_module.opts.rdynamic = true;
2140 } else if (mem.eql(u8, arg, "-version-script") or mem.eql(u8, arg, "--version-script")) {2138 } else if (mem.eql(u8, arg, "-version-script") or mem.eql(u8, arg, "--version-script")) {
2141 version_script = linker_args_it.nextOrFatal();2139 version_script = linker_args_it.nextOrFatal();
2142 } else if (mem.eql(u8, arg, "-O")) {2140 } else if (mem.eql(u8, arg, "-O")) {
...@@ -2295,7 +2293,7 @@ fn buildOutputType(...@@ -2295,7 +2293,7 @@ fn buildOutputType(
2295 } else if (mem.eql(u8, arg, "--high-entropy-va")) {2293 } else if (mem.eql(u8, arg, "--high-entropy-va")) {
2296 // This option does not do anything.2294 // This option does not do anything.
2297 } else if (mem.eql(u8, arg, "--export-all-symbols")) {2295 } else if (mem.eql(u8, arg, "--export-all-symbols")) {
2298 rdynamic = true;2296 create_module.opts.rdynamic = true;
2299 } else if (mem.eql(u8, arg, "--color-diagnostics") or2297 } else if (mem.eql(u8, arg, "--color-diagnostics") or
2300 mem.eql(u8, arg, "--color-diagnostics=always"))2298 mem.eql(u8, arg, "--color-diagnostics=always"))
2301 {2299 {
...@@ -3365,7 +3363,6 @@ fn buildOutputType(...@@ -3365,7 +3363,6 @@ fn buildOutputType(
3365 .emit_llvm_bc = emit_llvm_bc_resolved.data,3363 .emit_llvm_bc = emit_llvm_bc_resolved.data,
3366 .emit_docs = emit_docs_resolved.data,3364 .emit_docs = emit_docs_resolved.data,
3367 .emit_implib = emit_implib_resolved.data,3365 .emit_implib = emit_implib_resolved.data,
3368 .dll_export_fns = dll_export_fns,
3369 .lib_dirs = lib_dirs.items,3366 .lib_dirs = lib_dirs.items,
3370 .rpath_list = rpath_list.items,3367 .rpath_list = rpath_list.items,
3371 .symbol_wrap_set = symbol_wrap_set,3368 .symbol_wrap_set = symbol_wrap_set,
...@@ -3381,7 +3378,6 @@ fn buildOutputType(...@@ -3381,7 +3378,6 @@ fn buildOutputType(
3381 .wasi_emulated_libs = create_module.wasi_emulated_libs.items,3378 .wasi_emulated_libs = create_module.wasi_emulated_libs.items,
3382 .want_compiler_rt = want_compiler_rt,3379 .want_compiler_rt = want_compiler_rt,
3383 .hash_style = hash_style,3380 .hash_style = hash_style,
3384 .rdynamic = rdynamic,
3385 .linker_script = linker_script,3381 .linker_script = linker_script,
3386 .version_script = version_script,3382 .version_script = version_script,
3387 .disable_c_depfile = disable_c_depfile,3383 .disable_c_depfile = disable_c_depfile,