Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile failed on local linux laptop (arch linux) #3

Closed
zw963 opened this issue Jun 12, 2022 · 7 comments
Closed

compile failed on local linux laptop (arch linux) #3

zw963 opened this issue Jun 12, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@zw963
Copy link

zw963 commented Jun 12, 2022

When build with release, it failed.

 ╰─ $ make release
g++ -c  -o /home/zw963/Crystal/git/ic/share/crystal-ic/src/llvm/ext/llvm_ext.o /home/zw963/Crystal/git/ic/share/crystal-ic/src/llvm/ext/llvm_ext.cc -I/usr/include -std=c++14   -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
mkdir -p bin
CRYSTAL_CONFIG_PATH='$ORIGIN/../share/crystal-ic/src' CRYSTAL_PATH=/home/zw963/Crystal/git/ic/share/crystal-ic/src crystal build --progress --static src/main.cr -o bin/ic
Error: file 'src/main.cr' does not exist
make: *** [Makefile:32: release] Error 1

make without release work, but failed when try to run ./bin/ic

 ╰─ $ make
g++ -c  -o /home/zw963/Crystal/git/ic/share/crystal-ic/src/llvm/ext/llvm_ext.o /home/zw963/Crystal/git/ic/share/crystal-ic/src/llvm/ext/llvm_ext.cc -I/usr/include -std=c++14   -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
mkdir -p bin
CRYSTAL_CONFIG_PATH='$ORIGIN/../share/crystal-ic/src' CRYSTAL_PATH=/home/zw963/Crystal/git/ic/share/crystal-ic/src crystal build --progress src/ic.cr -o bin/ic
                                                      
 ╭─ 21:05  zw963 ⮀ ~/Crystal/git/ic ⮀ ⭠ (88e700b) master u=  ➦ ruby-3.1.0 
 ╰─ $ bin/ic
cannot find -lrt (/usr/lib/librt.so: cannot open shared object file: No such file or directory)
Linker arguments: -levent -lrt -ldl
Search path: /usr/lib/perf:/usr/lib/openmpi:/usr/lib32:/usr/lib/mysqlrouter:/usr/lib/libfakeroot:/lib64:/usr/lib64:/lib:/usr/lib (Crystal::Loader::LoadError)
  from share/crystal-ic/src/compiler/crystal/loader/unix.cr:86:31 in 'load_library'
  from share/crystal-ic/src/compiler/crystal/loader.cr:42:7 in 'new'
  from share/crystal-ic/src/compiler/crystal/loader/unix.cr:66:7 in 'parse'
  from share/crystal-ic/src/compiler/crystal/interpreter/context.cr:365:1 in 'loader'
  from share/crystal-ic/src/compiler/crystal/interpreter/context.cr:378:5 in 'c_function'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:1883:17 in 'compile_lib_call'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:1764:7 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:3000:5 in 'accept_with_wants_value'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:2990:5 in 'request_value'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:578:7 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:3000:5 in 'accept_with_wants_value'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:2990:5 in 'request_value'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:1219:5 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:566:7 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:234:5 in 'compile_def'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:1979:7 in 'create_compiled_def'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:1777:22 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:234:5 in 'compile_def'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:1979:7 in 'create_compiled_def'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:1777:22 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:447:7 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:234:5 in 'compile_def'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:1399:5 in 'get_const_index_and_compiled_def'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:2486:27 in 'initialize_const_if_needed'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:1371:9 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:3000:5 in 'accept_with_wants_value'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:2990:5 in 'request_value'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:2144:9 in 'compile_call_args'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:1773:5 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:234:5 in 'compile_def'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:1399:5 in 'get_const_index_and_compiled_def'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:680:31 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:2904:5 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:566:7 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:3000:5 in 'accept_with_wants_value'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:2994:5 in 'discard_value'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:2852:7 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:566:7 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:234:5 in 'compile_def:closure_owner'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:2952:5 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:566:7 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:234:5 in 'compile_def:closure_owner'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:2952:5 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:566:7 in 'visit'
  from share/crystal-ic/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from share/crystal-ic/src/compiler/crystal/interpreter/compiler.cr:165:5 in 'compile'
  from share/crystal-ic/src/compiler/crystal/interpreter/interpreter.cr:207:5 in 'interpret'
  from share/crystal-ic/src/compiler/crystal/interpreter/repl.cr:146:5 in 'interpret'
  from share/crystal-ic/src/compiler/crystal/interpreter/repl.cr:150:5 in 'interpret_and_exit_on_error'
  from share/crystal-ic/src/compiler/crystal/interpreter/repl.cr:140:5 in 'load_prelude'
  from src/repl.cr:10:5 in 'run'
  from src/ic.cr:59:3 in '__crystal_main'
  from share/crystal-ic/src/crystal/main.cr:115:5 in 'main_user_code'
  from share/crystal-ic/src/crystal/main.cr:101:7 in 'main'
  from share/crystal-ic/src/crystal/main.cr:127:3 in 'main'
  from /usr/lib/libc.so.6 in '??'
  from /usr/lib/libc.so.6 in '__libc_start_main'
  from ../sysdeps/x86_64/start.S:117 in '_start'
  from ???
@I3oris
Copy link
Owner

I3oris commented Jun 12, 2022

Hello, thanks for reporting the issue!, I push the fix for make release.

It seems to be crystal-lang/crystal#12036.
For stability, I use last release of crystal (1.4.1) to get the interpreter, but here the issue was merged after 1.4.1.

@I3oris I3oris closed this as completed in e273413 Jun 12, 2022
@I3oris I3oris reopened this Jun 12, 2022
@I3oris
Copy link
Owner

I3oris commented Jun 12, 2022

I push the same fix that crystal-lang/crystal#12036.
The binary should not be linked against librt anymore.

ldd bin/ic | grep rt

=> nothing

@I3oris I3oris added the bug Something isn't working label Jun 12, 2022
@I3oris I3oris closed this as completed in 0e1c3e9 Jun 12, 2022
@I3oris I3oris reopened this Jun 12, 2022
@I3oris
Copy link
Owner

I3oris commented Jun 12, 2022

Sorry, the issue close automatically since I written Fix #3 in the commit. I will close when it's sure it works well on your side :)

@zw963
Copy link
Author

zw963 commented Jun 12, 2022

It spent almost 40 minutes, so long, i even can compile my firefox from scratch. 😄

but still failed.

 ╰─ $ make release
g++ -c  -o /home/zw963/Crystal/git/ic/share/crystal-ic/src/llvm/ext/llvm_ext.o /home/zw963/Crystal/git/ic/share/crystal-ic/src/llvm/ext/llvm_ext.cc -I/usr/include -std=c++14   -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
mkdir -p bin
CRYSTAL_CONFIG_PATH='$ORIGIN/../share/crystal-ic/src' CRYSTAL_PATH=/home/zw963/Crystal/git/ic/share/crystal-ic/src crystal build --progress --static --release src/ic.cr -o bin/ic
[12/13] [0/1] Codegen (bc+obj)                  



/usr/sbin/ld: cannot find -lssl (this usually means you need to install the development package for libssl): No such file or directory
/usr/sbin/ld: cannot find -lcrypto (this usually means you need to install the development package for libcrypto): No such file or directory
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc "${@}" -o /home/zw963/Crystal/git/ic/bin/ic  -rdynamic -static -L/home/zw963/Crystal/bin/../lib/crystal -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'` /home/zw963/Crystal/git/ic/share/crystal-ic/src/llvm/ext/llvm_ext.o `"/usr/sbin/llvm-config" --libs --system-libs --ldflags --link-static 2> /dev/null` -lstdc++ -lpcre -lm -lgc -lpthread -levent  -lpthread -ldl -lffi`
make: *** [Makefile:34: release] Error 1

But, sure my laptop (arch linux) should install openssl (with dev files, arch no dev package individually)

 ╰─ $ pacman -Q |grep 'openssl '
lib32-openssl 1:1.1.1.n-1
openssl 1.1.1.o-1
 ╰─ $ pacman -Ql openssl |egrep 'libcrypto|libssl'
openssl /usr/lib/libcrypto.so
openssl /usr/lib/libcrypto.so.1.1
openssl /usr/lib/libssl.so
openssl /usr/lib/libssl.so.1.1
openssl /usr/lib/pkgconfig/libcrypto.pc
openssl /usr/lib/pkgconfig/libssl.pc

I guess it may caused my compile toolchain version is too new.

@I3oris
Copy link
Owner

I3oris commented Jun 12, 2022

The problem is the --static. Remove it from the makefile should be better. (or make release RELEASE_FLAGS="--progress --release"
It's such a shame of me to provide a soo broken makefile, my bad..

The cause is I was trying to release a static build of IC on an other repos, and add make install, but I merged the makefile any old how.

@zw963
Copy link
Author

zw963 commented Jun 12, 2022

The problem is the --static. Remove it from the makefile should be better. (or make release RELEASE_FLAGS="--progress --release"

It works after remove --static build argument, i should figure it out, sorry.

so, it was possible to build a static version ic, right? if that true, maybe you can use this git action to make all release automatically.

@I3oris
Copy link
Owner

I3oris commented Jun 12, 2022

Don't sorry, You actually help a lot IC. The fault is mine to not figure it out before push the makefile 😆

so, it was possible to build a static version ic

In fact, I realized it's not possible for now, (problem revealed by straight-shoota here).

I actually get inspired by your action for my try! I managed to build a static binary of IC on an alpine-container, but then the problem is that it should interpret code. And at that time it need to dynamically load libs with dlopen. And this later doesn't work when the binary is static. Though I'm not sure to understand the deep reason of this. 🤷

@I3oris I3oris closed this as completed Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants