Hello! The global assembly example in the Zig documentation in section 35.4 compiles for the linux-gnu target but not for the windows-gnu target.
const std = @import("std");
const expect = std.testing.expect;
comptime {
asm (
\\.global my_func;
\\.type my_func, @function;
\\my_func:
\\ lea (%rdi,%rsi,1),%eax
\\ retq
);
}
extern fn my_func(a: i32, b: i32) i32;
pub fn main() !void {
try expect(my_func(12, 34) == 46);
}
$ zig build-exe main.zig -target x86_64-linux-gnu
$ zig build-exe main.zig -target x86_64-windows-gnu
The build for the windows target produces the following error message:
`LLVM Emit Object... error: <inline asm>:2:7: expected absolute expression
.type my_func, @function;
^
How can this issue be resolved? Thanks.