From b0c8affbd943b6d86bf650ceab7faa16eacaddcb Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Sat, 16 Apr 2022 21:12:03 +0200 Subject: gcc: avoid excessive stat calls (#30005) For about a decade GCC has an option `-f[no]-canonical-system-headers` which basically runs `realpath` on all "system headers", to possibly reduce the length of paths in diagnostics. [1] Spack usually installs the "system headers" of GCC in very deeply nested directories. Calling `realpath` there results in stat calls on every level, for every header file. On some slow filesystem I have, `-fno-canonical-system-headers` gives about 5x speedup to compile hello world in C, meaning that ./configure scripts would be much faster when using this flag by default. [1] https://codereview.appspot.com/6495088 --- var/spack/repos/builtin/packages/gcc/package.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/var/spack/repos/builtin/packages/gcc/package.py b/var/spack/repos/builtin/packages/gcc/package.py index 04c0e31ac0..cf3765fb31 100644 --- a/var/spack/repos/builtin/packages/gcc/package.py +++ b/var/spack/repos/builtin/packages/gcc/package.py @@ -523,6 +523,11 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage): '--disable-nls' ] + # Avoid excessive realpath/stat calls for every system header + # by making -fno-canonical-system-headers the default. + if self.version >= Version('4.8.0'): + options.append('--disable-canonical-system-headers') + # Use installed libz if self.version >= Version('6'): options.append('--with-system-zlib') -- cgit v1.2.3-70-g09d2