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

ruby: Make it possible for it to not reference cc at all #90151

Merged
merged 2 commits into from Nov 9, 2020

Conversation

doronbehar
Copy link
Contributor

@doronbehar doronbehar commented Jun 11, 2020

Motivation for this change

Fix #89445.

Ruby's build flag called removeReferencesToCC doesn't do it's job completely - The file rbconfig.rb still retained the reference to CC. It seems that's unavoidable if JIT support is enabled. JIT support is enabled by default and it's probable that some Gems require this feature. Since the normal ruby we are shipping ever since a while always retained this cc reference, I think it should be best to make it possible to build a ruby flavor such as rubyMinimal without cc reference and let that derivation alone while leaving all of the regular ruby's cc references as are (After @peterhoeg 's comment).

This for example allows for someone to add an override such as (tested):

self: super:

{
  ruby = super.ruby.override {
    # rubyMinimal disables too much features required by asciidoctor
    rubygemsSupport = true;
    jitSupport = false;
    useRailsExpress = false;
    zlibSupport = true;
    opensslSupport = true;
    gdbmSupport = false;
    cursesSupport = false;
    docSupport = false;
    yamlSupport = false;
    fiddleSupport = false;
  };
}

And this will allow them to not need GCC on their system for their usage of Ruby. For example, run with this PR and that overlay applied:

$ nix why-depends -f. asciidoctor gcc

And you should get:

'asciidoctor' does not depend on 'gcc'

But without this PR, (and the overlay would fail without the PR) you should get:

/nix/store/nyb3ry2yvhskrlni9dphfmj3w1ylakaw-asciidoctor-2.0.10
╚═══bin/asciidoctor -> /nix/store/06rmj52zhnb7kkp3dzvicaiddj9a8zmx-asciidoctor-2.0.10/bin/asciidoctor
    => /nix/store/06rmj52zhnb7kkp3dzvicaiddj9a8zmx-asciidoctor-2.0.10
    ╚═══bin/.asciidoctor-epub3-wrapped: …#!/nix/store/ighz4wp6bmpsm8x1lrsvwjz4m81r6a6d-ruby-2.6.6/bin/ruby.#.# This fi…
        => /nix/store/ighz4wp6bmpsm8x1lrsvwjz4m81r6a6d-ruby-2.6.6
        ╚═══lib/ruby/2.6.0/x86_64-linux/rbconfig.rb: …CONFIG["MJIT_CC"] = "/nix/store/r4l53b461b2lyclxn1pdj0n4hvbxl2l6-gcc-wrapper-9.3.0/bin/gcc".  CO…
            => /nix/store/r4l53b461b2lyclxn1pdj0n4hvbxl2l6-gcc-wrapper-9.3.0
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@doronbehar doronbehar changed the title ###### Motivation for this change rubyMinimal: Don't reference cc Jun 11, 2020
@ofborg ofborg bot added the 6.topic: ruby label Jun 11, 2020
@ofborg ofborg bot requested review from vrthra and manveru June 11, 2020 18:27
@pbogdan
Copy link
Member

pbogdan commented Jun 11, 2020

Am I correct in understanding that even disabling JIT explicitly still requires purging compiler references manually?

@doronbehar
Copy link
Contributor Author

Correct.

@doronbehar doronbehar changed the title rubyMinimal: Don't reference cc ruby: Make it possible for it tn not reference cc Jun 13, 2020
@doronbehar doronbehar changed the title ruby: Make it possible for it tn not reference cc ruby: Make it possible for it to not reference cc at all Jun 13, 2020
@FRidh FRidh added this to WIP in Staging via automation Jul 2, 2020
@FRidh FRidh moved this from WIP to Needs review in Staging Jul 2, 2020
@doronbehar
Copy link
Contributor Author

Fixed a bit the release notes and the comment near the JitSupport flag.

@doronbehar
Copy link
Contributor Author

Rebased, and checked once more that jitSupport = false; creates a ruby without gcc reference.

pkgs/top-level/aliases.nix Outdated Show resolved Hide resolved
Staging automation moved this from Needs review to Ready Nov 9, 2020
If JIT support is built in to ruby, there's no choice other then to
leave this cc reference as is. removeReferencesToCC didn't do it's job
completely since some time ago. That's why it was practically redundant
- `lib/ruby/${version}/<platform>/rbconfig.rb` still referenced cc.
Removing this reference from
`lib/ruby/${version}/<platform>/rbconfig.rb` as well might lead to
breakage in some Gems that require this feature.

But, if JIT support is not desired, it should be safe enough to
completely remove all cc references, both in
lib/ruby/${version}/<platform>/rbconfig.rb and in $out/lib/libruby.so .
Hence now `rubyMinimal` has JIT support disabled and it has no
references at all to stdenv.cc.
Due to being unused, and seemingly unusable, added appropriate release
notes.
@doronbehar doronbehar changed the base branch from master to staging November 9, 2020 14:18
@doronbehar
Copy link
Contributor Author

Thanks for the approval, will merge to staging once CI is green.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/is-nixpkgs-rubys-closure-supposed-to-include-clang/9922/2

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

Successfully merging this pull request may close these issues.

Disable jit support for rubyMinimal - to reduce closure size significantly
4 participants