You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The compile command on Linux is cargo zigbuild --release --target x86_64-pc-windows-gnu.
The CGO compile command is CGO_ENABLED=1 CC="zig cc -target x86_64-windows-gnu" GOOS=windows go build <...>.
I've searched extensively and tried many approaches, but I keep encountering errors:
With the latest stable or nightly zig (0.13.0 or 0.14.0-dev.850+ddcb7b1c1), I consistently face errors when compiling the library:
= note: warning: ignoring deprecated linker optimization setting '1'
error: unable to find dynamic system library 'msvcrt' using strategy 'paths_first'. searched paths:
Using zig 0.10.1, I can successfully compile the library, but I encounter an error when cross-building the CGO:
/usr/local/go/pkg/tool/linux_amd64/link: running zig failed: exit status 1
lld-link: error: duplicate symbol: ___chkstk_ms
>>> defined at compiler_rt.lib(compiler_rt.lib.obj)
>>> defined at src/x86_64.rs:18
>>> libhello-win.a(compiler_builtins-6c9e2f948258138b.compiler_builtins.2bfaa9d19ad82e39-cgu.135.rcgu.o)
Here is the reproduce:
git clone -b issue-1 https://github.com/hellodword/rust-plus-golang
cd rust-plus-golang
docker run --rm -it -v "$(pwd)":/io -w /io messense/cargo-zigbuild bash
# install Go
curl -fSL --output /tmp/go1.22.6.linux-amd64.tar.gz https://go.dev/dl/go1.22.6.linux-amd64.tar.gz && \
tar -C /usr/local -xzf /tmp/go1.22.6.linux-amd64.tar.gz
export PATH="$PATH:/usr/local/go/bin"
go version
make build-static
make build-static-windows
Any ideas?
The text was updated successfully, but these errors were encountered:
IMHO, zig cc isn't in good shape for windows gnu target yet (for example #251), it's better to reproduce your issue using zig cc directly and report any problems to zig to hopefully get it fixed in upstream.
I am attempting to wrap a Rust library and compile it on Linux, then statically link it on both Linux and Windows using CGO.
I plan to use
zig cc -target x86_64-windows-gnu
for a straightforward cross-build experience.The source code I'm utilizing is https://github.com/hellodword/rust-plus-golang/tree/issue-1
The compile command on Linux is
cargo zigbuild --release --target x86_64-pc-windows-gnu
.The CGO compile command is
CGO_ENABLED=1 CC="zig cc -target x86_64-windows-gnu" GOOS=windows go build <...>
.I've searched extensively and tried many approaches, but I keep encountering errors:
0.13.0
or0.14.0-dev.850+ddcb7b1c1
), I consistently face errors when compiling the library:0.10.1
, I can successfully compile the library, but I encounter an error when cross-building the CGO:Here is the reproduce:
Any ideas?
The text was updated successfully, but these errors were encountered: