Anyolite / anyolite

Embedded mruby/Ruby for Crystal
https://anyolite.github.io/anyolite
MIT License
162 stars 10 forks source link

Errors when trying to use on NixOS #25

Closed maksalees closed 1 year ago

maksalees commented 1 year ago

When I compile project I get this error:

Error target ap-crystal failed to compile:
/nix/store/r2b9k28c6aghczpqfvh71y9xavm7rr68-binutils-2.39/bin/ld: cannot find /home/user/project/lib/anyolite/src/implementations/mruby/../../../build/mruby/lib/libmruby.a: No such file or directory
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `gcc "${@}" -o /home/user/project/bin/ap-crystal  -rdynamic -L/home/user/Documents/crystal/bin/../lib/crystal /home/user/project/lib/anyolite/src/implementations/mruby/../../../build/glue/mruby/error_helper.o -DMRB_INT64 /home/user/project/lib/anyolite/src/implementations/mruby/../../../build/glue/mruby/script_helper.o -DMRB_INT64 /home/user/project/lib/anyolite/src/implementations/mruby/../../../build/glue/mruby/data_helper.o -DMRB_INT64 /home/user/project/lib/anyolite/src/implementations/mruby/../../../build/glue/mruby/return_functions.o -DMRB_INT64 /home/user/project/lib/anyolite/src/implementations/mruby/../../../build/mruby/lib/libmruby.a -DMRB_INT64 -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'` -lpcre -lm -lgc -lpthread -L/nix/store/2w32p4shrbn9bdzq9hzkk8lawl4kadx0-libevent-2.1.12/lib -levent -lrt -lpthread -ldl`

If I try to compile myself (cd lib/anyolite; rake build_shard), there will be this error:

LD    ../../build/mruby/mrbc/bin/mrbc 
/nix/store/r2b9k28c6aghczpqfvh71y9xavm7rr68-binutils-2.39/bin/ld: /home/user/project/lib/anyolite/build/mruby/mrbc/lib/libmruby_core.a(y.tab.o): undefined reference to symbol '__ctype_tolower_loc@@GLIBC_2.3'
/nix/store/r2b9k28c6aghczpqfvh71y9xavm7rr68-binutils-2.39/bin/ld: /nix/store/c35hf8g5b9vksadym9dbjrd6p2y11m8h-glibc-2.35-224/lib/libc.so.6: error adding symbols: DSO missing from command line
rake aborted!
Command failed with status (1): [ld  -o "/home/user/project/lib/anyol...]

I use mruby and glibc 2.35.

Hadeweka commented 1 year ago

It seems that gcc is used to compile the object files, but then another linker (the one at /nix/store/r2b9k28c6aghczpqfvh71y9xavm7rr68-binutils-2.39/bin/ld) is used to link them.

If this is the case, maybe a bash script like

cd lib/anyolite
unset LD
rake build_shard

could provide a quick temporary fix. The mruby package for Nix uses the same trick.

If that doesn't work, try export LD=gcc instead of unset LD.

Hadeweka commented 1 year ago

Did you happen to have any success with one of the fixes?

In that case I can incorporate the fix into the build script.

maksalees commented 1 year ago

Did you happen to have any success with one of the fixes?

In that case I can incorporate the fix into the build script.

unset LD worked

Hadeweka commented 1 year ago

Should be fixed in the latest main commit now (if there are still problems, please comment here again).