zig-bootstrap
                                
                                
                                
                                    zig-bootstrap copied to clipboard
                            
                            
                            
                        stage2 can't cross compile mingw
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
                                    
                                    
                                    
                                
Hmm, I cannot seem to repro this locally.
I don't know if it matters but this happens on a Zig binary built without stage1.
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 
                                    
                                    
                                    
                                
Mine is pretty much the same except that --search-prefix points at zig-bootstrap/out/native-linux-gnu-native/
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.
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.
This is caused by passing native to build, I think it should either resolve to the canonical value or be disallowed entirely.