git.iko.soy/typeable/nixpkgs
on master help sign in
firefox: add ltoSupport and enable it by default
commit4f12bddea6b6e5b38ccd54c66d0be53e7a1df465 authorS. Nordin Abouzahra <abouzahra.9@wright.edu> dateTue 6 Oct 2020, 14:14 (6 years ago) parent301d04f
1 file changed+37−17
pkgs/applications/networking/browsers/firefox/common.nix+37−17
pkgs/applications/networking/browsers/firefox/common.nix+37−17
@@ -9,7 +9,7 @@
99, hunspell, libXdamage, libevent, libstartup_notification
1010, libvpx_1_8
1111, icu67, libpng, jemalloc, glib
12−, autoconf213, which, gnused, cargo, rustc, llvmPackages
12+, autoconf213, which, gnused, cargo, rustc
1313, rust-cbindgen, nodejs, nasm, fetchpatch
1414, debugBuild ? false
1515
@@ -22,6 +22,7 @@
2222, ffmpegSupport ? true
2323, gtk3Support ? true, gtk2, gtk3, wrapGAppsHook
2424, waylandSupport ? true, libxkbcommon
25+, ltoSupport ? true, overrideCC, buildPackages
2526, gssSupport ? true, kerberos
2627, pipewireSupport ? waylandSupport && webrtcSupport, pipewire
2728
@@ -87,9 +88,14 @@ let
8788 then "/Applications/${binaryNameCapitalized}.app/Contents/MacOS"
8889 else "/bin";
8990
91+ llvmPackages = buildPackages.llvmPackages_10;
92+
93+ buildStdenv = if ltoSupport
94+ then overrideCC stdenv llvmPackages.lldClang
95+ else stdenv;
9096in
9197
92−stdenv.mkDerivation ({
98+buildStdenv.mkDerivation ({
9399 name = "${pname}-unwrapped-${ffversion}";
94100 version = ffversion;
95101
@@ -131,11 +137,17 @@ stdenv.mkDerivation ({
131137 ++ lib.optional pulseaudioSupport libpulseaudio # only headers are needed
132138 ++ lib.optional gtk3Support gtk3
133139 ++ lib.optional gssSupport kerberos
140+ ++ lib.optional ltoSupport llvmPackages.libunwind
134141 ++ lib.optionals waylandSupport [ libxkbcommon ]
135142 ++ lib.optionals pipewireSupport [ pipewire ]
136− ++ lib.optionals stdenv.isDarwin [ CoreMedia ExceptionHandling Kerberos
137− AVFoundation MediaToolbox CoreLocation
138− Foundation libobjc AddressBook cups ];
143+ ++ lib.optionals buildStdenv.isDarwin [ CoreMedia ExceptionHandling Kerberos
144+ AVFoundation MediaToolbox CoreLocation
145+ Foundation libobjc AddressBook cups ];
146+
147+ NIX_LDFLAGS = lib.optionalString ltoSupport ''
148+ -rpath ${placeholder "out"}/lib/${binaryName}
149+ -rpath ${llvmPackages.libunwind.out}/lib
150+ '';
139151
140152 NIX_CFLAGS_COMPILE = toString [
141153 "-I${glib.dev}/include/gio-unix-2.0"
@@ -179,7 +191,7 @@ stdenv.mkDerivation ({
179191 which
180192 ]
181193 ++ lib.optional gtk3Support wrapGAppsHook
182− ++ lib.optionals stdenv.isDarwin [ xcbuild rsync ]
194+ ++ lib.optionals buildStdenv.isDarwin [ xcbuild rsync ]
183195 ++ extraNativeBuildInputs;
184196
185197 preConfigure = ''
@@ -197,12 +209,12 @@ stdenv.mkDerivation ({
197209 # included we need to look in a few places.
198210 # TODO: generalize this process for other use-cases.
199211
200− BINDGEN_CFLAGS="$(< ${stdenv.cc}/nix-support/libc-crt1-cflags) \
201− $(< ${stdenv.cc}/nix-support/libc-cflags) \
202− $(< ${stdenv.cc}/nix-support/cc-cflags) \
203− $(< ${stdenv.cc}/nix-support/libcxx-cxxflags) \
204− ${lib.optionalString stdenv.cc.isClang "-idirafter ${stdenv.cc.cc}/lib/clang/${lib.getVersion stdenv.cc.cc}/include"} \
205− ${lib.optionalString stdenv.cc.isGNU "-isystem ${stdenv.cc.cc}/include/c++/${lib.getVersion stdenv.cc.cc} -isystem ${stdenv.cc.cc}/include/c++/${lib.getVersion stdenv.cc.cc}/${stdenv.hostPlatform.config}"} \
212+ BINDGEN_CFLAGS="$(< ${buildStdenv.cc}/nix-support/libc-crt1-cflags) \
213+ $(< ${buildStdenv.cc}/nix-support/libc-cflags) \
214+ $(< ${buildStdenv.cc}/nix-support/cc-cflags) \
215+ $(< ${buildStdenv.cc}/nix-support/libcxx-cxxflags) \
216+ ${lib.optionalString buildStdenv.cc.isClang "-idirafter ${buildStdenv.cc.cc}/lib/clang/${lib.getVersion buildStdenv.cc.cc}/include"} \
217+ ${lib.optionalString buildStdenv.cc.isGNU "-isystem ${buildStdenv.cc.cc}/include/c++/${lib.getVersion buildStdenv.cc.cc} -isystem ${buildStdenv.cc.cc}/include/c++/${lib.getVersion buildStdenv.cc.cc}/${buildStdenv.hostPlatform.config}"} \
206218 $NIX_CFLAGS_COMPILE"
207219
208220 echo "ac_add_options BINDGEN_CFLAGS='$BINDGEN_CFLAGS'" >> $MOZCONFIG
@@ -236,11 +248,19 @@ stdenv.mkDerivation ({
236248 "--enable-jemalloc"
237249 "--enable-default-toolkit=${default-toolkit}"
238250 "--with-libclang-path=${llvmPackages.libclang}/lib"
239− "--with-clang-path=${llvmPackages.clang}/bin/clang"
240251 "--with-system-nspr"
241252 "--with-system-nss"
242253 ]
243− ++ lib.optional (stdenv.isDarwin) "--disable-xcode-checks"
254+ ++ lib.optional (buildStdenv.isDarwin) "--disable-xcode-checks"
255+ ++ lib.optional (!ltoSupport) "--with-clang-path=${llvmPackages.clang}/bin/clang"
256+ # LTO is done using clang and lld.
257+ # elf-hack is broken when using clang:
258+ # https://bugzilla.mozilla.org/show_bug.cgi?id=1482204
259+ ++ lib.optionals ltoSupport [
260+ "--enable-lto"
261+ "--enable-linker=lld"
262+ "--disable-elf-hack"
263+ ]
244264
245265 ++ flag alsaSupport "alsa"
246266 ++ flag pulseaudioSupport "pulseaudio"
@@ -270,12 +290,12 @@ stdenv.mkDerivation ({
270290 enableParallelBuilding = true;
271291 doCheck = false; # "--disable-tests" above
272292
273− installPhase = if stdenv.isDarwin then ''
293+ installPhase = if buildStdenv.isDarwin then ''
274294 mkdir -p $out/Applications
275295 cp -LR dist/${binaryNameCapitalized}.app $out/Applications
276296 '' else null;
277297
278− postInstall = lib.optionalString stdenv.isLinux ''
298+ postInstall = lib.optionalString buildStdenv.isLinux ''
279299 # Remove SDK cruft. FIXME: move to a separate output?
280300 rm -rf $out/share/idl $out/include $out/lib/${binaryName}-devel-*
281301
@@ -283,7 +303,7 @@ stdenv.mkDerivation ({
283303 gappsWrapperArgs+=(--argv0 "$out/bin/.${binaryName}-wrapped")
284304 '';
285305
286− postFixup = lib.optionalString stdenv.isLinux ''
306+ postFixup = lib.optionalString buildStdenv.isLinux ''
287307 # Fix notifications. LibXUL uses dlopen for this, unfortunately; see #18712.
288308 patchelf --set-rpath "${lib.getLib libnotify
289309 }/lib:$(patchelf --print-rpath "$out"/lib/${binaryName}*/libxul.so)" \