lilith icon indicating copy to clipboard operation
lilith copied to clipboard

Does not build with current crystal

Open AlectronikForge opened this issue 4 years ago • 3 comments

Tried to build this amazing project but unfortunately just get an error when running "make toolchain/crystal/.build/crystal" and I currently lack the knowledge to fix it..

cd toolchain/crystal && make release=1 make[1]: Entering directory '/home/nix/Source/9-OS/lilith/toolchain/crystal' Using /usr/bin/llvm-config [version=10.0.1] CRYSTAL_CONFIG_LIBRARY_PATH="" CRYSTAL_CONFIG_BUILD_COMMIT="ad3fae661" ./bin/crystal build --release -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib In src/gc/boehm.cr:9:1

9 | {% if flag?(:freebsd) %} ^ Warning: expanding macro

"" There was a problem expanding macro 'macro_140249756127904'

Called macro defined in src/gc/boehm.cr:9:1

9 | {% if flag?(:freebsd) %}

Which expanded to:

1 |

2 | @[Link("gc", static: true)] Warning: specifying static linking for individual libraries is deprecated

A total of 1 warnings were found. In src/time.cr:1322:7

1322 | in(Location.local) ^ Error: expecting identifier 'end', not 'in' make[1]: *** [Makefile:133: .build/crystal] Error 1 make[1]: Leaving directory '/home/nix/Source/9-OS/lilith/toolchain/crystal' make: *** [Makefile:205: toolchain/crystal/.build/crystal] Error 2 ""

Used crystal from Arch Linux. Thanks for response!

AlectronikForge avatar Oct 27 '20 16:10 AlectronikForge

I guess the best scenario would be @ffwff merging ffwff/crystal(branch lilin) with crystal-lang/crystal (master or tag 0.35.1)

For the time being you can go to toolchain/crystal and merge "crystal-lang/crystal" onto ffwff's crystal repo yourself. (You have some merge conflicts to handle, but that can be done with common sense)

I've compiled the patched crystal compiler, but am not in the perfect condition to share this :( Wish you luck and I'll get back as soon as I have the chance.

ghost avatar Nov 24 '20 14:11 ghost

Oof never mind, the built compiler fails spectacularly...

ghost avatar Nov 25 '20 04:11 ghost

FWIW for the next person working on this, here's the patch I made by merging: https://gist.github.com/Scorbie/62597e651fbb09a6be7bcf1d614cc3d4 You can apply it by:

git clone https://github.com/crystal-lang/crystal
cd crystal
git checkout 0.35.1
wget -O - https://gist.githubusercontent.com/Scorbie/62597e651fbb09a6be7bcf1d614cc3d4/raw/f310c8cdc72673f43dc2c0407e438d0e54b7e866/lilith-crystal-0.35.1.patch | patch -p1
make

I think the patch is okay, the patched compiler builds okay, it's just that the compiler complains when I try to build the kernel. The cast thing seems to have something with src/crystal/compiler/crystal/codegen/codegen.cr that uses casts.

BUG: unhandled primitive in codegen: cast (Exception)
  from toolchain/crystal/src/compiler/crystal/codegen/primitives.cr:81:15 in 'codegen_primitive'
  from toolchain/crystal/src/compiler/crystal/codegen/call.cr:419:7 in 'codegen_call'
  from toolchain/crystal/src/compiler/crystal/codegen/call.cr:35:7 in 'visit'
  from toolchain/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:2324:7 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/call.cr:100:7 in 'prepare_call_args_non_external'
  from toolchain/crystal/src/compiler/crystal/codegen/call.cr:57:7 in 'prepare_call_args'
  from toolchain/crystal/src/compiler/crystal/codegen/call.cr:21:26 in 'visit'
  from toolchain/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:2324:7 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/call.cr:73:7 in 'prepare_call_args_non_external'
  from toolchain/crystal/src/compiler/crystal/codegen/call.cr:57:7 in 'prepare_call_args'
  from toolchain/crystal/src/compiler/crystal/codegen/call.cr:21:26 in 'visit'
  from toolchain/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:2324:7 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/fun.cr:162:11 in 'codegen_fun'
  from toolchain/crystal/src/compiler/crystal/codegen/fun.cr:51:3 in 'codegen_fun'
  from toolchain/crystal/src/compiler/crystal/codegen/fun.cr:8:54 in 'target_def_fun'
  from toolchain/crystal/src/compiler/crystal/codegen/call.cr:424:12 in 'codegen_call'
  from toolchain/crystal/src/compiler/crystal/codegen/call.cr:35:7 in 'visit'
  from toolchain/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:2324:7 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:751:9 in 'visit'
  from toolchain/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:2324:7 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/const.cr:135:13 in 'create_initialize_const_function'
  from toolchain/crystal/src/compiler/crystal/codegen/const.cr:112:56 in 'initialize_const'
  ...

Adding --debug makes it complain like

$ toolchain/crystal/bin/crystal build -Dkernel --cross-compile --target x86_64-elf --prelude ./prelude.cr --error-trace --mcmodel kernel --mno-red-zone -Ddisable_overflow --freestanding --no-finalizers   --debug src/main.cr -o build/main
Using compiled compiler at toolchain/crystal/.build/crystal
Nil assertion failed (NilAssertionError)
  from toolchain/crystal/src/nil.cr:106:5 in 'not_nil!'
  from toolchain/crystal/src/compiler/crystal/codegen/debug.cr:172:59 in 'create_debug_type'
  from toolchain/crystal/src/compiler/crystal/codegen/debug.cr:68:43 in 'get_debug_type'
  from toolchain/crystal/src/compiler/crystal/codegen/debug.cr:292:7 in 'get_debug_type'
  from toolchain/crystal/src/compiler/crystal/codegen/debug.cr:123:59 in 'create_debug_type'
  from toolchain/crystal/src/compiler/crystal/codegen/debug.cr:68:43 in 'get_debug_type'
  from toolchain/crystal/src/compiler/crystal/codegen/debug.cr:292:7 in 'get_debug_type'
  from toolchain/crystal/src/compiler/crystal/codegen/fun.cr:292:37 in 'codegen_fun_signature_non_external'
  from toolchain/crystal/src/compiler/crystal/codegen/fun.cr:231:7 in 'codegen_fun_signature'
  from toolchain/crystal/src/compiler/crystal/codegen/fun.cr:82:7 in 'codegen_fun'
  from toolchain/crystal/src/compiler/crystal/codegen/fun.cr:51:3 in 'codegen_fun'
  from toolchain/crystal/src/compiler/crystal/codegen/fun.cr:8:54 in 'target_def_fun'
  from toolchain/crystal/src/compiler/crystal/codegen/call.cr:424:12 in 'codegen_call'
  from toolchain/crystal/src/compiler/crystal/codegen/call.cr:35:7 in 'visit'
  from toolchain/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:2324:7 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/class_var.cr:135:15 in 'create_initialize_class_var_function'
  from toolchain/crystal/src/compiler/crystal/codegen/class_var.cr:87:17 in 'initialize_class_var'
  from toolchain/crystal/src/compiler/crystal/codegen/class_var.cr:82:7 in 'initialize_class_var'
  from toolchain/crystal/src/compiler/crystal/codegen/class_var.cr:75:5 in 'initialize_class_var'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:1076:11 in 'codegen_assign'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:1051:7 in 'visit'
  from toolchain/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:2324:7 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:751:9 in 'visit'
  from toolchain/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:2324:7 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:810:7 in 'visit'
  from toolchain/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from toolchain/crystal/src/compiler/crystal/syntax/ast.cr:1121:7 in 'accept_children'
  from toolchain/crystal/src/compiler/crystal/syntax/visitor.cr:28:11 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:2324:7 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:751:9 in 'visit'
  from toolchain/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:2324:7 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:810:7 in 'visit'
  from toolchain/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:2324:7 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:751:9 in 'visit'
  from toolchain/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:2324:7 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:537:9 in 'visit'
  from toolchain/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:2324:7 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:751:9 in 'visit'
  from toolchain/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:2324:7 in 'accept'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:71:7 in 'codegen'
  from toolchain/crystal/src/compiler/crystal/codegen/codegen.cr:69:5 in 'codegen:debug:single_module'
  from toolchain/crystal/src/compiler/crystal/progress_tracker.cr:22:7 in 'codegen'
  from toolchain/crystal/src/compiler/crystal/compiler.cr:184:16 in 'compile'
  from toolchain/crystal/src/compiler/crystal/command.cr:295:3 in 'compile'
  from toolchain/crystal/src/compiler/crystal/command.cr:293:5 in 'compile'
  from toolchain/crystal/src/compiler/crystal/command.cr:186:5 in 'build'
  from toolchain/crystal/src/compiler/crystal/command.cr:73:7 in 'run'
  from toolchain/crystal/src/compiler/crystal/command.cr:49:5 in 'run'
  from toolchain/crystal/src/compiler/crystal/command.cr:48:3 in 'run'
  from toolchain/crystal/src/compiler/crystal.cr:11:1 in '__crystal_main'
  from toolchain/crystal/src/crystal/main.cr:105:5 in 'main_user_code'
  from toolchain/crystal/src/crystal/main.cr:91:7 in 'main'
  from toolchain/crystal/src/crystal/main.cr:114:3 in 'main'
  from __libc_start_main
  from _start
  from ???
Error: you've found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug: https://github.com/crystal-lang/crystal/issues
# Scorbie: I decided not to bother the crystal devs with a patched version of a previous version of the compiler.

ghost avatar Nov 25 '20 13:11 ghost