ziglang / zig-bootstrap

take off every zig
376 stars 91 forks source link

stage2 can't cross compile mingw #144

Closed Vexu closed 1 week ago

Vexu commented 1 year ago

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
kubkon commented 1 year ago

Hmm, I cannot seem to repro this locally.

Vexu commented 1 year ago

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

kubkon commented 1 year ago

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 
Vexu commented 1 year ago

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

andrewrk commented 1 year ago

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.

Vexu commented 1 year ago

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 commented 1 year ago

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

alexrp commented 3 weeks ago

@Vexu just to be clear, is the repro for this issue just ./build x86_64-windows native on a Linux machine?

That works for me FWIW.

Vexu commented 3 weeks ago

I think it happened when using ./build native-linux-gnu native but I haven't tried it since making this issue.

alexrp commented 1 week ago

Both ./build native-linux-gnu native and ./build native-windows-gnu native work for me on Linux.

Do you think it's safe to close this?

Vexu commented 1 week ago

Fine by me. I haven't ran into this since.