linuxPackages_latest.perf: add -O1 workaround for gcc-13

Without the change `perf top` just crashes early as:

    $ perf top
    perf: Segmentation fault
    -------- backtrace --------
    /<<NIX>>/perf-linux-6.7.4/bin/perf[0x627382]
    /<<NIX>>/glibc-2.38-27/lib/libc.so.6(+0x3deb0)[0x7f423a054eb0]
    /<<NIX>>/perf-linux-6.7.4/bin/perf(__dsos__findnew_link_by_longname_id+0x34b)[0x53655b]
    /<<NIX>>/perf-linux-6.7.4/bin/perf(map__new+0x35f)[0x55884f]
    /<<NIX>>/perf-linux-6.7.4/bin/perf(machine__process_mmap2_event+0xb7)[0x557b27]
    /<<NIX>>/perf-linux-6.7.4/bin/perf(perf_tool__process_synth_event+0x7e)[0x59e86e]
    /<<NIX>>/perf-linux-6.7.4/bin/perf(perf_event__synthesize_mmap_events+0x370)[0x59f0e0]
    /<<NIX>>/perf-linux-6.7.4/bin/perf[0x59fd5c]
    /<<NIX>>/perf-linux-6.7.4/bin/perf[0x59ffcc]
    /<<NIX>>/perf-linux-6.7.4/bin/perf[0x5a0093]
    /<<NIX>>/glibc-2.38-27/lib/libc.so.6(+0x8b333)[0x7f423a0a2333]
    /<<NIX>>/glibc-2.38-27/lib/libc.so.6(+0x10defc)[0x7f423a124efc]

It's a known `gcc-12+` bug not yet fixed in `gcc-13`: https://gcc.gnu.org/PR111009

Let's demote optimizations from `-O2` down to `-O1` to disable any
VRP-related effects for affected `gcc-13`.
This commit is contained in:
Sergei Trofimovich 2024-02-08 20:51:54 +00:00
parent a5d28c9bff
commit 410d15e156

View File

@ -129,12 +129,17 @@ stdenv.mkDerivation {
++ lib.optional (lib.versionAtLeast kernel.version "5.8") libpfm
++ lib.optional (lib.versionAtLeast kernel.version "6.0") python3.pkgs.setuptools;
env.NIX_CFLAGS_COMPILE = toString [
env.NIX_CFLAGS_COMPILE = toString ([
"-Wno-error=cpp"
"-Wno-error=bool-compare"
"-Wno-error=deprecated-declarations"
"-Wno-error=stringop-truncation"
];
] ++ lib.optionals (stdenv.cc.isGNU && lib.versions.major stdenv.cc.version == "13") [
# Workaround gcc bug that causes enev simplest `perf top` runs to
# crash: https://gcc.gnu.org/PR111009.
# Can be removed once gcc-13 is updated past 13.2.0.
"-O1"
]);
doCheck = false; # requires "sparse"