ziglang/zig

Failure to use atomics with arm-linux-musleabi target

link2xt opened this issue · 1 comments

Zig Version

0.11.0-dev.1928+3169f0529

Steps to Reproduce and Observed Behavior

Create file atom.c:

#include <stdatomic.h>

int main() {
        _Atomic int val;
        atomic_fetch_add_explicit(&val, 1, memory_order_relaxed);
        return 0;
}

Run

$ zig cc atom.c -target arm-linux-musleabi

This results in an error

LLD Link... ld.lld: error: undefined symbol: __atomic_fetch_add_4

I also tried to use -target thumb-linux-musleabi, but it resulted in segmentation fault even without atomics and I filed another bugreport #14891.

Same with Zig 0.10.1.

The problem actually occurs when attempting to compile OpenSSL: openssl/openssl#20490

Expected Behavior

Atomic operations from https://github.com/ziglang/zig/blob/master/lib/compiler_rt/atomics.zig should be available on 32-bit ARM.

Note: building with zig cc atom.c -target arm-linux-musleabihf works, no idea why.
Using it here for now: deltachat/deltachat-core-rust#4155
But it is not obvious how and why "hf" (hard float) affects atomics.