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

[Feature Request] Any chance for pre-built binaries for raspberry pi or arm? #25

Closed
g0kuz opened this issue Apr 4, 2020 · 11 comments
Closed
Labels
enhancement New feature or request

Comments

@g0kuz
Copy link

g0kuz commented Apr 4, 2020

Arm doesn't support crystal without jumping through hoops. Any chance you could create a binary for arm?

@g0kuz g0kuz added the enhancement New feature or request label Apr 4, 2020
@hkalexling
Copy link
Member

Yeah, good idea! While we are at it, I should probably set up automated builds for various platforms (including ARM Linux and macOS).

I am not familiar with raspberry pi. Are you using a 64-bit OS?

@g0kuz
Copy link
Author

g0kuz commented Apr 5, 2020

All raspberry pi uses ARMv7. Would be great if you are able to do it!!

Tested on my desktop, its everything i wanted. But having it run on my pi 24/7 is more ideal!

@hkalexling
Copy link
Member

hkalexling commented Apr 5, 2020

I looked into it, and unfortunately I cannot provide an ARM binary at this moment :(

In Crystal, in order to have a standalone binary with all libraries statically linked, the application must be compiled on Alpine. In our case, we need to compile it with an Alpine on ARM, but there's no official release for ARM systems yet.

So to have a standalone binary, we would need to cross-compile and link on an Alpine system on ARM, which is not yet possible (see crystal-lang/crystal#5467). We can also cross-compile and link on other GNU-based Linux systems, but then the Mango binary would be dynamically linked and might not be portable.

What I can do is create a special Dockerfile for ARM, and you can then follow the installation guide to install Mango with Docker. What do you think?

@g0kuz
Copy link
Author

g0kuz commented Apr 5, 2020

create a special Dockerfile for ARM

Wow this will be great! I'm happy to test it for you

@hkalexling
Copy link
Member

Could you try and see if the following Dockerfile works?

FROM arm32v7/ubuntu:18.04

RUN apt-get update && apt-get install -y wget git make llvm-3.9 g++ libsqlite3-dev libyaml-dev libgc-dev libssl-dev libcrypto++-dev libevent-dev libgmp-dev zlib1g-dev libpcre++-dev

RUN git clone https://github.com/crystal-lang/crystal
RUN cd crystal && git checkout 0.32.1 && make deps && cd ..

RUN wget https://drive.hkalexling.com/mango.o
RUN cc 'mango.o' -o 'mango'  -rdynamic -static  -lsqlite3 -lm -ldl -lz -lpthread -lgmp -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'` -lpcre -lm /usr/lib/arm-linux-gnueabihf/libgc.a -lpthread ./crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/bin/../lib/crystal/lib -L/usr/lib -L/usr/local/lib

CMD ["./mango"]

The Dockerfile downloads the object file mango.o I cross-compiled for arm32v7, links it against all the required libraries and generates the binary mango. To use it, please clone this repository, replace the default Dockerfile with the one above, and follow the instructions here.

PS: The Docker image takes quite a while to build, so please be patient :P If it works I will further optimize it to improve the build time.

@g0kuz
Copy link
Author

g0kuz commented Apr 5, 2020

Note: checking out '0.32.1'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 41bd18fbe... Release 0.32.1 (#8590)
make: crystal: Command not found
Using /usr/bin/llvm-config-3.9 [version=3.9.1]
g++ -c  -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc -I/usr/lib/llvm-3.9/include -std=c++0x -gsplit-dwarf -Wl,-fuse-ld=gold -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -std=c++11 -ffunction-sections -fdata-sections -O2 -g -DNDEBUG  -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
src/llvm/ext/llvm_ext.cc:1:31: fatal error: llvm/IR/DIBuilder.h: No such file or directory
 #include "llvm/IR/DIBuilder.h"
                               ^
compilation terminated.
Makefile:136: recipe for target 'src/llvm/ext/llvm_ext.o' failed
make: *** [src/llvm/ext/llvm_ext.o] Error 1

This is after running cd crystal && git checkout 0.32.1 && make deps && cd ..

@hkalexling
Copy link
Member

Thanks! Please try the following (with updated llvm)

FROM arm32v7/ubuntu:18.04

RUN apt-get update && apt-get install -y wget git make llvm-8 llvm-8-dev g++ libsqlite3-dev libyaml-dev libgc-dev libssl-dev libcrypto++-dev libevent-dev libgmp-dev zlib1g-dev libpcre++-dev

RUN git clone https://github.com/crystal-lang/crystal
RUN cd crystal && git checkout 0.32.1 && make deps && cd ..

RUN wget https://drive.hkalexling.com/mango.o
RUN cc 'mango.o' -o 'mango'  -rdynamic -static  -lsqlite3 -lm -ldl -lz -lpthread -lgmp -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'` -lpcre -lm /usr/lib/arm-linux-gnueabihf/libgc.a -lpthread ./crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/bin/../lib/crystal/lib -L/usr/lib -L/usr/local/lib

CMD ["./mango"]

@hkalexling
Copy link
Member

Hi,

I got my hands on a raspberry pi 3 and tried the Dockerfile above. The docker image builds successfully, but Mango would crash whenever it queries the SQLite database. It works fine on amd64, so I guess it's caused by a bug in crystal-sqlite3 on ARM.

I will try to submit an issue there, but I found another ARM related bug report from 2017 that's still open, so I am not sure if they will fix it.

Unfortunately, there's nothing else I can do to help :( I will edit the README file to make it clear that ARM is not yet supported.

@g0kuz
Copy link
Author

g0kuz commented Apr 6, 2020

Hi,

I got my hands on a raspberry pi 3 and tried the Dockerfile above. The docker image builds successfully, but Mango would crash whenever it queries the SQLite database. It works fine on amd64, so I guess it's caused by a bug in crystal-sqlite3 on ARM.

I will try to submit an issue there, but I found another ARM related bug report from 2017 that's still open, so I am not sure if they will fix it.

Unfortunately, there's nothing else I can do to help :( I will edit the README file to make it clear that ARM is not yet supported.

That's a shame!! For the time being I'm using komga on my raspberry pi. Sadly, it doesn't have continuous scrolling unlike yours. =/

@hkalexling
Copy link
Member

I guess that's the price I have to pay for using a "cool language" :P

Anyway, I have submitted an issue there and will let you know if it's fixed or if they suggest any workaround. Closing this for now.

@hkalexling
Copy link
Member

ARM support has been added in v0.11.0. There's no pre-built binary yet, and you will have to run it in a Docker container. Please see the wiki page for more details.

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

No branches or pull requests

2 participants