There is std.Build.Step.Compile.Entry
pub 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,
};
and the CLI flags -fentry and -fno-entry for specifying the name of the entry symbol of the executable or omitting an entry function altogether.
In lib/std/start.zig it assumes the name of the entry function:
const start_sym_name = if (native_arch.isMIPS()) "__start" else "_start";
The issue:
$ cat x.zig
pub export fn _start() void {}
$ zig build-exe x.zig # works
Now change _start to start and tell the compiler about it:
$ cat x.zig
pub export fn start() void {}
$ zig build-exe x.zig -fentry=start
zig-linux-x86_64/lib/std/start.zig:607:46: error: root struct of file 'x' has no member named 'main'
It should compile successfully.
Perhaps to fix this the Entry struct above should be moved into lib/std/builtin.zig (as std.builtin.Entry) and the entry option should be exposed through @import("builtin").
lib/std/start.zig then looks at @import("builtin").entry instead of assuming anything.
There is
std.Build.Step.Compile.Entryand the CLI flags
-fentryand-fno-entryfor specifying the name of the entry symbol of the executable or omitting an entry function altogether.In
lib/std/start.zigit assumes the name of the entry function:The issue:
Now change
_starttostartand tell the compiler about it:It should compile successfully.
Perhaps to fix this the
Entrystruct above should be moved intolib/std/builtin.zig(asstd.builtin.Entry) and the entry option should be exposed through@import("builtin").lib/std/start.zigthen looks at@import("builtin").entryinstead of assuming anything.