Bootstrapping compiler for FreeBSD package

@dch here from FreeBSD thanks for the work over last few years on finding solutions for build issues, SSL compat. It’s a breeze now to port new crystal apps to FreeBSD (let me know of any interesting candidates).

We’re looking at deprecating LLVM14 in our ports tree in the next 6 months, so I need to find a way to bootstrap Crystal builds starting from a more modern C compiler. In theory I could just stash a 12.1 build and use that in future, but that means I have no way to bring up a new architecture for Crystal when it’s available, like arm64 or RISC-V in the past.

Any suggestions?

@straight-shoota any suggestions on handling this?

Yeah, bootstrapping is a common issue for packages.
I don’t think there are many options besides pulling in a stage-0 compiler from somewhere (i.e. outside the package tree). For a new architecture that would require cross-compiling from an existing one.

It’s technically possible to reiterate the bootstrap journey from the latest compiler written in Ruby, but that’s a tedious process with many intermediate steps and moving dependencies (see GitHub - crystal-lang/bootstrap-script: Automated script to bootstrap the crystal compiler from source · GitHub). People have tried, but I’m not aware anyone has completed integrating that bootstrap process into any package system.

An alternative route could be web assembly: With recent advancements in the standard, we’re currently upstreaming changes for the Crystal compiler to run entirely in a WASI runtime. Not sure if that brings many benefits for bootstrapping because the wasm program is still a binary blob you need to get from somewhere. But at least it should simplify building a compiler on a new architecture.

Note: I’m going to extract this into a new topic to keep the discussion focussed. You might want to repeat your first comment in the original topic.

OK, in that case I used current crystal to build a minimal bootstrap that I can use going forwards. ⚙ D61263 lang/crystal: Bootstrap with LLVM 20 and pcre2 for future architectures being able to bootstrap off a generic WASM compiler would be a great idea.