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
This commit is contained in:
Harmen Stoppels
2022-04-16 21:12:03 +02:00
committed by GitHub
parent 03a7643816
commit b0c8affbd9

View File

@@ -523,6 +523,11 @@ def configure_args(self):
'--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')