zig icon indicating copy to clipboard operation
zig copied to clipboard

Cannot use WebAssembly 64-bit atomics

Open Aandreba opened this issue 1 year ago • 3 comments

Zig Version

0.12.0

Steps to Reproduce and Observed Behavior

Godbolt example

When trying to compile the following program:

pub export fn setTwelve(ptr: *i64) void {
    @atomicStore(i64, ptr, 12, .monotonic);
}

Using the following command:

zig build-obj --name output -fno-emit-bin -femit-asm=output.s -target wasm32-freestanding -mcpu baseline+atomics example.zig

The compiler returns the following error: example.zig:2:18: error: expected 32-bit integer type or smaller; found 64-bit integer type

Expected Behavior

The compiler should be able to use WebAssembly's 64-bit atomics whenever the atomics cpu feature is enabled.

Aandreba avatar May 22 '24 17:05 Aandreba

To use the 64-bit atomics, you need to use wasm64.

Rexicon226 avatar May 22 '24 18:05 Rexicon226

But the instructions exists for wasm32, why the wasm64 requirement?

Aandreba avatar May 22 '24 22:05 Aandreba

It shouldn't be required.

Vexu avatar May 23 '24 04:05 Vexu