kassane / anotherBuildStep

zig build add-on (add more toolchains [LLVM-based] support)
Mozilla Public License 2.0
1 stars 0 forks source link

rust: Cross-compiling build no have final binary #4

Open kassane opened 2 months ago

kassane commented 2 months ago

During some tests on #3 it was noticed that when building a binary with rustc + zig cc for cross-compilation, the final binary is not built. Only the host target works!

Why not use cargo-zigbuild?

Currently, no have cargo-support in ABS (AnotherBuildStep) - TODO

kassane commented 2 months ago

rustc not show -C linker=zcc output...

kassane commented 2 months ago

rust need rewrite using cargo!! :face_exhaling:

It may sound crazy, but by doing some tests using cargo-zigbuild instead of zigcc-wrapper in rustc cli commands, cross compiling successfully outputs the final binary.

WTF?? :eyes: Why won't rustc show the output of zcc?

$ cat $HOME/.cache/cargo-zigbuild/0.19.0/zigcc-aarch64-unknown-linux-gnu-aef7.sh
#!/bin/sh
exec "/home/kassane/.cargo/bin/cargo-zigbuild" zig cc -- -g -target aarch64-linux-gnu "$@"

$ cargo-zigbuild zig --help
Zig linker wrapper

Usage: cargo-zigbuild zig <COMMAND>

Commands:
  cc      `zig cc` wrapper
  c++     `zig c++` wrapper
  ar      `zig ar` wrapper
  ranlib  `zig ranlib` wrapper
  help    Print this message or the help of the given subcommand(s)

Options:
  -h, --help  Print help

Note: Another cargo-zigbuild commands need manifest file (a.k.a Cargo.toml)