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

[install/bug] Alternate toolchain specified in ENV works, but does not work when passed as build arguments #3160

Open
1 task done
ziggythehamster opened this issue Mar 18, 2024 · 1 comment
Labels
topic/installation Installation difficulties

Comments

@ziggythehamster
Copy link
Contributor

Have you read and followed the installation tutorial at http://www.nokogiri.org/tutorials/installing_nokogiri.html?

  • Yes!

We are using a non-default toolchain, so e.g. ld is available at gcc10-ld. For most gems with native code, they either use RbConfig to locate the toolchain (RbConfig::CONFIG['LD'] # => "gcc10-ld") or allow you to specify them as build arguments, e.g. gem install foo -- LD=gcc10-ld or bundle config build.foo LD=gcc10-ld. Nokogiri seems to pass along CC but won't pass along LD or AR to the libxml2 build.

Nokogiri will pass these along if they are defined in ENV, however.

This results in this not working:

gem install --platform ruby nokogiri -- AR=gcc10-ar CC=gcc10-cc CXX=gcc10-c++ LD=gcc10-ld

But this works:

AR=gcc10-ar CC=gcc10-cc CXX=gcc10-c++ LD=gcc10-ld gem install --platform ruby nokogiri

The former would be preferred, because I can configure BUNDLE_BUILD__NOKOGIRI in the "user" bundler config file to correctly specify these. The latter requires someone who is bundle install'ing to specify the toolchain (which they should not need to know about).

I think that this would be a rather simple change to extconf.rb, but I'm not sure if this would be an accepted change or not.

@ziggythehamster ziggythehamster added the topic/installation Installation difficulties label Mar 18, 2024
@flavorjones
Copy link
Member

@ziggythehamster Thanks for opening this, I think this is just an oversight. I would absolutely review to a PR to pass these other values through!

flavorjones added a commit that referenced this issue Apr 27, 2024
**What problem is this PR intended to solve?**

#3160

Note I also have branches that fix this on v1.16.x and v1.15.x, but I
wanted to make sure I actioned feedback in one place before I opened
additional MRs.

Also note that Nokogiri doesn't seem to honor variables passed as gem
configuration args, and I didn't add that here because I'm not entirely
sure what the "canonical" way to do this is with mkmf/mini_portile. In
other situations where I need to provide the toolchain
(rdkafka/karafka-rdkafka), there seems to be no special code to convert
`FOO=BAR` to an env var.

That said, it's not actually necessary in my case because using `AR` and
`LD` from `RbConfig` is sufficient. So one might say if you need to do
something different from that, maybe it's actually a good thing that you
would need to do `AR=x gem install nokogiri` rather than `gem install
nokogiri -- AR=x`. I can take a stab at making this work, though, if the
team thinks that both ways should work.

**Have you included adequate test coverage?**

N/A but I assume if it breaks the build in some configuration I didn't
test, GitHub Actions will be mad about it :).

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

No
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/installation Installation difficulties
Projects
None yet
Development

No branches or pull requests

2 participants