Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: first-class musl support #3111

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

flavorjones
Copy link
Member

What problem is this PR intended to solve?

Ship linux-musl gems built specifically for musl libc systems.

Although there are no existing issues that this addresses, we've been bitten in the past by musl incompatibilities and this should prevent those sorts of problems going forward.

Also: upgrade to rake-compiler-dock 1.5.0.rc1

Have you included adequate test coverage?

Test coverage has been updated.

Does this change affect the behavior of either the C or the Java implementations?

No functional changes.

@flavorjones
Copy link
Member Author

Found a pretty significant blocker this weekend. We probably cannot release this unless rubygems/rubygems#7432 is addressed in bundler or rubygems.

And even then, we probably need additional documentation to help people resolve issues.

Putting this on hold until we know more.

kou pushed a commit to rake-compiler/rake-compiler that referenced this pull request Jan 30, 2024
…x libc (#236)

### Problem I'm trying to solve

Rubygems does not correctly recognize `-musl` or `-gnu` platform
suffixes until v3.3.22.

### Solution

If rake-compiler is building a linux native gem that specifies a libc in
its platform object, then add ">= 3.3.22" to the
required_rubygems_version requirement.


https://github.com/rubygems/rubygems/blob/master/CHANGELOG.md#3322--2022-09-07

### Context

While working on musl support in the precompilation toolchain:

- rake-compiler/rake-compiler-dock#111
- flavorjones/ruby-c-extensions-explained#27
- sparklemotion/sqlite3-ruby#442
- sparklemotion/nokogiri#3111

I noticed that Ruby 3.0 is still shipping with Rubygems 3.2.33, which
does not recognize these gem platforms.

Specifying the rubygems requirement changes the error experienced by
users during gem installation from:

> ERROR:  While executing gem ... (Gem::Exception)
> Unable to find spec for #<Gem::NameTuple rcee_precompiled,
0.6.test.2024.0128.1724, aarch64-linux>

to:

> ERROR: Error installing
rcee_precompiled-0.6.test.2024.0128.1735-x86_64-linux-musl.gem:
> rcee_precompiled-0.6.test.2024.0128.1735-x86_64-linux-musl requires
RubyGems version >= 3.3.22.
> The current RubyGems version is 3.2.33. Try 'gem update --system' to
update RubyGems itself.
@flavorjones flavorjones force-pushed the flavorjones-first-class-musl-support branch from a8bdd44 to 6c94d58 Compare February 7, 2024 16:57
@flavorjones
Copy link
Member Author

Picking this back up again since the fix to the rubygems issue mentioned above was released in bundler 2.5.6.

@flavorjones flavorjones force-pushed the flavorjones-first-class-musl-support branch 4 times, most recently from 7261336 to c581896 Compare February 7, 2024 20:54
@flavorjones flavorjones force-pushed the flavorjones-first-class-musl-support branch from c581896 to 94592d2 Compare February 25, 2024 15:38
@flavorjones
Copy link
Member Author

I'm proceeding carefully here since an exploration shows that the version of rubygems and bundler that ships with Ruby 3.0 by default don't work well with the -linux-musl platform name, see rake-compiler/rake-compiler-dock#117

My instinct is to wait until we drop support for Ruby 3.0 in Nokogiri before we ship first-class musl support, since we don't know of any issues with the current linux gem.

@flavorjones
Copy link
Member Author

Additional note that I had forgotten about: There are some things we're doing to work around precompiled-musl-support-from-a-gnu-toolchain.

Specifically I'm thinking of:

  1. We are compiling with -U_FORTIFY_SOURCE to avoid issues on musl (see Compile native extensions with '-O2 -g' flags #2100 and 0b49210). We should remove this workaround and compile with FORTIFY_SOURCE.
  2. I think the thread-local storage feature being turned off in 004e6a6 is also because of musl, see Update to libxml 2.12.0 or later #3031

@flavorjones flavorjones added this to the v1.18.0 milestone Jun 24, 2024
@flavorjones
Copy link
Member Author

Tagging for v1.18 which is when we're planning to drop support for Ruby 3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant