Repository navigation
Closed
Description
I have a project with a dependency on a C file. This works fine with plain zig build, but with -Drelease-safe=true the build results in:
zig build-exe src/main.zig -cflags -std=c99 -- deps/linenoise.c -OReleaseSafe --cache-dir zig-cache --global-cache-dir /Users/user/.cache/zig --name app -I deps --enable-cache
LLVM Emit Object...
error: MissingMainEntrypoint
app...The following command exited with error code 1:
zig build-exe src/main.zig -cflags -std=c99 -- deps/linenoise.c -OReleaseSafe --cache-dir zig-cache --global-cache-dir /Users/user/.cache/zig --name app -I deps --enable-cache
error: the following build command failed with exit code 1:
zig-cache/o/fdb0418b57bb58f267a95d7e400a17da/build zig /Users/user/app zig-cache /Users/user/.cache/zig --verbose -Drelease-safe=true
The zig binary is d1a41fe on macOS x64.
The object files are of type LLVM bitcode, wrapper x86_64 after the error.
Release builds work fine if I remove the dependency on the C file.
Here's the build file:
const std = @import("std");
pub fn build(b: *std.build.Builder) void {
const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions();
const exe = b.addExecutable("app", "src/main.zig");
if (!target.isWindows()) {
exe.addCSourceFile("deps/linenoise.c", &[_][]const u8{"-std=c99"});
exe.addIncludeDir("deps");
}
exe.setTarget(target);
exe.setBuildMode(mode);
exe.install();
const run_cmd = exe.run();
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}
Metadata
Metadata
Assignees
Labels
arch-x86_6464-bit x86bugObserved behavior contradicts documented or intended behaviorlinkingos-macosmacOSstage1The process of building from source via WebAssembly and the C backend.
Activity
kubkon commentedon Apr 19, 2021
Different linkers, but I wonder if the root cause is in any way related to #8531.
mikdusan commentedon Jan 1, 2023
Is this still a bug? I have no issue combining a
.con azig build-exe main.zig ...command line; tried debug + all 3 release modes.kubkon commentedon Jan 1, 2023
It's a missing feature tracked by #8680 I believe. Given that we currently have LTO disabled when targeting macOS, if shouldn't pop up unless someone explicitly passes an LLVM bitcode file as input to Zig.