Skip to content

Commit

Permalink
change -linux to -linux-gnu everywhere
Browse files Browse the repository at this point in the history
and test gems built with the `-linux-gnu` suffix on ruby 3.1 and
later, which are the ones that ship with rubygems 3.2.33 or later (the
version that first recognizes the `-gnu` suffix)
  • Loading branch information
flavorjones committed Jan 16, 2024
1 parent f700f7d commit 0b25bbe
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 46 deletions.
48 changes: 38 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,22 @@ jobs:
fail-fast: false
matrix:
include:
- platform: aarch64-linux
- platform: arm-linux
- platform: aarch64-linux-gnu
alias: aarch64-linux
- platform: arm-linux-gnu
alias: arm-linux
- platform: arm64-darwin
- platform: jruby
- platform: x64-mingw-ucrt
static: true
- platform: x64-mingw32
static: true
- platform: x86-linux
- platform: x86-linux-gnu
alias: x86-linux
- platform: x86-mingw32
- platform: x86_64-darwin
- platform: x86_64-linux
- platform: x86_64-linux-gnu
alias: x86_64-linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -114,6 +118,21 @@ jobs:
name: gem-${{ matrix.platform }}-static
path: test/rcd_test/pkg/*-*-*.gem

- if: matrix.alias
name: Build native gem ${{ matrix.alias }}
run: |
cd test/rcd_test/
bundle install
bundle exec rake clean clobber
bundle exec rake gem:${{ matrix.alias }}
- if: matrix.alias
name: Upload native gem ${{ matrix.alias }}
uses: actions/upload-artifact@v3
with:
name: gem-${{ matrix.alias }}
path: test/rcd_test/pkg/*-*-*.gem

test_source_gem:
name: test source
needs: build_source_gem
Expand Down Expand Up @@ -172,6 +191,15 @@ jobs:
platform: x86_64-darwin
- os: ubuntu
platform: x86_64-linux
- os: ubuntu # ruby 3.0 and earlier ship rubygems < 3.2.33, so can't recognize the -gnu suffix
ruby: "3.1"
platform: x86_64-linux-gnu
- os: ubuntu
ruby: "3.2"
platform: x86_64-linux-gnu
- os: ubuntu
ruby: "3.3"
platform: x86_64-linux-gnu
- os: ubuntu
ruby: jruby
platform: jruby
Expand Down Expand Up @@ -282,22 +310,22 @@ jobs:
matrix:
include:
- from_image: amd64/centos
platform: x86_64-linux
platform: x86_64-linux-gnu
dockerfile: centos
- from_image: navikey/raspbian-bullseye
platform: arm-linux
platform: arm-linux-gnu
dockerfile: debian
- from_image: arm64v8/ubuntu
platform: aarch64-linux
platform: aarch64-linux-gnu
dockerfile: debian
- from_image: i386/alpine
platform: x86-linux
platform: x86-linux-gnu
dockerfile: alpine
- from_image: arm32v6/alpine
platform: arm-linux
platform: arm-linux-gnu
dockerfile: alpine
- from_image: alpine
platform: x86_64-linux
platform: x86_64-linux-gnu
dockerfile: alpine
runs-on: ubuntu-latest
steps:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/publish-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ jobs:
fail-fast: false
matrix:
platform:
- x86-mingw32
- aarch64-linux-gnu
- arm-linux-gnu
- arm64-darwin
- x64-mingw-ucrt
- x64-mingw32
- x86-linux
- x86_64-linux
- x86-linux-gnu
- x86-mingw32
- x86_64-darwin
- arm64-darwin
- arm-linux
- aarch64-linux
- x86_64-linux-gnu
- jruby
runs-on: ubuntu-latest
steps:
Expand Down
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/.bundle/
/.yardoc
/Dockerfile.mri.aarch64-linux
/Dockerfile.mri.arm-linux
/Dockerfile.mri.aarch64-linux-gnu
/Dockerfile.mri.arm-linux-gnu
/Dockerfile.mri.arm64-darwin
/Dockerfile.mri.arm64-linux
/Dockerfile.mri.x64-mingw-ucrt
/Dockerfile.mri.x64-mingw32
/Dockerfile.mri.x86-linux
/Dockerfile.mri.x86-linux-gnu
/Dockerfile.mri.x86-mingw32
/Dockerfile.mri.x86_64-darwin
/Dockerfile.mri.x86_64-linux
/Dockerfile.mri.x86_64-linux-gnu
/Gemfile.lock
/_yardoc/
/cache/
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile.mri.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%
image = case platform
when /x86_64-linux/ then "quay.io/pypa/manylinux2014_x86_64"
when /x86-linux/ then "quay.io/pypa/manylinux2014_i686"
when /x86_64-linux-gnu/ then "quay.io/pypa/manylinux2014_x86_64"
when /x86-linux-gnu/ then "quay.io/pypa/manylinux2014_i686"
else "ubuntu:20.04"
end
manylinux = !!(image =~ /manylinux/)
Expand Down Expand Up @@ -68,8 +68,8 @@ RUN dpkg -i /debs/*.deb
RUN apt-get -y update && \
apt-get install -y <%
if platform =~ /darwin/ %> clang python lzma-dev libxml2-dev libssl-dev libc++-10-dev <% end %><%
if platform =~ /aarch64-linux/ %> gcc-aarch64-linux-gnu g++-aarch64-linux-gnu <% end %><%
if platform =~ /arm-linux/ %> gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf <% end %><%
if platform =~ /aarch64-linux-gnu/ %> gcc-aarch64-linux-gnu g++-aarch64-linux-gnu <% end %><%
if platform =~ /arm-linux-gnu/ %> gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf <% end %><%
if platform =~ /x86-mingw32/ %> gcc-mingw-w64-i686 g++-mingw-w64-i686 <% end %><%
if platform =~ /x64-mingw32/ %> gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 <% end %> && \
rm -rf /var/lib/apt/lists/*
Expand Down
3 changes: 3 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
next / unreleased
-----------------

* Linux builds and their images are now fully qualified with the libc flavor. So, `x86_64-linux`
should now be referred to as `x86_64-linux-gnu`, and the generated files are also named with the
libc name.
* Replace `rvm` with `rbenv` and `ruby-build`
- `rvm` has been replaced by `rbenv` and `ruby-build`
- no longer applying sendfile patches to bootstrap rubies
Expand Down
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Your Rakefile should enable cross compilation like so:
```ruby
exttask = Rake::ExtensionTask.new('my_extension', my_gem_spec) do |ext|
ext.cross_compile = true
ext.cross_platform = %w[x86-mingw32 x64-mingw-ucrt x64-mingw32 x86-linux x86_64-linux x86_64-darwin arm64-darwin]
ext.cross_platform = %w[x86-mingw32 x64-mingw-ucrt x64-mingw32 x86-linux-gnu x86_64-linux-gnu x86_64-darwin arm64-darwin]
end
```

Expand All @@ -44,7 +44,7 @@ Additionally it may also be used to build ffi based binary gems like [libusb](ht
### Interactive Usage

Rake-compiler-dock offers the shell command `rake-compiler-dock` and a [ruby API](http://www.rubydoc.info/gems/rake-compiler-dock/RakeCompilerDock) for issuing commands within the docker image, described below.
There are dedicated images for `x86-mingw32`, `x64-mingw-ucrt`, `x64-mingw32`, `x86-linux`, `x86_64-linux`, `x86_64-darwin`, `arm64-darwin` and `jruby` targets.
There are dedicated images for targets: `aarch64-linux-gnu`, `arm-linux-gnu`, `arm64-darwin`, `x64-mingw-ucrt`, `x64-mingw32`, `x86-linux-gnu`, `x86-mingw32`, `x86_64-darwin`, `x86_64-linux-gnu`, and `jruby`.
The images contain all supported cross ruby versions, with the exception of `x64-mingw32`, which has versions before 3.1 only, and `x64-mingw-ucrt`, which has only ruby-3.1+.
This is to match the [changed platform of RubyInstaller-3.1](https://rubyinstaller.org/2021/12/31/rubyinstaller-3.1.0-1-released.html).

Expand All @@ -68,12 +68,12 @@ To build x86 Windows and x86_64 Linux binary gems interactively, it can be calle
user@host:$ ls pkg/*.gem
your-gem-1.0.0.gem your-gem-1.0.0-x86-mingw32.gem

user@host:$ RCD_PLATFORM=x86_64-linux rake-compiler-dock # this enters a container for amd64 Linux target
user@host:$ RCD_PLATFORM=x86_64-linux-gnu rake-compiler-dock # this enters a container for amd64 Linux target
user@adc55b2b92a9:$ bundle
user@adc55b2b92a9:$ rake cross native gem
user@adc55b2b92a9:$ exit
user@host:$ ls pkg/*.gem
your-gem-1.0.0.gem your-gem-1.0.0-x86_64-linux.gem
your-gem-1.0.0.gem your-gem-1.0.0-x86_64-linux-gnu.gem

Or non-interactive:

Expand Down Expand Up @@ -118,10 +118,21 @@ To make the build process reproducible for other parties, it is recommended to a
This can be done like this:

```ruby
PLATFORMS = %w[
aarch64-linux-gnu
arm-linux-gnu
arm64-darwin
x64-mingw-ucrt
x64-mingw32
x86-linux-gnu
x86-mingw32
x86_64-darwin
x86_64-linux-gnu
]
task 'gem:native' do
require 'rake_compiler_dock'
sh "bundle package --all" # Avoid repeated downloads of gems by using gem files from the host.
%w[ x86-mingw32 x64-mingw-ucrt x64-mingw32 x86-linux x86_64-linux arm-linux aarch64-linux x86_64-darwin arm64-darwin ].each do |plat|
PLATFORMS.each do |plat|
RakeCompilerDock.sh "bundle --local && rake native:#{plat} gem", platform: plat
end
RakeCompilerDock.sh "bundle --local && rake java gem", rubyvm: :jruby
Expand Down Expand Up @@ -187,21 +198,21 @@ jobs:
name: "native-gem"
runs-on: ubuntu-latest
container:
image: "ghcr.io/rake-compiler/rake-compiler-dock-image:1.2.2-mri-x86_64-linux"
image: "ghcr.io/rake-compiler/rake-compiler-dock-image:1.2.2-mri-x86_64-linux-gnu"
steps:
- uses: actions/checkout@v2
- run: bundle install && bundle exec rake gem:x86_64-linux:rcd
- run: bundle install && bundle exec rake gem:x86_64-linux-gnu:rcd
- uses: actions/upload-artifact@v2
with:
name: native-gem
path: gems
retention-days: 1
```
Where the referenced rake task might be defined by:
Where the referenced rake task might be defined by something like:
``` ruby
cross_platforms = ["x64-mingw32", "x86_64-linux", "x86_64-darwin", "arm64-darwin"]
cross_platforms = ["x64-mingw32", "x86_64-linux-gnu", "x86_64-darwin", "arm64-darwin"]

namespace "gem" do
cross_platforms.each do |platform|
Expand All @@ -223,7 +234,7 @@ For an example of rake tasks that support this style of invocation, visit https:

OCI images snapshotted from `main` are published weekly to Github Container Registry with the string "snapshot" in place of the version number in the tag name, e.g.:

- `ghcr.io/rake-compiler/rake-compiler-dock-image:snapshot-mri-x86_64-linux`
- `ghcr.io/rake-compiler/rake-compiler-dock-image:snapshot-mri-x86_64-linux-gnu`

These images are intended for integration testing. They may not work properly and should not be considered production ready.

Expand All @@ -237,7 +248,7 @@ The following variables are recognized by rake-compiler-dock:
* `RCD_RUBYVM` - The ruby VM and toolchain to be used.
Must be one of `mri`, `jruby`.
* `RCD_PLATFORM` - The target rubygems platform.
Must be a space separated list out of `x86-mingw32`, `x64-mingw-ucrt`, `x64-mingw32`, `x86-linux`, `x86_64-linux`, `arm-linux`, `aarch64-linux`, `x86_64-darwin` and `arm64-darwin`.
Must be a space separated list out of `aarch64-linux-gnu`, `arm-linux-gnu`, `arm64-darwin`, `x64-mingw-ucrt`, `x64-mingw32`, `x86-linux-gnu`, `x86-mingw32`, `x86_64-darwin`, `x86_64-linux-gnu`.
It is ignored when `rubyvm` is set to `:jruby`.
* `RCD_IMAGE` - The docker image that is downloaded and started.
Defaults to "ghcr.io/rake-compiler/rake-compiler-dock-image:IMAGE_VERSION-PLATFORM" with an image version that is determined by the gem version.
Expand Down
15 changes: 8 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ CLEAN.include("tmp")
RakeCompilerDock::GemHelper.install_tasks

platforms = [
["x86-mingw32", "i686-w64-mingw32"],
["x64-mingw32", "x86_64-w64-mingw32"],
# tuple is [platform, target]
["aarch64-linux-gnu", "aarch64-linux-gnu"],
["arm-linux-gnu", "arm-linux-gnueabihf"],
["arm64-darwin", "aarch64-apple-darwin"],
["x64-mingw-ucrt", "x86_64-w64-mingw32"],
["x86-linux", "i686-redhat-linux"],
["x86_64-linux", "x86_64-redhat-linux"],
["x64-mingw32", "x86_64-w64-mingw32"],
["x86-linux-gnu", "i686-redhat-linux-gnu"],
["x86-mingw32", "i686-w64-mingw32"],
["x86_64-darwin", "x86_64-apple-darwin"],
["arm64-darwin", "aarch64-apple-darwin"],
["arm-linux", "arm-linux-gnueabihf"],
["aarch64-linux", "aarch64-linux-gnu"],
["x86_64-linux-gnu", "x86_64-redhat-linux-gnu"],
]

namespace :build do
Expand Down
3 changes: 2 additions & 1 deletion lib/rake_compiler_dock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ module RakeCompilerDock
#
# Option +:platform+ can be set to a list of space separated values.
# It selects the docker image(s) with an appropriate toolchain.
# Allowed values are +:x86-mingw32+, +x64-mingw32+, +x86-linux+ or +x86_64-linux+.
# Allowed values are +aarch64-linux-gnu+, +arm-linux-gnu+, +arm64-darwin+, +x64-mingw-ucrt+,
# +x64-mingw32+, +x86-linux-gnu+, +x86-mingw32+, +x86_64-darwin+, +x86_64-linux-gnu+.
# If the list contains multiple values, +cmd+ is consecutively executed in each of the docker images,
# Option +:platform+ is ignored when +:rubyvm+ is set to +:jruby+.
# Default is "x86-mingw32 x64-mingw32" .
Expand Down
12 changes: 11 additions & 1 deletion test/rcd_test/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ else
ext.ext_dir = 'ext/mri'
ext.lib_dir = 'lib/rcd_test'
ext.cross_compile = true
ext.cross_platform = %w[x86-mingw32 x64-mingw-ucrt x64-mingw32 x86-linux x86_64-linux aarch64-linux arm-linux x86_64-darwin arm64-darwin]
ext.cross_platform = %w[
aarch64-linux-gnu
arm-linux-gnu
arm64-darwin
x64-mingw-ucrt
x64-mingw32
x86-linux-gnu
x86-mingw32
x86_64-darwin
x86_64-linux-gnu
]
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/test_starter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_container_jrubyvm?
assert(Starter.container_jrubyvm?({:rubyvm => "jruby"}))
assert(Starter.container_jrubyvm?({:platform => "jruby"}))
refute(Starter.container_jrubyvm?({:rubyvm => "mri"}))
refute(Starter.container_jrubyvm?({:platform => "x86_64-linux"}))
refute(Starter.container_jrubyvm?({:platform => "x86_64-linux-gnu"}))
end

def test_platforms
Expand Down

0 comments on commit 0b25bbe

Please sign in to comment.