When running specs for Crystal >= 0.30.0 on Alpine Edge on aarch64, I got:
make spec
Using /usr/bin/llvm-config [version=8.0.1]
./bin/crystal build -D preview_overflow -D compiler_rt -o .build/all_spec spec/all_spec.cr
Using compiled compiler at `.build/crystal'
Invalid memory access (signal 11) at address 0x20
[0x40003d87f4] *CallStack::print_backtrace:Int32 +100
[0x40003c4144] __crystal_sigfault_handler +228
[0x40010d4778] sigfault_handler +40
[0x4001af72a8] __setjmp +56
[0x400296ec30] _ZN4llvm12getOpcodeDefEjjRKNS_19MachineRegisterInfoE +40
[0x400295ae98] ???
[0x400295c03c] ???
[0x400295c10c] ???
[0x400295ca00] ???
[0x40026d9c70] ???
[0x40025e0990] _ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE +368
[0x40025e0b1c] _ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE +60
[0x40025e0fdc] _ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE +516
[0x400302220c] ???
[0x400302232c] LLVMTargetMachineEmitToFile +240
[0x4000e70d64] *LLVM::TargetMachine#emit_to_file<LLVM::Module, String, LLVM::CodeGenFileType>:Bool +92
[0x4000e70da8] *LLVM::TargetMachine#emit_obj_to_file<LLVM::Module, String>:Bool +16
[0x4000fbfad4] *Crystal::Compiler::CompilationUnit#compile_to_object:(LLVM::Module | Nil) +832
[0x4000fbf5e8] *Crystal::Compiler::CompilationUnit#compile:(LLVM::Module | Nil) +52
[0x40003c0694] ~procProc(Nil) +484
[0x4000452e70] *Fiber#run:(IO::FileDescriptor | Nil) +84
[0x40003be440] ~procProc(Fiber, (IO::FileDescriptor | Nil)) +8
[0x0] ???
Invalid memory access (signal 11) at address 0x10
[0x40003d87f4] *CallStack::print_backtrace:Int32 +100
[0x40003c4144] __crystal_sigfault_handler +228
[0x40010d4778] sigfault_handler +40
[0x4001af72a8] __setjmp +56
[0x400309f690] _ZNK4llvm23AArch64RegisterBankInfo15getInstrMappingERKNS_12MachineInstrE +1740
[0x400296b0b0] _ZN4llvm13RegBankSelect11assignInstrERNS_12MachineInstrE +104
[0x400296b280] _ZN4llvm13RegBankSelect20runOnMachineFunctionERNS_15MachineFunctionE +228
[0x40026d9c70] ???
[0x40025e0990] _ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE +368
[0x40025e0b1c] _ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE +60
[0x40025e0fdc] _ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE +516
[0x400302220c] ???
[0x400302232c] LLVMTargetMachineEmitToFile +240
[0x4000e70d64] *LLVM::TargetMachine#emit_to_file<LLVM::Module, String, LLVM::CodeGenFileType>:Bool +92
[0x4000e70da8] *LLVM::TargetMachine#emit_obj_to_file<LLVM::Module, String>:Bool +16
[0x4000fbfad4] *Crystal::Compiler::CompilationUnit#compile_to_object:(LLVM::Module | Nil) +832
[0x4000fbf5e8] *Crystal::Compiler::CompilationUnit#compile:(LLVM::Module | Nil) +52
[0x40003c0694] ~procProc(Nil) +484
[0x4000452e70] *Fiber#run:(IO::FileDescriptor | Nil) +84
[0x40003be440] ~procProc(Fiber, (IO::FileDescriptor | Nil)) +8
[0x0] ???
Invalid memory access (signal 11) at address 0x20
[0x40003d87f4] *CallStack::print_backtrace:Int32 +100
[0x40003c4144] __crystal_sigfault_handler +228
[0x40010d4778] sigfault_handler +40
[0x4001af72a8] __setjmp +56
[0x400296ec30] _ZN4llvm12getOpcodeDefEjjRKNS_19MachineRegisterInfoE +40
[0x400295ae98] ???
[0x400295c03c] ???
[0x400295c10c] ???
[0x400295ca00] ???
[0x40026d9c70] ???
[0x40025e0990] _ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE +368
[0x40025e0b1c] _ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE +60
[0x40025e0fdc] _ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE +516
[0x400302220c] ???
[0x400302232c] LLVMTargetMachineEmitToFile +240
[0x4000e70d64] *LLVM::TargetMachine#emit_to_file<LLVM::Module, String, LLVM::CodeGenFileType>:Bool +92
[0x4000e70da8] *LLVM::TargetMachine#emit_obj_to_file<LLVM::Module, String>:Bool +16
[0x4000fbfad4] *Crystal::Compiler::CompilationUnit#compile_to_object:(LLVM::Module | Nil) +832
[0x4000fbf5e8] *Crystal::Compiler::CompilationUnit#compile:(LLVM::Module | Nil) +52
[0x40003c0694] ~procProc(Nil) +484
[0x4000452e70] *Fiber#run:(IO::FileDescriptor | Nil) +84
[0x40003be440] ~procProc(Fiber, (IO::FileDescriptor | Nil)) +8
[0x0] ???
Invalid memory access (signal 11) at address 0x20
[0x40003d87f4] *CallStack::print_backtrace:Int32 +100
[0x40003c4144] __crystal_sigfault_handler +228
[0x40010d4778] sigfault_handler +40
[0x4001af72a8] __setjmp +56
[0x400296ec30] _ZN4llvm12getOpcodeDefEjjRKNS_19MachineRegisterInfoE +40
[0x400295ae98] ???
[0x400295c03c] ???
[0x400295c10c] ???
[0x400295ca00] ???
[0x40026d9c70] ???
[0x40025e0990] _ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE +368
[0x40025e0b1c] _ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE +60
[0x40025e0fdc] _ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE +516
[0x400302220c] ???
[0x400302232c] LLVMTargetMachineEmitToFile +240
[0x4000e70d64] *LLVM::TargetMachine#emit_to_file<LLVM::Module, String, LLVM::CodeGenFileType>:Bool +92
[0x4000e70da8] *LLVM::TargetMachine#emit_obj_to_file<LLVM::Module, String>:Bool +16
[0x4000fbfad4] *Crystal::Compiler::CompilationUnit#compile_to_object:(LLVM::Module | Nil) +832
[0x4000fbf5e8] *Crystal::Compiler::CompilationUnit#compile:(LLVM::Module | Nil) +52
[0x40003c0694] ~procProc(Nil) +484
[0x4000452e70] *Fiber#run:(IO::FileDescriptor | Nil) +84
[0x40003be440] ~procProc(Fiber, (IO::FileDescriptor | Nil)) +8
[0x0] ???
Invalid memory access (signal 11) at address 0x10
[0x40003d87f4] *CallStack::print_backtrace:Int32 +100
[0x40003c4144] __crystal_sigfault_handler +228
[0x40010d4778] sigfault_handler +40
[0x4001af72a8] __setjmp +56
[0x400309f690] _ZNK4llvm23AArch64RegisterBankInfo15getInstrMappingERKNS_12MachineInstrE +1740
[0x400296b0b0] _ZN4llvm13RegBankSelect11assignInstrERNS_12MachineInstrE +104
[0x400296b280] _ZN4llvm13RegBankSelect20runOnMachineFunctionERNS_15MachineFunctionE +228
[0x40026d9c70] ???
[0x40025e0990] _ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE +368
[0x40025e0b1c] _ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE +60
[0x40025e0fdc] _ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE +516
[0x400302220c] ???
[0x400302232c] LLVMTargetMachineEmitToFile +240
[0x4000e70d64] *LLVM::TargetMachine#emit_to_file<LLVM::Module, String, LLVM::CodeGenFileType>:Bool +92
[0x4000e70da8] *LLVM::TargetMachine#emit_obj_to_file<LLVM::Module, String>:Bool +16
[0x4000fbfad4] *Crystal::Compiler::CompilationUnit#compile_to_object:(LLVM::Module | Nil) +832
[0x4000fbf5e8] *Crystal::Compiler::CompilationUnit#compile:(LLVM::Module | Nil) +52
[0x40003c0694] ~procProc(Nil) +484
[0x4000452e70] *Fiber#run:(IO::FileDescriptor | Nil) +84
[0x40003be440] ~procProc(Fiber, (IO::FileDescriptor | Nil)) +8
[0x0] ???
Invalid memory access (signal 11) at address 0x20
[0x40003d87f4] *CallStack::print_backtrace:Int32 +100
[0x40003c4144] __crystal_sigfault_handler +228
[0x40010d4778] sigfault_handler +40
[0x4001af72a8] __setjmp +56
[0x400296ec30] _ZN4llvm12getOpcodeDefEjjRKNS_19MachineRegisterInfoE +40
[0x400295ae98] ???
[0x400295b8bc] ???
[0x400295c104] ???
[0x400295ca00] ???
[0x40026d9c70] ???
[0x40025e0990] _ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE +368
[0x40025e0b1c] _ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE +60
[0x40025e0fdc] _ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE +516
[0x400302220c] ???
[0x400302232c] LLVMTargetMachineEmitToFile +240
[0x4000e70d64] *LLVM::TargetMachine#emit_to_file<LLVM::Module, String, LLVM::CodeGenFileType>:Bool +92
[0x4000e70da8] *LLVM::TargetMachine#emit_obj_to_file<LLVM::Module, String>:Bool +16
[0x4000fbfad4] *Crystal::Compiler::CompilationUnit#compile_to_object:(LLVM::Module | Nil) +832
[0x4000fbf5e8] *Crystal::Compiler::CompilationUnit#compile:(LLVM::Module | Nil) +52
[0x40003c0694] ~procProc(Nil) +484
[0x4000452e70] *Fiber#run:(IO::FileDescriptor | Nil) +84
[0x40003be440] ~procProc(Fiber, (IO::FileDescriptor | Nil)) +8
[0x0] ???
Invalid memory access (signal 11) at address 0x10
[0x40003d87f4] *CallStack::print_backtrace:Int32 +100
[0x40003c4144] __crystal_sigfault_handler +228
[0x40010d4778] sigfault_handler +40
[0x4001af72a8] __setjmp +56
[0x400309f690] _ZNK4llvm23AArch64RegisterBankInfo15getInstrMappingERKNS_12MachineInstrE +1740
[0x400296b0b0] _ZN4llvm13RegBankSelect11assignInstrERNS_12MachineInstrE +104
[0x400296b280] _ZN4llvm13RegBankSelect20runOnMachineFunctionERNS_15MachineFunctionE +228
[0x40026d9c70] ???
[0x40025e0990] _ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE +368
[0x40025e0b1c] _ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE +60
[0x40025e0fdc] _ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE +516
[0x400302220c] ???
[0x400302232c] LLVMTargetMachineEmitToFile +240
[0x4000e70d64] *LLVM::TargetMachine#emit_to_file<LLVM::Module, String, LLVM::CodeGenFileType>:Bool +92
[0x4000e70da8] *LLVM::TargetMachine#emit_obj_to_file<LLVM::Module, String>:Bool +16
[0x4000fbfad4] *Crystal::Compiler::CompilationUnit#compile_to_object:(LLVM::Module | Nil) +832
[0x4000fbf5e8] *Crystal::Compiler::CompilationUnit#compile:(LLVM::Module | Nil) +52
[0x40003c0694] ~procProc(Nil) +484
[0x4000452e70] *Fiber#run:(IO::FileDescriptor | Nil) +84
[0x40003be440] ~procProc(Fiber, (IO::FileDescriptor | Nil)) +8
[0x0] ???
Invalid memory access (signal 11) at address 0x10
[0x40003d87f4] *CallStack::print_backtrace:Int32 +100
[0x40003c4144] __crystal_sigfault_handler +228
[0x40010d4778] sigfault_handler +40
[0x4001af72a8] __setjmp +56
[0x400309f690] _ZNK4llvm23AArch64RegisterBankInfo15getInstrMappingERKNS_12MachineInstrE +1740
[0x400296b0b0] _ZN4llvm13RegBankSelect11assignInstrERNS_12MachineInstrE +104
[0x400296b280] _ZN4llvm13RegBankSelect20runOnMachineFunctionERNS_15MachineFunctionE +228
[0x40026d9c70] ???
[0x40025e0990] _ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE +368
[0x40025e0b1c] _ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE +60
[0x40025e0fdc] _ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE +516
[0x400302220c] ???
[0x400302232c] LLVMTargetMachineEmitToFile +240
[0x4000e70d64] *LLVM::TargetMachine#emit_to_file<LLVM::Module, String, LLVM::CodeGenFileType>:Bool +92
[0x4000e70da8] *LLVM::TargetMachine#emit_obj_to_file<LLVM::Module, String>:Bool +16
[0x4000fbfad4] *Crystal::Compiler::CompilationUnit#compile_to_object:(LLVM::Module | Nil) +832
[0x4000fbf5e8] *Crystal::Compiler::CompilationUnit#compile:(LLVM::Module | Nil) +52
[0x40003c0694] ~procProc(Nil) +484
[0x4000452e70] *Fiber#run:(IO::FileDescriptor | Nil) +84
[0x40003be440] ~procProc(Fiber, (IO::FileDescriptor | Nil)) +8
[0x0] ???
cc: error: _main.o: No such file or directory
cc: error: S-lice40U-I-nt841.o: No such file or directory
cc: error: P-ointer40U-I-nt841.o: No such file or directory
...
cc: error: Z-lib.o: No such file or directory
cc: error: L-E-B-R-eader.o: No such file or directory
Error: execution of command failed with code: 1: `cc "${@}" -o '/app/.build/all_spec' -rdynamic -lreadline -lgmp -lxml2 -lyaml -lz `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s '-lcrypto'` /app/src/llvm/ext/llvm_ext.o `/usr/bin/llvm-config --libs --system-libs --ldflags 2> /dev/null` -lstdc++ -lpcre -lm /usr/lib/libgc.a -lpthread /app/src/ext/libcrystal.a -levent -lrt -L/usr/lib -L/usr/local/lib`
make: *** [Makefile:120: .build/all_spec] Error 1
Also reported by mps on IRC/Gitter.
LLVM version: 8.0.1
According to mps, Crystal can't even be built on LLVM 5 or 6.
After testing, compiling Crystal 0.30.1 with LLVM 5 on aarch64 works.
Any idea @bcardiff ?
using --threads=1 and/or --no-debug might offer a workaround to narrow where the issue is.
the next step would be to check a llvm built with assertions in case there is some wrong usage of it.
and the next one is to, debug and get the full backtrace.
when compiling 0.30.1, be sure to use 0.29.0 and not 0.30.
I have no experience issues with llvm 8 since 0.30.1 (either debug or release w/--no-debug). I know there is debug information issues that affect release builds. But all this is on mac so far.
The CI currently use llvm-4 for linux.
By adding --no-debug --threads=1, I finally got:
Invalid memory access (signal 11) at address 0x10
[0x40003d87f4] *CallStack::print_backtrace:Int32 +100
[0x40003c4144] __crystal_sigfault_handler +228
[0x40010d4778] sigfault_handler +40
[0x4001af72a8] __setjmp +56
[0x400309f690] _ZNK4llvm23AArch64RegisterBankInfo15getInstrMappingERKNS_12MachineInstrE +1740
[0x400296b0b0] _ZN4llvm13RegBankSelect11assignInstrERNS_12MachineInstrE +104
[0x400296b280] _ZN4llvm13RegBankSelect20runOnMachineFunctionERNS_15MachineFunctionE +228
[0x40026d9c70] ???
[0x40025e0990] _ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE +368
[0x40025e0b1c] _ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE +60
[0x40025e0fdc] _ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE +516
[0x400302220c] ???
[0x400302232c] LLVMTargetMachineEmitToFile +240
[0x4000e70d64] *LLVM::TargetMachine#emit_to_file<LLVM::Module, String, LLVM::CodeGenFileType>:Bool +92
[0x4000e70da8] *LLVM::TargetMachine#emit_obj_to_file<LLVM::Module, String>:Bool +16
[0x4000fbfad4] *Crystal::Compiler::CompilationUnit#compile_to_object:(LLVM::Module | Nil) +832
[0x4000fbf5e8] *Crystal::Compiler::CompilationUnit#compile:(LLVM::Module | Nil) +52
[0x4000e6c4c4] *Crystal::Compiler#codegen_many_units<Crystal::Program, Array(Crystal::Compiler::CompilationUnit), String>:Array(String) +364
[0x4000e6b72c] *Crystal::Compiler#codegen<Crystal::Program, Array(Crystal::Compiler::CompilationUnit), String, String>:Tuple(Array(Crystal::Compiler::CompilationUnit), Array(String)) +600
[0x4000e6ac00] *Crystal::Compiler#codegen<Crystal::Program, Crystal::ASTNode+, Array(Crystal::Compiler::Source), String>:(Tuple(Array(Crystal::Compiler::CompilationUnit), Array(String)) | Nil) +1224
[0x4000e6d3ec] *Crystal::Compiler#compile<Array(Crystal::Compiler::Source), String>:Crystal::Compiler::Result +164
[0x4001010760] *Crystal::Command::CompilerConfig#compile<String>:Crystal::Compiler::Result +64
[0x4001010704] *Crystal::Command::CompilerConfig#compile:Crystal::Compiler::Result +36
[0x4001001270] *Crystal::Command#build:Crystal::Compiler::Result +184
[0x4001000834] *Crystal::Command#run:(Bool | Crystal::Compiler::Result | Nil) +316
[0x4001000610] *Crystal::Command::run<Array(String)>:(Bool | Crystal::Compiler::Result | Nil) +24
[0x40010005d4] *Crystal::Command::run:(Bool | Crystal::Compiler::Result | Nil) +28
[0x40003a6ac0] __crystal_main +5552
[0x4000cc5938] *Crystal::main_user_code<Int32, Pointer(Pointer(UInt8))>:Nil +12
[0x4000cc588c] *Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32 +40
[0x40003addf8] main +8
[0x4001acc6d8] ???
@j8r Can you try using an LLVM compiled with assertions turned on? Or are you using one with that on? I'm almost sure that error will turn into an LLVM assertion and we'll be able to figure out the cause.
Ok, I will try @asterite . It will take forever to compile on QEMU, we have to be patient :skull:
After several days compiling, I got a LLVM8 with assertions enabled.
make clean
make 'FLAGS=--no-debug --threads=1'
Using /usr/bin/llvm-config [version=8.0.1]
++ -c -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc -I/usr/lib/llvm8/include -std=c++1y -fno-exceptions -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
cc -fPIC -c -o src/ext/sigfault.o src/ext/sigfault.c
ar -rcs src/ext/libcrystal.a src/ext/sigfault.o
CRYSTAL_CONFIG_PATH="/app/src" CRYSTAL_CONFIG_LIBRARY_PATH="" CRYSTAL_CONFIG_BUILD_COMMIT="5e6a1b672" ./bin/crystal build --no-debug --threads=1 -D preview_overflow -D compiler_rt -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib
./bin/crystal build --no-debug '--threads=1' -D preview_overflow -D compiler_rt -o .build/all_spec spec/all_spec.cr
Using compiled compiler at `.build/crystal'
Assertion failed: Index + getMRI()->getType(Res).getSizeInBits() <= getMRI()->getType(Src).getSizeInBits() && "extracting off end of register" (/aports/main/llvm8/src/llvm-8.0.1.src/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp: buildExtract: 413)
Aborted (core dumped)
I don't know if LLVM was compiled correctly at then end.
Looks vaguely similar to https://github.com/crystal-lang/crystal/pull/6373
@j8r Thanks for compiling with assertions!
The issue is the one we fixed here: https://github.com/crystal-lang/crystal/pull/8063
It's an LLVM bug I reported here: https://bugs.llvm.org/show_bug.cgi?id=42932
A master is available in workaround (well, after that PR I linked).
Are you compiling master or some other previous version? And if not, maybe we should try again and see why it's failing for you.
Another way: remove the Int128/UInt128 constants MAX and MIN and then maybe remove all code related to those types because the LLVM bug is related to that (though that means modifying the compiler).
This doesn't seem to work, after commenting all match of grep -rn 'Int128::', I got a compiler error from the Crystal::CodeGenVisitor: Bug: called 'range' for non-integer literal (Exception)
I was under the impression that LLVM 8 could be used with master, maybe I'm wrong. I remember there was also a problem with debug metadata on our side and that's why we ended up using an older version of LLVM for mac osx. Maybe @bcardiff knows more about this.
@asterite I used LLVM 8.0.1. I tried with commenting Int128 constants as you said. I think I will still need to recompile it.
It works for us, I don't know why it doesn't work for you...
@j8r Actually, I think I understand what might be going on.
With what version are you compiling the compiler? If you are using a compiler before 0.30.1 it means that it will try to generate i128 extern global constants and that will fail with LLVM 8. So to compile 0.30.1 you need a compiler >= 0.30.1. But you don't have that! So you should build with LLVM 3.9.1 or LLVM 5 if that worked for you, and only in 0.31.0 you will be able to compile with LLVM 8.
I believe in CI we are still using LLVM 3.9.1 for the current 0.30.1 release and we'll just upgrade the LLVM version in the next release.
On linux we use llvm-4 from alpine
I will compile Crystal master with Crystal 0.29.0 (LLVM5), to build Crystal master with itself. After that, building the spec.
Everything will be done with LLVM8.0.1 (assertions enabled)
What I've done:
Assertion failed: Index + getMRI()->getType(Res).getSizeInBits() <= getMRI()->getType(Src).getSizeInBits() && "extracting off end of register" (/aports/main/llvm8/src/llvm-8.0.1.src/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp: buildExtract: 413)
Aborted (core dumped)
Update note: the issue is still present on 0.31.0.
@asterite and @bcardiff , I have setup a CI for Alpine aarch64 and amd64. (here are the jobs).
A cron will check every hour if there are new commits, and will run the CI.
Curious side note: The compiler crashes with invalid memory access, but why does it still call cc?
/cc MR for building with LLVM 8 on arch: https://gitlab.alpinelinux.org/alpine/aports/merge_requests/508
@straight-shoota the compiler uses fork to implement --threads. That these forks succeed is never checked. Just that they exit in some way.
The bug is still present, the aarch64 support of Crystal on Alpine will be therefore dropped in order to remove all LLVM5 dependencies from Alpine packages: https://gitlab.alpinelinux.org/alpine/aports/issues/11017.
This means we won't be able to easily distribute statically-linked binaries on Raspberry PIs anymore :worried:
Tried to recompile with the https://github.com/alpinelinux/aports/commit/4c68eb496f2a7016bf7ac8ee3b226fa72831fa73 fix (package llvm8-8.0.1-r30 - same errors as before.
In the Alpine issue, there is talk to drop support for aarch64 if this can't be solved.
@jirutka suggests to ask to @ysbaddaden, who might have an idea on this tough issue?
I have tried build crystal 0.32 and 0.33 with llvm8 and llvm10 on aarch64. Problem is still there.
This is the result with crystal 0.33.0 and llvm10 with assertions enabled:
make: crystal: No such file or directory
ESC[33mUsing /usr/lib/llvm10/bin/llvm-config [version=10.0.0]ESC[0m
./bin/crystal build --verbose --target aarch64-alpine-linux-musl --progress --threads 1 --link-flags="-Wl,--as-needed" --exclude-warnings spec/std --exclude-warnings spec/compiler -o .build/all_spec spec/all_spec.cr
Using compiled compiler at .build/crystal
Assertion failed: (Ty->isVoidTy() == (Regs.empty() || Regs[0] == 0)) && "only void types should have no register" (/home/ncopa/aports/main/llvm10/src/llvm-10.0.0.src/include/llvm/CodeGen/GlobalISel/CallLowering.h: ArgInfo: 64)
make: *** [Makefile:106: .build/all_spec] Aborted
Definitely seems like an LLVM bug. Or if we are generating invalid IR, they're not validating it correctly.
Does crystal work with llvm[8-10] on aarch64 with other distros?
Any suggestions how to report this upstream, or how to create a testcase for llvm?
I have the same issue on an Arch based aarch64 distro, so it doesn't seem to be specific to alpine.
Just to document it here: The issue seem to be that we generate a value of a zero sized type and that LLVM's "new" Global ISel pass doesn't like that at all. That pass is not enabled by default on x86 but I guess got recently enabled by default on AArch64.
So the proper fix is probably to stop generating those values of a zero sized type, but until then #9401 works around this by just disabling Global ISel for all targets.
Most helpful comment
@asterite and @bcardiff , I have setup a CI for Alpine aarch64 and amd64. (here are the jobs).
A cron will check every hour if there are new commits, and will run the CI.