diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-11-05 18:44:12 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-05 18:44:12 -0500 |
| commit | 702b809ea3e9b9dbdc1fd6efe9306442487e7103 (patch) | |
| tree | bd639378ad2931013ff49789aadfc2104093261c /lib/std/Build/Step | |
| parent | bec36aa7c028f2eaec94a2358f3e1326fcb9a30c (diff) | |
| parent | c893f837151d4764fd34911376836a01192b4d75 (diff) | |
| download | zig-702b809ea3e9b9dbdc1fd6efe9306442487e7103.tar.gz zig-702b809ea3e9b9dbdc1fd6efe9306442487e7103.zip | |
Merge pull request #17815 from Luukdegram/wasm-no-entry
wasm-linker: implement `-fno-entry` and correctly pass `--shared` and `--pie` when given
Diffstat (limited to 'lib/std/Build/Step')
| -rw-r--r-- | lib/std/Build/Step/Compile.zig | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig index 9ede31c917..2d08541545 100644 --- a/lib/std/Build/Step/Compile.zig +++ b/lib/std/Build/Step/Compile.zig @@ -189,7 +189,8 @@ dll_export_fns: ?bool = null, subsystem: ?std.Target.SubSystem = null, -entry_symbol_name: ?[]const u8 = null, +/// How the linker must handle the entry point of the executable. +entry: Entry = .default, /// List of symbols forced as undefined in the symbol table /// thus forcing their resolution by the linker. @@ -304,6 +305,18 @@ const FrameworkLinkInfo = struct { weak: bool = false, }; +const Entry = union(enum) { + /// Let the compiler decide whether to make an entry point and what to name + /// it. + default, + /// The executable will have no entry point. + disabled, + /// The executable will have an entry point with the default symbol name. + enabled, + /// The executable will have an entry point with the specified symbol name. + symbol_name: []const u8, +}; + pub const IncludeDir = union(enum) { path: LazyPath, path_system: LazyPath, @@ -1418,9 +1431,13 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { try zig_args.append(try std.fmt.allocPrint(b.allocator, "-ofmt={s}", .{@tagName(ofmt)})); } - if (self.entry_symbol_name) |entry| { - try zig_args.append("--entry"); - try zig_args.append(entry); + switch (self.entry) { + .default => {}, + .disabled => try zig_args.append("-fno-entry"), + .enabled => try zig_args.append("-fentry"), + .symbol_name => |entry_name| { + try zig_args.append(try std.fmt.allocPrint(b.allocator, "-fentry={s}", .{entry_name})); + }, } { |
