electron_34-bin: fix read out of range on aarch64 16k pages systems (#382497)

This commit is contained in:
Emily 2025-02-17 14:01:44 +01:00 committed by GitHub
commit fca94f7fff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -131,6 +131,13 @@ let
]
);
# Fix read out of range on aarch64 16k pages builds
# https://github.com/NixOS/nixpkgs/pull/365364
# https://github.com/NixOS/nixpkgs/pull/380991
# Can likely be removed when v34.2.1 (or v32.3.0?) releases:
# https://github.com/electron/electron/pull/45571
needsAarch64PageSizeFix = lib.versionAtLeast version "34" && stdenv.hostPlatform.isAarch64;
linux = finalAttrs: {
buildInputs = [
glib
@ -153,6 +160,19 @@ let
chmod u-x $out/libexec/electron/*.so*
'';
# We use null here to not cause unnecessary rebuilds.
dontWrapGApps = if needsAarch64PageSizeFix then true else null;
preFixup =
if needsAarch64PageSizeFix then
''
wrapProgram "$out/libexec/electron/chrome_crashpad_handler" "''${gappsWrapperArgs[@]}"
wrapProgram "$out/libexec/electron/chrome-sandbox" "''${gappsWrapperArgs[@]}"
wrapProgram "$out/libexec/electron/electron" "''${gappsWrapperArgs[@]}" \
--add-flags "--js-flags=--no-decommit-pooled-pages"
''
else
null;
postFixup = ''
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \