rust-cross / cargo-zigbuild

Compile Cargo project with zig as linker
MIT License
1.45k stars 52 forks source link

Atomics are not linked into the binary #109

Closed link2xt closed 1 year ago

link2xt commented 1 year ago

I have a minimal example at https://github.com/link2xt/openssl-cross-example It is a binary which links against OpenSSL via openssl-sys which in turn depends on the C code of OpenSSL provided in openssl-src crate.

There is a build script scripts/build.sh in the repository which calls cargo-build.

The build fails with errors like this:

          ld.lld: error: undefined symbol: __atomic_load
          >>> referenced by bio_lib.c:689 (crypto/bio/bio_lib.c:689)
          >>>               bio_lib.o:(BIO_free_all) in archive ...

even though Zig should provide __atomic_load.

messense commented 1 year ago

Probably due to https://github.com/ziglang/zig/issues/4911 which is a known upstream issue.

link2xt commented 1 year ago

Is there a known workaround?

link2xt commented 1 year ago

Probably due to ziglang/zig#4911 which is a known upstream issue.

Does not seem to be related, reported to Zig: https://github.com/ziglang/zig/issues/14889