From 1853d303516f91c958aae5ba9a86f9cfa840f364 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Fri, 7 Oct 2022 00:50:24 +0200 Subject: [PATCH 1/4] mbqn: 0.pre+date=2021-12-13 -> 0.pre+date=2022-10-03 --- pkgs/development/interpreters/bqn/mlochbaum-bqn/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/interpreters/bqn/mlochbaum-bqn/default.nix b/pkgs/development/interpreters/bqn/mlochbaum-bqn/default.nix index fbb5b458d08b..83d4a08e33dc 100644 --- a/pkgs/development/interpreters/bqn/mlochbaum-bqn/default.nix +++ b/pkgs/development/interpreters/bqn/mlochbaum-bqn/default.nix @@ -7,13 +7,13 @@ stdenvNoCC.mkDerivation rec { pname = "bqn"; - version = "0.pre+date=2021-12-13"; + version = "0.pre+date=2022-10-03"; src = fetchFromGitHub { owner = "mlochbaum"; repo = "BQN"; - rev = "2c2e86e10ff963a6aefa14f76fd8833ce3c9157c"; - hash = "sha256-iAlDXGlHTeI6+r/QKFiBHhj5A+FgUy7JFrCpAwpyVQU="; + rev = "1518205cceeb1fef27c584d24e92b189ffd234f4"; + hash = "sha256:1pyk331ymbs2fv9jxmbv28yvk9mr2mcni1dsja6fzkk1jrd767hy"; }; nativeBuildInputs = [ makeWrapper ]; From 1d7d8b4b0a4cef86bb7d70ec94d510f3ff4e4a0e Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Fri, 7 Oct 2022 00:51:01 +0200 Subject: [PATCH 2/4] cbqn: 0.pre+date=2022-05-06 -> 0.pre+date=2022-10-04 --- .../interpreters/bqn/cbqn/default.nix | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pkgs/development/interpreters/bqn/cbqn/default.nix b/pkgs/development/interpreters/bqn/cbqn/default.nix index 0426a72c81aa..fc426bb374bb 100644 --- a/pkgs/development/interpreters/bqn/cbqn/default.nix +++ b/pkgs/development/interpreters/bqn/cbqn/default.nix @@ -4,6 +4,7 @@ , genBytecode ? false , bqn-path ? null , mbqn-source ? null +, libffi }: let @@ -11,23 +12,27 @@ let name = "cbqn-bytecode-files"; owner = "dzaima"; repo = "CBQN"; - rev = "c39653c898531a2cdbf4cc5c764df6e37b1894a4"; - hash = "sha256-JCEmkwh5Rv5+NQoxvefSrYnayU892/Wam+gjMgcQmO0="; + rev = "3df8ae563a626ff7ae0683643092f0c3bc2481e5"; + hash = "sha256:0rh9qp1bdm9aa77l0kn9n4jdy08gl6l7898lncskxiq9id6xvyb8"; }; in assert genBytecode -> ((bqn-path != null) && (mbqn-source != null)); stdenv.mkDerivation rec { pname = "cbqn" + lib.optionalString (!genBytecode) "-standalone"; - version = "0.pre+date=2022-05-06"; + version = "0.pre+date=2022-10-04"; src = fetchFromGitHub { owner = "dzaima"; repo = "CBQN"; - rev = "3496a939b670f8c9ca2a04927378d6b7e9abd68e"; - hash = "sha256-P+PoY4XF9oEw7VIpmybvPp+jxWHEo2zt1Lamayf1mHg="; + rev = "abcb575a537712763e9e53b6cb0eb415346b00e6"; + hash = "sha256:05gqw2ppcykv36ji8mkp8mq502q84vk9algp9c2d3z495xqy8rn6"; }; + buildInputs = [ + libffi + ]; + dontConfigure = true; postPatch = '' @@ -44,7 +49,7 @@ stdenv.mkDerivation rec { '' + (if genBytecode then '' ${bqn-path} genRuntime ${mbqn-source} '' else '' - cp ${cbqn-bytecode-files}/src/gen/{compiles,formatter,runtime0,runtime1,src} src/gen/ + cp ${cbqn-bytecode-files}/src/gen/{compiles,explain,formatter,runtime0,runtime1,src} src/gen/ ''); installPhase = '' From ad0537ab1f03d32783feb7d6f2d5906e12efa9fa Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Mon, 10 Oct 2022 11:11:46 +0200 Subject: [PATCH 3/4] cbqn: pass adjusted linker flags for darwin --- pkgs/development/interpreters/bqn/cbqn/default.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/development/interpreters/bqn/cbqn/default.nix b/pkgs/development/interpreters/bqn/cbqn/default.nix index fc426bb374bb..f45dda4088fa 100644 --- a/pkgs/development/interpreters/bqn/cbqn/default.nix +++ b/pkgs/development/interpreters/bqn/cbqn/default.nix @@ -50,7 +50,12 @@ stdenv.mkDerivation rec { ${bqn-path} genRuntime ${mbqn-source} '' else '' cp ${cbqn-bytecode-files}/src/gen/{compiles,explain,formatter,runtime0,runtime1,src} src/gen/ - ''); + '') + # Need to adjust ld flags for darwin manually + # https://github.com/dzaima/CBQN/issues/26 + + lib.optionalString stdenv.hostPlatform.isDarwin '' + makeFlagsArray+=(LD_LIBS="-ldl -lffi") + ''; installPhase = '' runHook preInstall From 0e5f7501b613b09e2f22db4a1609470fa5bdab81 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Mon, 10 Oct 2022 10:59:40 +0200 Subject: [PATCH 4/4] 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"; };