Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save MatthiasPortzel/0f90e9869f3a178002541b73fe533fbd to your computer and use it in GitHub Desktop.

Select an option

Save MatthiasPortzel/0f90e9869f3a178002541b73fe533fbd to your computer and use it in GitHub Desktop.
Using Zig as the C compiler for Ruby native extensions
podman run -it --rm docker.io/library/ruby:slim bash
apt update
apt install -y curl minisign xz-utils # needed to install Zig lol
apt install -y make # needed to install gems
mkdir /zig; cd /zig
# Random mirror from https://ziglang.org/download/community-mirrors.txt
curl -Lo zig.tar.xz https://zig.tilok.dev/zig-x86_64-linux-0.17.0-dev.1397+4331ba0fb.tar.xz
curl -Lo zig.tar.xz https://zig.tilok.dev/zig-x86_64-linux-0.17.0-dev.1397+4331ba0fb.tar.xz.minisig
minisign -Vm zig.tar.xz -P 'RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U' # Zig public key
# Verify signature
tar -xf zig.tar.xz
cd /zig/zig
printf '#!/usr/bin/env bash\n\nexec /zig/zig/zig cc "$@"' > gcc
chmod +x gcc
export PATH="$(realpath .):$PATH"
mkdir /app; cd /app
printf 'source "https://gem.coop"\n\ngem "date"' > Gemfile
bundle install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment