Skip to content

Setup initial cross compilation workflow#1

Merged
ianks merged 3 commits intomainfrom
cross-gem/init
Oct 29, 2022
Merged

Setup initial cross compilation workflow#1
ianks merged 3 commits intomainfrom
cross-gem/init

Conversation

@ianks
Copy link
Copy Markdown
Collaborator

@ianks ianks commented Oct 21, 2022

This is a PR to setup cross gem compilation. Right now, it just adds the ability to cross compile gems via Github UI. We'll figure out publishing later.

@ianks ianks requested a review from jbourassa October 21, 2022 20:46
@ianks
Copy link
Copy Markdown
Collaborator Author

ianks commented Oct 22, 2022

cha-ching!

Copy link
Copy Markdown
Collaborator

@jbourassa jbourassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you so much Ian.

I see the cross-compile's smoke test fails:

ERROR:  Error installing pkg/wasmtime-rb-0.1.0-x86_64-linux.gem:
  wasmtime-rb-0.1.0-x86_64-linux requires Ruby version >= 3.0, < > 3.1.dev. The current ruby version is 3.1.2.20.

Looks like we're only building for 3.0.0:

no configuration section for specified version of Ruby (rbconfig-x86_64-linux-"3.1.0)
no configuration section for specified version of Ruby (rbconfig-x86_64-linux-2.7.0")

Searching for that error message led me to rake-compiler. Looks like config.yml doesn't have entries for all rubies. Is it because xrubies bundles 1 ruby version per image, unlike rake-compiler-docker?

Edit: also no idea where 3.0.0 is coming from. I understand the intent to be "build for all RUBY_CC_VERSION", not only 3.0.0 🤔.

run: |
bundle exec rake build
gem install pkg/wasmtime-rb-*.gem --verbose
script="puts Wasmtime::Engine.new(Wasmtime::Config.new).precompile_module('(module)')"
Copy link
Copy Markdown
Collaborator

@jbourassa jbourassa Oct 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the config is optional now, this should also work:

Suggested change
script="puts Wasmtime::Engine.new(Wasmtime::Config.new).precompile_module('(module)')"
script="puts Wasmtime::Engine.new.precompile_module('(module)')"

@ianks
Copy link
Copy Markdown
Collaborator Author

ianks commented Oct 27, 2022

@jbourassa I am very confused about this as well. Not sure where the bug is… Gonna contact rake-compiler team

@flavorjones
Copy link
Copy Markdown

flavorjones commented Oct 27, 2022

The current error, I think, is because rake-compiler will put the cross-compiled shared object file into a subdirectory named after the ruby minor version (e.g., lib/wasmtime/3.1/ext.so instead of lib/wasmtime/ext.so).

You can see this in the build log: https://github.com/bytecodealliance/wasmtime-rb/actions/runs/3340442663/jobs/5530540697#step:4:280

You should look first for a ruby-specific precompiled .so, and fall back to lib/wasmtime/ext.so if you can't find it (which means the user compiled upon installation). A lot of this is explained in https://github.com/flavorjones/ruby-c-extensions-explained/tree/main/precompiled

An example of how to do this is

Hope this helps!

@ianks ianks requested a review from jbourassa October 28, 2022 19:18
@ianks ianks merged commit b23985d into main Oct 29, 2022
@ianks ianks deleted the cross-gem/init branch October 29, 2022 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants