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

portable-ruby: fix more compiler toolchain references #187

Merged
merged 1 commit into from Apr 20, 2024

Conversation

ZhongRuoyu
Copy link
Member

We already get rid of the compiler shim references in rbconfig.rb, but there are still some more that may not be valid on the target system:

$ brew ruby -e 'p RbConfig::CONFIG.select { |k, v| v.match? /gcc-(.*)-\d+/ }'
{"RANLIB"=>"gcc-ranlib-11", "NM"=>"gcc-nm-11", "AR"=>"gcc-ar-11"}

We can replace them with ranlib, nm, and ar, respectively.

This should help to avoid issues like the one spotted in Homebrew/brew#17114.

We already get rid of the compiler shim references in `rbconfig.rb`, but
there are still some more that may not be valid on the target system:

    $ brew ruby -e 'p RbConfig::CONFIG.select { |k, v| v.match? /gcc-(.*)-\d+/ }'
    {"RANLIB"=>"gcc-ranlib-11", "NM"=>"gcc-nm-11", "AR"=>"gcc-ar-11"}

We can replace them with `ranlib`, `nm`, and `ar`, respectively.

This should help to avoid issues like the one spotted in
Homebrew/brew#17114.
@ParadoxV5
Copy link

Maybe the solution for the core problem is to have the Ruby builder use these agnostic names in the first place?


Interesting. Portable Ruby. I know RubyInstaller2 for Windows is portable, but never knew that Mac and Linux also have this.

@ZhongRuoyu
Copy link
Member Author

Maybe the solution for the core problem is to have the Ruby builder use these agnostic names in the first place?

That's possible too; they can be overridden with ENV["AR"], etc. Those gcc-* tools are wrappers that pass the LTO plugin, although we don't seem to have enabled LTO.

Interesting. Portable Ruby. I know RubyInstaller2 for Windows is portable, but never knew that Mac and Linux also have this.

This is for Homebrew's internal use only; we don't advertise it or provide download or support for general usage like RubyInstaller or others do.

@ZhongRuoyu ZhongRuoyu requested a review from Bo98 April 20, 2024 03:17
@Bo98
Copy link
Member

Bo98 commented Apr 20, 2024

Maybe the solution for the core problem is to have the Ruby builder use these agnostic names in the first place?

Same has applied to cc for years - this is just an extension to that workaround to cover ar too. In our particular case, the host compiler doesn't necessarily match the target compiler, so we replace gcc-XX references with cc etc.

On macOS, this generally isn't a problem since clang will always exist if you have macOS SDK installed. And we do not see full paths like you are seeing in that prism issue:

"AR" => "ar",
"CC" => "clang",

Copy link
Member

@Bo98 Bo98 left a comment

Choose a reason for hiding this comment

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

Thanks, will make a new release soon

@Bo98 Bo98 merged commit 6db5441 into master Apr 20, 2024
5 checks passed
@Bo98 Bo98 deleted the fix-more-toolchain-refs branch April 20, 2024 04:23
@MikeMcQuaid
Copy link
Member

Thanks @ZhongRuoyu!

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.

None yet

4 participants