From c14486ae8d3bbc862c625d948a6b2f4dc0927d5b Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sun, 1 Sep 2024 01:37:10 +0200 Subject: [PATCH] forbid gcc for compilation, only allow clang while gcc 12 and older miscompile our generators, gcc 13 and older outright crash on kj coroutines. (newer gcc versions may fix this) Change-Id: I19f12c8c147239680eb0fa5a84ef5c7de38c9263 --- flake.nix | 11 ++++++++--- meson.build | 10 +++++++++- package.nix | 4 ++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 662469479..46f9e43e8 100644 --- a/flake.nix +++ b/flake.nix @@ -99,9 +99,10 @@ ]; stdenvs = [ - "gccStdenv" + # see assertion in package.nix why these two are disabled + # "stdenv" + # "gccStdenv" "clangStdenv" - "stdenv" "libcxxStdenv" "ccacheStdenv" ]; @@ -121,7 +122,11 @@ name = "${stdenvName}Packages"; value = f stdenvName; }) stdenvs - ); + ) + // { + # TODO delete this and reënable gcc stdenvs once gcc compiles kj coros correctly + stdenvPackages = f "clangStdenv"; + }; # Memoize nixpkgs for different platforms for efficiency. nixpkgsFor = forAllSystems ( diff --git a/meson.build b/meson.build index b015cc606..f89f5a016 100644 --- a/meson.build +++ b/meson.build @@ -167,10 +167,18 @@ endif # frees one would expect when the objects are unique_ptrs. these problems # often show up as memory corruption when nesting generators (since we do # treat generators like owned memory) and will cause inexplicable crashs. +# +# gcc 13 does not compile capnp coroutine code correctly. a newer version +# may fix this. (cf. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102051) +# we allow gcc 13 here anyway because CI uses it for clang-tidy, and when +# the compiler crashes outright if won't produce any bad binaries either. assert( cxx.get_id() != 'gcc' or cxx.version().version_compare('>=13'), - 'GCC 12 and earlier are known to miscompile lix coroutines, use GCC 13 or clang.' + 'GCC is known to miscompile coroutines, use clang.' ) +if cxx.get_id() == 'gcc' + warning('GCC is known to crash while building coroutines, use clang.') +endif # Translate some historical and Mesony CPU names to Lixy CPU names. diff --git a/package.nix b/package.nix index e5ab5eff0..eebf222b7 100644 --- a/package.nix +++ b/package.nix @@ -90,6 +90,10 @@ capnproto-lix = capnproto.overrideAttrs { CXXFLAGS = "-std=c++20"; }; }, }: + +# gcc miscompiles coroutines at least until 13.2, possibly longer +assert stdenv.cc.isClang || lintInsteadOfBuild; + let inherit (__forDefaults) canRunInstalled; inherit (lib) fileset;