zig-bootstrap icon indicating copy to clipboard operation
zig-bootstrap copied to clipboard

stage2 can't cross compile mingw

Open Vexu opened this issue 3 years ago • 7 comments

To reproduce on Linux:

$ touch empty.c
$ echo "pub fn main() void {}" > main.zig
$ zig build-exe a.zig a.c -target x86_64-windows -fstage1
$ zig build-exe main.zig empty.c -target x86_64-windows
error(mingw): clang exited with code 1 and stderr: error: unknown target triple 'native-unknown-linux-gnu', please use -triple or -arch

error(mingw): clang exited with code 1 and stderr: error: unknown target triple 'native-unknown-linux-gnu', please use -triple or -arch

error: unable to generate DLL import .lib file: ClangPreprocessorFailed

Vexu avatar Oct 21 '22 20:10 Vexu

Hmm, I cannot seem to repro this locally.

kubkon avatar Oct 24 '22 19:10 kubkon

I don't know if it matters but this happens on a Zig binary built without stage1.

Vexu avatar Oct 24 '22 19:10 Vexu

I wonder if this is due to how Zig is built. My invocation is something like:

$ ./stage3/bin/zig build -p stage4 -Dstatic-llvm --search-prefix /home/kubkon/dev/zig-bootstrap/out/x86_64-linux-musl-baseline 

kubkon avatar Oct 24 '22 20:10 kubkon

Mine is pretty much the same except that --search-prefix points at zig-bootstrap/out/native-linux-gnu-native/

Vexu avatar Oct 24 '22 20:10 Vexu

I haven't looked into this yet but as a clue - "native" is a zig-only concept; it's supposed to get resolved into a concrete architecture before it gets sent to LLVM.

andrewrk avatar Oct 24 '22 20:10 andrewrk

It seems to work properly on a zig binary built by cmake and a release zig binary built by the cmake zig but not on a debug Zig built by that release zig.

Vexu avatar Oct 24 '22 20:10 Vexu

This is caused by passing native to build, I think it should either resolve to the canonical value or be disallowed entirely.

Vexu avatar Dec 21 '22 21:12 Vexu