zig icon indicating copy to clipboard operation
zig copied to clipboard

`zig cc` cross compile to powerpc64le-linux-gnu is broken

Open messense opened this issue 3 years ago • 3 comments
trafficstars

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.

messense avatar Feb 24 '22 07:02 messense

powerpc64le-linux-musl has the same problem.

messense avatar Feb 24 '22 07:02 messense

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.

tsmanner avatar Apr 08 '22 21:04 tsmanner

~~I couldn't compile for powerpc64le-linux-gnu on powerpc64le. https://github.com/ziglang/zig/issues/1290#issuecomment-1298748945~~

rjzak avatar Nov 01 '22 15:11 rjzak

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

andrewrk avatar Dec 29 '22 02:12 andrewrk