From b034e4cbf12f7c0d749674c102e31e6a47fa2d7f Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Fri, 27 Oct 2023 16:38:20 -0400 Subject: [PATCH] nodejs_18: fix build with clang 16 mk2 Trying to backport the fixes from v8 caused crashes with npm when building other packages, so just build it with clang 15. --- pkgs/development/web/nodejs/v18.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkgs/development/web/nodejs/v18.nix b/pkgs/development/web/nodejs/v18.nix index 3c8abbb291880..b36e8e3d0f3a2 100644 --- a/pkgs/development/web/nodejs/v18.nix +++ b/pkgs/development/web/nodejs/v18.nix @@ -1,8 +1,20 @@ -{ callPackage, fetchpatch, openssl, python3, enableNpm ? true }: +{ callPackage, lib, overrideCC, pkgs, buildPackages, fetchpatch, openssl, python3, enableNpm ? true }: let + # Clang 16+ cannot build Node v18 due to -Wenum-constexpr-conversion errors. + # Use an older version of clang with the current libc++ for compatibility (e.g., with icu). + ensureCompatibleCC = packages: + if packages.stdenv.cc.isClang && lib.versionAtLeast (lib.getVersion packages.stdenv.cc.cc) "16" + then overrideCC packages.llvmPackages_15.stdenv (packages.llvmPackages_15.stdenv.cc.override { + inherit (packages.llvmPackages) libcxx; + extraPackages = [ packages.llvmPackages.libcxxabi ]; + }) + else packages.stdenv; + buildNodejs = callPackage ./nodejs.nix { inherit openssl; + stdenv = ensureCompatibleCC pkgs; + buildPackages = buildPackages // { stdenv = ensureCompatibleCC buildPackages; }; python = python3; }; in