From 0e5f7501b613b09e2f22db4a1609470fa5bdab81 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Mon, 10 Oct 2022 10:59:40 +0200 Subject: [PATCH] cbqn: always compile using clang Investigating the build failures of CBQN on i686 and aarch64, turns up that CBQN is broken on these platforms only with gcc. In the case of i686 due to a codegen bug, on aarch64 gcc doesn't like some CPP macros CBQN uses. The deeper reason for this is that CBQN primarily is developed for and tested with clang, so it probably saves us trouble just using clang, as it is no real problem for us to do so (clangStdenv is quite unproblematic for pure C builds). This should also yield faster binaries, since CBQN apparently uses some clang-specific tricks to get quicker code generation. --- pkgs/top-level/all-packages.nix | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ab58c766f7d0..7fff163119f3 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15148,22 +15148,35 @@ with pkgs; # Below, the classic self-bootstrapping process cbqn-bootstrap = lib.dontRecurseIntoAttrs { + # Use clang to compile CBQN if we aren't already. + # CBQN's upstream primarily targets and tests clang which means using gcc + # will result in slower binaries and on some platforms failing/broken builds. + # See https://github.com/dzaima/CBQN/issues/12. + # + # Known issues: + # + # * CBQN using gcc is broken at runtime on i686 due to + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58416, + # * CBQN uses some CPP macros gcc doesn't like for aarch64. + stdenv = if !stdenv.cc.isClang then clangStdenv else stdenv; + mbqn-source = buildPackages.mbqn.src; phase0 = callPackage ../development/interpreters/bqn/cbqn { + inherit (cbqn-bootstrap) stdenv; genBytecode = false; bqn-path = null; mbqn-source = null; }; phase1 = callPackage ../development/interpreters/bqn/cbqn { - inherit (cbqn-bootstrap) mbqn-source; + inherit (cbqn-bootstrap) mbqn-source stdenv; genBytecode = true; bqn-path = "${buildPackages.cbqn-bootstrap.phase0}/bin/cbqn"; }; phase2 = callPackage ../development/interpreters/bqn/cbqn { - inherit (cbqn-bootstrap) mbqn-source; + inherit (cbqn-bootstrap) mbqn-source stdenv; genBytecode = true; bqn-path = "${buildPackages.cbqn-bootstrap.phase1}/bin/cbqn"; };