From 133f6b65e55c31bef5c52984aa661834460225e6 Mon Sep 17 00:00:00 2001 From: Silvia Uberti Date: Fri, 3 Feb 2023 18:02:49 +0100 Subject: [PATCH] Add template for libssl and yjit for 3.2.0 --- README.md | 3 +- build_ruby.go | 5 ++ data/Dockerfile-bionic-libssl-yjit.template | 56 +++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 data/Dockerfile-bionic-libssl-yjit.template diff --git a/README.md b/README.md index 8caf9b7..8b7373e 100644 --- a/README.md +++ b/README.md @@ -48,9 +48,10 @@ Follow the [README](https://github.com/basecamp/work#first-time-setup) in order $ bin/build_ruby -d ubuntu:18.04 -a amd64 -i "37s~bionic" -r 2.4.1 $ bin/build_ruby -d ubuntu:18.04:libssl -a amd64 -i "37s~bionic.libssl" -r 3.1.2 - + # Ruby 3.2.0 + YJIT support $ bin/build_ruby -d ubuntu:18.04:yjit -a amd64 -i "37s~bionic" -r 3.2.0 + $ bin/build_ruby -d ubuntu:18.04:libssl-yjit -a amd64 -i "37s~bionic.libssl" -r 3.2.0 ### Other options diff --git a/build_ruby.go b/build_ruby.go index 600fc5a..5eb6898 100644 --- a/build_ruby.go +++ b/build_ruby.go @@ -21,6 +21,7 @@ var ( "ubuntu:18.04": "ubuntu:18.04", "ubuntu:18.04:libssl": "ubuntu:18.04:libssl", // drop this variant once we move beyond bionic "ubuntu:18.04:yjit": "ubuntu:18.04:yjit", // used for building 3.2.0 with yjit support + "ubuntu:18.04:libssl-yjit": "ubuntu:18.04:libssl-yjit", // used for building 3.2.0 with yjit support and new libssl } docker_client *docker.Client @@ -351,6 +352,8 @@ func dockerFileFromTemplate(distro, ruby_version, arch, iteration string, patche template_location = "data/Dockerfile-bionic-libssl.template" case "ubuntu:18.04:yjit": // used for building 3.2.0 with yjit support template_location = "data/Dockerfile-bionic-yjit.template" + case "ubuntu:18.04:libssl-yjit": // used for building 3.2.0 with yjit support and new libssl + template_location = "data/Dockerfile-bionic-libssl-yjit.template" default: template_location = "data/Dockerfile.template" } @@ -386,6 +389,8 @@ func gemfilesFromDistro(distro string) (string, string) { return "data/Gemfile.bionic", "data/Gemfile.bionic.lock" case "ubuntu:18.04:yjit": // used for building 3.2.0 with yjit support return "data/Gemfile.bionic", "data/Gemfile.bionic.lock" + case "ubuntu:18.04:libssl-yjit": // used for building 3.2.0 with yjit support and new libssl + return "data/Gemfile.bionic", "data/Gemfile.bionic.lock" default: return "data/Gemfile.template", "data/Gemfile.template.lock" } diff --git a/data/Dockerfile-bionic-libssl-yjit.template b/data/Dockerfile-bionic-libssl-yjit.template new file mode 100644 index 0000000..371c035 --- /dev/null +++ b/data/Dockerfile-bionic-libssl-yjit.template @@ -0,0 +1,56 @@ +# Only produces builds for ruby >= 2.4 due to the newer openssl +# see https://3.basecamp.com/2914079/buckets/21350690/todos/4209849128 +# +# We should drop this variant when we move beyond bionic + +# Can't use {{.Distro}} since it's ubuntu:18.04:libssl +FROM ubuntu:18.04 +RUN apt-get update +RUN apt-get install -y build-essential \ + libc6-dev libffi-dev libgdbm-dev libncurses5-dev \ + libreadline-dev libssl-dev libyaml-dev zlib1g-dev rustc \ + curl ruby ruby-dev +RUN ["/usr/bin/gem", "install", "bundler", "-v", "1.17.3", "--no-rdoc", "--no-ri"] +ADD Gemfile / +ADD Gemfile.lock / +RUN ["bundle", "install"] + +RUN curl {{.DownloadUrl}}|tar oxzC /tmp +{{range .Patches}}ADD {{.}} / +{{end}} +WORKDIR /tmp/ruby-{{.RubyVersion}} +RUN for i in `/bin/ls /*.patch`; do patch -p0 < $i; done +RUN CFLAGS='-march=x86-64 -O3 -fno-fast-math -g3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -std=iso9899:1999 -fPIC' ./configure \ + --prefix=/opt/ruby{{.RubyVersion}} \ + --enable-shared \ + --disable-install-doc \ + --enable-load-relative \ + --enable-yjit +# Seems to only affect some 1.9 series Rubies, but the combined make step: +# +# RUN make -j8 install DESTDIR=/tmp/fpm +# +# that ran the make then make install, was broken. Splitting it up into +# two separate commands works fine: +RUN make -j{{.NumCPU}} +RUN make install DESTDIR=/tmp/fpm + +WORKDIR / +RUN fpm \ + -s dir \ + -t deb \ + -n ruby-{{.RubyVersion}} \ + -a {{.Arch}} \ + -v {{.RubyVersion}} \ + {{.Iteration}} + -d libc6-dev \ + -d libffi-dev \ + -d libgdbm-dev \ + -d libncurses5-dev \ + -d libreadline-dev \ + -d libssl-dev \ + -d libyaml-dev \ + -d zlib1g-dev \ + -C /tmp/fpm \ + -p /{{.FileName}} \ + opt