-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std.build.Builder.addObject
does not copy artifacts by default
#14079
Comments
I'm not sure what changed, but the The exact shell command is: zig build-obj <project>/root.zig -lc -femit-bin=<project>/packages/debug-bun-darwin-aarch64/bun-debug.o -fno-strip --cache-dir <project>/zig-cache --global-cache-dir /Users/jarred/.cache/zig --name bun-debug -fno-compiler-rt -fno-omit-frame-pointer -target native-native.11 -mcpu apple_m1 --mod build_options::<project>/zig-cache/c/85f8bbe9bf69b61d1147ff5eb7fce805/options.zig --mod async_io::<project>/src/io/io_darwin.zig --deps async_io,build_options -I <project>/src/deps -I <project>/src/deps --main-pkg-path /Users/jarred/Code/bun --enable-cache The |
you might need edit: relevant pr + issue #15245 |
Unfortunately it refuses |
Workaround: const obj = b.addObject(.{
.name = "obj-name",
// ...
});
obj.override_dest_dir = std.Build.InstallDir{ .custom = "obj" };
b.installArtifact(obj); Will output to |
Thanks! it works. |
This is working as designed. Not only are objects not installed by default, neither are executables, libraries, or tests. You need to add install steps into your build graph in order to install things. InstallArtifact is for installing binaries in standard ways, and there is no standard way to install object files. Therefore, you should use const install_object = b.addInstallFile(obj.getOutputSource(), "my_object_path.o");
b.getInstallStep().dependOn(&install_object.step); Note that you might want a different extension than Related: #16351 |
My reason for installing an object file is to get it into a known location where it can then be linked together with other object files as part of an existing Makefile project. Do you think this is a bad reason? Is there a better path? |
Zig's build system allows you to run external commands using a
In either case, you need to pass the path to the object file to a |
@mlugg beat me to the punch, but I'll finish what I was typing up too: For that use case, either If If |
Zig Version
0.11.0-dev.947+cf822c6dd
Steps to Reproduce and Observed Behavior
zig init-exe
zig build
zig-out
:Expected Behavior
zls-missing-root-obj.o
should exist inzig-out/lib/zls-missing-root-obj.o
or otherwise somewhere inzig-out
.The text was updated successfully, but these errors were encountered: