# Crystal (compiler) for arm7?

**URL:** https://forum.crystal-lang.org/t/crystal-compiler-for-arm7/6048
**Category:** Crystal Contrib
**Created:** [October 2, 2023, 7:45am UTC](https://forum.crystal-lang.org/t/crystal-compiler-for-arm7/6048 "2023-10-02T07:45:01Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![kronn](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/kronn/32/2178_2.png) [@kronn](https://forum.crystal-lang.org/u/kronn)
#### Post date: [October 2, 2023, 7:45am UTC](https://forum.crystal-lang.org/t/crystal-compiler-for-arm7/6048/1 "2023-10-02T07:45:01Z")

</div>

Hello

I recently dusted off an older chromebook to have a smaller portable typewriter with me. It’s a Samsung Chromebook 2 (XE303C12) with has a ARMv7 Cortex-A15 architecture, which arch linux describes as arm7l and I only read as “arm7”.

Aside from handling emails, I also want to work on side-projects a little. For this, I need (well… want) to use crystal. Writing is easy as vim has been compiled to almost everything. Compiling is harder, as crystal requires crystal to compile.

I heard about cross-compilation, but have no experience in it. The most understandable approach right now would be iterative upgrading from the early crystal versions (ruby works). Both solutions leave me rahter… unsatisfied.

Would it be possible to support arm7 officially and build that centrally? Or am I missing something here?

---

<div class="post-metadata">

### Author: ![mdwagner](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/mdwagner/32/1077_2.png) [@mdwagner](https://forum.crystal-lang.org/u/mdwagner)
#### Post date: [October 2, 2023, 3:10pm UTC](https://forum.crystal-lang.org/t/crystal-compiler-for-arm7/6048/2 "2023-10-02T15:10:40Z")

</div>

I’ve cross compiled to ARMv7 successfully, it should work. Although, I think the bigger issue you might face is just that’s 32bit instead of 64bit, and I don’t think Crystal supports 32bit as much anymore.

---

<div class="post-metadata">

### Author: ![kronn](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/kronn/32/2178_2.png) [@kronn](https://forum.crystal-lang.org/u/kronn)
#### Post date: [October 2, 2023, 3:30pm UTC](https://forum.crystal-lang.org/t/crystal-compiler-for-arm7/6048/3 "2023-10-02T15:30:06Z")

</div>

Ah, I see. That’s actually a very helpful answer. So, I missed the limited 32bit-support 🙂

Maybe I will just retire the Chromebook as the battery is also not the best anymore. At least for crystal-programming, it seems not suitable. To my own surprise, while I want to keep electronic waste to a minimum, I choose crystal instead of the hardware in this case.

I will think about this a little…

---

<div class="post-metadata">

### Author: ![mdwagner](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/mdwagner/32/1077_2.png) [@mdwagner](https://forum.crystal-lang.org/u/mdwagner)
#### Post date: [October 2, 2023, 3:47pm UTC](https://forum.crystal-lang.org/t/crystal-compiler-for-arm7/6048/4 "2023-10-02T15:47:07Z")

</div>

That’s not to say it won’t work, just that you’re on your own a bit, as it falls outside common use cases. If you want to try it out and see how it goes, I’d say go for it 🙂.  
I agree on utilizing older devices when they still work ok, but at some point the hardware architecture is really the limitation, not so much of the lifespan.

---

<div class="post-metadata">

### Author: ![kronn](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/kronn/32/2178_2.png) [@kronn](https://forum.crystal-lang.org/u/kronn)
#### Post date: [October 3, 2023, 8:47am UTC](https://forum.crystal-lang.org/t/crystal-compiler-for-arm7/6048/5 "2023-10-03T08:47:58Z")

</div>

Hmm. So I took a look a the current assortment of chromebook or small laptop, saw an overwhelming and wide arrangement and did the only logical thing. I went to [Cross-compilation](https://crystal-lang.org/reference/1.9/syntax_and_semantics/cross-compilation.html), looked up my target-triplet and did the first step of cross-compilation. I was hoping that I could get a compiler for the target, but `arm7l-unknown-linux-gnueabihf` seems harder to find. Or I am clueless again. Since I set up syncthing earlier, the transfer-part seems easier that anticipated. Tonight, I might compile me some crystal (or fail at doing so). And yes, I leave this here in this much detail to help DenverCoder09 in the future.

Current steps were:

- `llvm-config --host-target` on the chromebook
- git checkout of crystal-lang/crystal and build-depencies installed
- `make crystal release=1 interpreter=1 target=arm7l-unknown-linux-gnueabihf`

---

<div class="post-metadata">

### Author: ![kronn](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/kronn/32/2178_2.png) [@kronn](https://forum.crystal-lang.org/u/kronn)
#### Post date: [October 3, 2023, 1:38pm UTC](https://forum.crystal-lang.org/t/crystal-compiler-for-arm7/6048/6 "2023-10-03T13:38:45Z")

</div>

The flag `interpreter=1` did not work for me. I will not debug this now. Without it, it produces the `.build/crystal.o` cleanly.

On the one hand, this is sad, because I wanted the REPL. On the other hand, this gives me something I can try to compile. Since that was my goal, I’ll take the win. Most packaged binaries also come without the interpreter, so I might as well grow up and compile my code.

---

<div class="post-metadata">

### Author: ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)
#### Post date: [October 4, 2023, 11:31am UTC](https://forum.crystal-lang.org/t/crystal-compiler-for-arm7/6048/7 "2023-10-04T11:31:20Z")

</div>

The interpreter is currently not supported on ARM (even on more modern versions).

> <https://github.com/crystal-lang/crystal/issues/12299>
>
> The interpreter currently doesn't build on arm. Codegen fails with the error mes…sage \`LLVM ERROR: Cannot generate unaligned atomic store\`.
> 
> Extracted from #12298

---

<div class="post-metadata">

### Author: ![kronn](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/kronn/32/2178_2.png) [@kronn](https://forum.crystal-lang.org/u/kronn)
#### Post date: [October 10, 2023, 8:09pm UTC](https://forum.crystal-lang.org/t/crystal-compiler-for-arm7/6048/8 "2023-10-10T20:09:40Z")

</div>

Not having the interpreter is secondary, but it’s good to know that this is known.

As for the actual compilation: my first try failed. I am a little occupied with work at the moment, so it will take a while for the next try, including more detailed error-messages and a little research.

For now just know: I survived the first attempt and will try again.

---

<div class="post-metadata">

### Author: ![kronn](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/kronn/32/2178_2.png) [@kronn](https://forum.crystal-lang.org/u/kronn)
#### Post date: [November 24, 2023, 7:51am UTC](https://forum.crystal-lang.org/t/crystal-compiler-for-arm7/6048/9 "2023-11-24T07:51:39Z")

</div>

For now, I will abandon this project. My goal was to have a little program that helps me focus. On a full-powered machine with modern architecture, window-managers and everything, that is helpful. On a small chromebook, whose only approximation of a GUI is fbterm and tmux, the distractions are rather minimal.

Therefore, I will not try again to cross-compile crystal for the outdated architecture. Also, after reading the docs for cross-compilation again today, I find it complete and helpful enough. Thanks for your help regarding this.
