ruby: add removeReferenceToCC package option

Reduces the runtime closure by ~200MB if enabled.
This commit is contained in:
Profpatsch 2019-12-12 16:38:55 +01:00
parent add4e5ea66
commit 80c07f8aaf

View File

@ -3,7 +3,7 @@
, zlib, openssl, gdbm, ncurses, readline, groff, libyaml, libffi, autoreconfHook, bison
, autoconf, libiconv, libobjc, libunwind, Foundation
, buildEnv, bundler, bundix
, makeWrapper, buildRubyGem, defaultGemConfig
, makeWrapper, buildRubyGem, defaultGemConfig, removeReferencesTo
} @ args:
let
@ -44,6 +44,11 @@ let
, groff, docSupport ? true
, libyaml, yamlSupport ? true
, libffi, fiddleSupport ? true
# ruby -e "puts RbConfig::CONFIG['configure_args']"
# puts a reference to the C compiler in the binary.
# This might be required by some gems at runtime,
# but we allow to strip it out for smaller closure size.
, removeReferencesTo, removeReferenceToCC ? false
, autoreconfHook, bison, autoconf
, buildEnv, bundler, bundix
, libiconv, libobjc, libunwind, Foundation
@ -145,6 +150,13 @@ let
# Remove unnecessary groff reference from runtime closure, since it's big
sed -i '/NROFF/d' $out/lib/ruby/*/*/rbconfig.rb
${lib.optionalString removeReferenceToCC ''
# Get rid of the CC runtime dependency
${removeReferencesTo}/bin/remove-references-to \
-t ${stdenv.cc} \
$out/lib/libruby.so.*
''}
# Bundler tries to create this directory
mkdir -p $out/nix-support
cat > $out/nix-support/setup-hook <<EOF