From 1c2dfb8de915aa9fbabed038e30afbb2d6c9ed74 Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 20 Jun 2025 11:22:11 +0100 Subject: [PATCH] gcc: use `sanitiseHeaderPathsHook` This reduces the WebKitGTK runtime closure size from 1.45 GiB to 1.22 GiB on `aarch64-linux`, as measured by `nix-tree`. --- pkgs/development/compilers/gcc/common/dependencies.nix | 5 +++++ pkgs/development/compilers/gcc/default.nix | 2 ++ 2 files changed, 7 insertions(+) diff --git a/pkgs/development/compilers/gcc/common/dependencies.nix b/pkgs/development/compilers/gcc/common/dependencies.nix index ee62f1da0e1f..38cbcc2682b1 100644 --- a/pkgs/development/compilers/gcc/common/dependencies.nix +++ b/pkgs/development/compilers/gcc/common/dependencies.nix @@ -12,6 +12,7 @@ gmp, mpfr, libmpc, + sanitiseHeaderPathsHook, libucontext ? null, libxcrypt ? null, isSnapshot ? false, @@ -42,6 +43,10 @@ in texinfo which gettext + + # Prevent GCC leaking into the runtime closure of C++ packages + # through headers using `__FILE__`. + sanitiseHeaderPathsHook ] ++ optionals (perl != null) [ perl ] ++ optionals (with stdenv.targetPlatform; isVc4 || isRedox || isSnapshot && flex != null) [ flex ] diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix index 1cd81dc4f669..a3d54f1b8525 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -49,6 +49,7 @@ !enablePlugin || (stdenv.targetPlatform.isAvr && stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64), nukeReferences, + sanitiseHeaderPathsHook, callPackage, majorMinorVersion, apple-sdk, @@ -179,6 +180,7 @@ let pkgsBuildTarget profiledCompiler reproducibleBuild + sanitiseHeaderPathsHook staticCompiler stdenv targetPackages