zig
zig copied to clipboard
`zig cc` cross compile to powerpc64le-linux-gnu is broken
Zig Version
0.9.1
Steps to Reproduce
❯ cat hello.c
#include <stdio.h>
int main(int argc, char **argv) {
fprintf(stderr, "Hello, World!\n");
return 0;
}
❯ zig cc -o hello hello.c -target powerpc64le-linux-gnu
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
zig: warning: argument unused during compilation: '-mred-zone' [-Wunused-command-line-argument]
Expected Behavior
compilation successful.
Actual Behavior
The process hangs forever.
powerpc64le-linux-musl has the same problem.
I bumped into this recently as well and decided to try running it under gdb to poke around a little bit. I took 11 stack snapshots, a few in the five or so minutes, then a few more a couple of hours later. It does seem to be an infinite loop in LLVM, but I don't know how to isolate where or why that's happening.
11/11 stack traces are identical up to 0x00007ffff2bde933 in llvm::SelectionDAGISel::CodeGenAndEmitDAG() () from /nix/store/22s3qq6a1wck8cs156kljvb6qw05pq27-llvm-13.0.0-lib/lib/libLLVM-13.so
10/11 stack traces are identical up to 0x00007ffff2a6a51b in (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) () from /nix/store/22s3qq6a1wck8cs156kljvb6qw05pq27-llvm-13.0.0-lib/lib/libLLVM-13.so
There are some other patterns in the 10/11 stack traces, all related to this DAG traversal, which makes me think that LLVM is being handed a "DAG" that is not actually acyclic.
~~I couldn't compile for powerpc64le-linux-gnu on powerpc64le. https://github.com/ziglang/zig/issues/1290#issuecomment-1298748945~~
Tested with 0.11.0-dev.995+7350f0d9b and it works now. We have test coverage here:
https://github.com/ziglang/zig/blob/7350f0d9b5aecaf98998bc6591a649d9a7b7091f/test/tests.zig#L330-L345