ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
33.79k stars 2.47k forks source link

Error building Zig source: selected processor does not support system register name 'id_aa64mmfr2_el1' #21435

Open saltzm opened 2 days ago

saltzm commented 2 days ago

I am attempting to build zig from source in an Ubuntu VM on a Macbook Pro with an M1 chip.

I used the clang+llvm binaries from here, choosing this one clang+llvm-18.1.8-aarch64-linux-gnu.tar.xz.

Used

mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=<decompressed clang+llvm directory>

And then I'm getting the following error:

~/code/zig/build$ make install
[ 36%] Built target zigcpp
[ 47%] Built target zig-wasm2c
[ 52%] Building C object CMakeFiles/zig1.dir/zig1.c.o
[ 57%] Building C object CMakeFiles/zig1.dir/stage1/wasi.c.o
[ 63%] Linking C executable zig1
[ 68%] Built target zig1
[ 73%] Running zig1.wasm to produce /home/parallels/code/zig/build/compiler_rt.c
[ 78%] Running zig1.wasm to produce /home/parallels/code/zig/build/zig2.c
Scanning dependencies of target zig2
[ 84%] Building C object CMakeFiles/zig2.dir/zig2.c.o
/tmp/cc8a8trg.s: Assembler messages:
/tmp/cc8a8trg.s:3602308: Error: selected processor does not support system register name 'id_aa64mmfr2_el1'
make[2]: *** [CMakeFiles/zig2.dir/build.make:1049: CMakeFiles/zig2.dir/zig2.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:112: CMakeFiles/zig2.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
alexrp commented 2 days ago

gcc --version && as --version?

saltzm commented 2 days ago
$ gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
...
$ as --version
GNU assembler (GNU Binutils for Ubuntu) 2.34
...
$ cmake --version
cmake version 3.16.3
saltzm commented 2 days ago

Ah, I just noticed this note from the build from source instructions:

LLVM, Clang, LLD development libraries == 18.x, compiled with the same gcc or clang version above

I just downloaded the binary directly from the llvm site rather than compiling from source locally, in case that makes a difference

alexrp commented 2 days ago

compiled with the same gcc or clang version above

This is not likely to be the issue, I think. The problem here is more likely that your gcc/as versions are too old. Ubuntu should have newer versions in its repos with an explicit version suffix; I suggest trying with these first of all. So e.g. cmake .. -DCMAKE_PREFIX_PATH=<clang+llvm> -DCMAKE_C_COMPILER=gcc-12.

alexrp commented 2 days ago

For what it's worth, on my RPi5 running Debian Bookworm, gcc is 12.2.0.

saltzm commented 2 days ago

Interesting - the instructions say that only gcc >= 7.0.0 is required so I was going off of that. I'll try with an upgraded gcc and see what happens