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

Static build works but dynamic build doesn't #78

Open
astrolemonade opened this issue Oct 10, 2023 · 5 comments
Open

Static build works but dynamic build doesn't #78

astrolemonade opened this issue Oct 10, 2023 · 5 comments

Comments

@astrolemonade
Copy link

astrolemonade commented Oct 10, 2023

Hey! I have both crystal and shards installed in /usr/bin. I compiled them from source.

[/tmp/cr] $ crystal -v
Crystal 1.10.0 [9c011d77d] (2023-10-09)

LLVM: 15.0.7
Default target: x86_64-unknown-linux-gnu

[/tmp/cr] $ shards --version
Shards 0.17.3 [4bf845f] (2023-07-23)

I tried to compile crystalline from source to, commit e1dd820.
I managed to build it by using the following instructions:

git clone https://github.com/elbywan/crystalline
cd crystalline
shards install
mkdir bin
CRYSTAL_PATH=/usr/lib/crystal/src:lib shards build crystalline \
      --no-debug --progress --stats --production --release \
      -Dpreview_mt --ignore-crystal-version

I set the absolute path in the VS Code extension v0.8.4: /home/user/Clones/crystalline/bin/crystalline

image

I receive the following in the PROBLEMS tab and no LSP feature works.
I am using Linux:

[/tmp/cr] $ uname -a
Linux catalin 6.5.5-258.current #1 SMP PREEMPT_DYNAMIC 0 x86_64 GNU/Linux

[/tmp/cr] $ gcc --version
gcc (Solus) 12.3.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[22:32:28]
[/tmp/cr] $ clang --version
clang version 15.0.7
Target: x86_64-solus-linux
Thread model: posix
InstalledDir: /usr/bin

If you have any ideas on how to make it work let me know.

Edit 1: I used the barebones crystal executable project for testing.
I never got the dynamic build to ever run on my machine.

Edit 2: I can run the code without problems.

[/tmp/cr] $ shards run
Dependencies are satisfied
Building: cr
Executing: cr 

Edit 3: the executable from GitHub releases is statically built and it's built against musl. I am using libc.

@elbywan
Copy link
Owner

elbywan commented Oct 11, 2023

Hey @astrolemonade,

From a quick glance it looks similar to the following issue: 🤔
crystal-lang/crystal#12593

I do not think that it is related to static / dynamic compilation at all, more like that the target(x86_64-solus-linux) causes the problem.

@astrolemonade
Copy link
Author

astrolemonade commented Oct 12, 2023

I build crystal with the CRYSTAL_CONFIG_TARGET=x86_64-linux-gnu 🤔 should have been enough. I will make a custom symbolic link to the lib_c from https://github.com/crystal-lang/crystal/tree/1d0a7ab02320349ea9db5a178c45c9fdacf742a6/src/lib_c/x86_64-linux-gnu and come back with the results.
If that works I will open a PR.
I wonder if crystal uses the source code of crystal when building and if I can hijack it to use my custom one.

@astrolemonade
Copy link
Author

Even after adding that directory it still doesn't build successfully.

@elbywan
Copy link
Owner

elbywan commented Oct 13, 2023

Was your vscode instance opened with a shell that has the CRYSTAL_CONFIG_TARGET=x86_64-linux-gnu environment variable set? (and the crystal path one)

Crystalline is spawned as a sub process of a vscode helper, and the error you posted comes from crystalline trying to compile from within the editor.

@astrolemonade
Copy link
Author

astrolemonade commented Oct 13, 2023

I did as you said! I wrapped the crystalline binary in a bash script that sets those variables and set it in VS code crystalline binary path. This is what I am executing instead of crystalline.

#! /usr/bin/env bash
export CRYSTAL_CONFIG_TARGET="x86_64-linux-gnu"
export CRYSTAL_PATH="lib:/usr/lib64/crystal/src/src"
# I tried with export CRYSTAL_PATH="lib:/usr/lib64/crystal/src" also and it didn't fixed the issue
/home/user/Clones/crystalline/bin/crystalline "$@"
[/tmp/haha] $ crystal env CRYSTAL_PATH
lib:/usr/lib64/crystal/src/src
[23:47:58]
[/tmp/haha] $ shards run
Dependencies are satisfied
Building: haha
Executing: haha 

It didn't help, unfortunately.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants