summary refs log tree commit diff
diff options
context:
space:
mode:
authorWeijia Wang <9713184+wegank@users.noreply.github.com>2023-11-04 17:14:36 +0100
committerGitHub <noreply@github.com>2023-11-04 17:14:36 +0100
commit023d20ae6442f9f0a4550eea12e4134a2198bb91 (patch)
tree7cf56fb35ad52c4bdd3cf8e886ad3c8cc884fad1
parent7d2381f73b5ac1a5fda3d78c0b080e5054571cdf (diff)
parent2c4e2d81b0a81930dc5de98b06cf69e0b1803740 (diff)
downloadnixpkgs-023d20ae6442f9f0a4550eea12e4134a2198bb91.tar
nixpkgs-023d20ae6442f9f0a4550eea12e4134a2198bb91.tar.gz
nixpkgs-023d20ae6442f9f0a4550eea12e4134a2198bb91.tar.bz2
nixpkgs-023d20ae6442f9f0a4550eea12e4134a2198bb91.tar.lz
nixpkgs-023d20ae6442f9f0a4550eea12e4134a2198bb91.tar.xz
nixpkgs-023d20ae6442f9f0a4550eea12e4134a2198bb91.tar.zst
nixpkgs-023d20ae6442f9f0a4550eea12e4134a2198bb91.zip
Merge pull request #265307 from reckenrode/clang16-fixes-batch2
rubyPackages.iconv, v8: fix build with clang 16
-rw-r--r--pkgs/development/ruby-modules/gem-config/default.nix5
-rw-r--r--pkgs/development/ruby-modules/gem-config/iconv-fix-incompatible-function-pointer-conversions.patch51
-rw-r--r--pkgs/stdenv/adapters.nix44
-rw-r--r--pkgs/top-level/all-packages.nix11
4 files changed, 110 insertions, 1 deletions
diff --git a/pkgs/development/ruby-modules/gem-config/default.nix b/pkgs/development/ruby-modules/gem-config/default.nix
index 1704df297a6..317ed53828a 100644
--- a/pkgs/development/ruby-modules/gem-config/default.nix
+++ b/pkgs/development/ruby-modules/gem-config/default.nix
@@ -369,7 +369,12 @@ in
   };
 
   iconv = attrs: {
+    dontBuild = false;
     buildFlags = lib.optional stdenv.isDarwin "--with-iconv-dir=${libiconv}";
+    patches = [
+      # Fix incompatible function pointer conversion errors with clang 16
+      ./iconv-fix-incompatible-function-pointer-conversions.patch
+    ];
   };
 
   idn-ruby = attrs: {
diff --git a/pkgs/development/ruby-modules/gem-config/iconv-fix-incompatible-function-pointer-conversions.patch b/pkgs/development/ruby-modules/gem-config/iconv-fix-incompatible-function-pointer-conversions.patch
new file mode 100644
index 00000000000..1cc38cbae13
--- /dev/null
+++ b/pkgs/development/ruby-modules/gem-config/iconv-fix-incompatible-function-pointer-conversions.patch
@@ -0,0 +1,51 @@
+diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
+index 2801049..77fae7e 100644
+--- a/ext/iconv/iconv.c
++++ b/ext/iconv/iconv.c
+@@ -188,7 +188,7 @@ static VALUE iconv_convert _((iconv_t cd, VALUE str, long start, long length, in
+ static VALUE iconv_s_allocate _((VALUE klass));
+ static VALUE iconv_initialize _((int argc, VALUE *argv, VALUE self));
+ static VALUE iconv_s_open _((int argc, VALUE *argv, VALUE self));
+-static VALUE iconv_s_convert _((struct iconv_env_t* env));
++static VALUE iconv_s_convert _((VALUE env));
+ static VALUE iconv_s_iconv _((int argc, VALUE *argv, VALUE self));
+ static VALUE iconv_init_state _((VALUE cd));
+ static VALUE iconv_finish _((VALUE self));
+@@ -204,7 +204,7 @@ static VALUE charset_map;
+  * Returns the map from canonical name to system dependent name.
+  */
+ static VALUE
+-charset_map_get(void)
++charset_map_get(VALUE klass)
+ {
+     return charset_map;
+ }
+@@ -642,7 +642,7 @@ iconv_s_allocate(VALUE klass)
+ }
+ 
+ static VALUE
+-get_iconv_opt_i(VALUE i, VALUE arg)
++get_iconv_opt_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg))
+ {
+     VALUE name;
+ #if defined ICONV_SET_TRANSLITERATE || defined ICONV_SET_DISCARD_ILSEQ
+@@ -784,8 +784,9 @@ iconv_s_open(int argc, VALUE *argv, VALUE self)
+ }
+ 
+ static VALUE
+-iconv_s_convert(struct iconv_env_t* env)
++iconv_s_convert(VALUE env_value)
+ {
++    struct iconv_env_t* env = (struct iconv_env_t*)env_value;
+     VALUE last = 0;
+ 
+     for (; env->argc > 0; --env->argc, ++env->argv) {
+@@ -906,7 +907,7 @@ list_iconv(unsigned int namescount, const char *const *names, void *data)
+ 
+ #if defined(HAVE_ICONVLIST) || defined(HAVE___ICONV_FREE_LIST)
+ static VALUE
+-iconv_s_list(void)
++iconv_s_list(VALUE klass)
+ {
+ #ifdef HAVE_ICONVLIST
+     int state;
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix
index a6a2736fec1..dd298719071 100644
--- a/pkgs/stdenv/adapters.nix
+++ b/pkgs/stdenv/adapters.nix
@@ -42,6 +42,50 @@ rec {
     stdenv.override (prev: { allowedRequisites = null; extraBuildInputs = (prev.extraBuildInputs or []) ++ pkgs; });
 
 
+  # Override the libc++ dynamic library used in the stdenv to use the one from the platform’s
+  # default stdenv. This allows building packages and linking dependencies with different
+  # compiler versions while still using the same libc++ implementation for compatibility.
+  #
+  # Note that this adapter still uses the headers from the new stdenv’s libc++. This is necessary
+  # because older compilers may not be able to parse the headers from the default stdenv’s libc++.
+  overrideLibcxx = stdenv:
+    assert stdenv.cc.libcxx != null;
+    let
+      llvmLibcxxVersion = lib.getVersion llvmLibcxx;
+      stdenvLibcxxVersion = lib.getVersion stdenvLibcxx;
+
+      stdenvLibcxx = pkgs.stdenv.cc.libcxx;
+      stdenvCxxabi = pkgs.stdenv.cc.libcxx.cxxabi;
+
+      llvmLibcxx = stdenv.cc.libcxx;
+      llvmCxxabi = stdenv.cc.libcxx.cxxabi;
+
+      libcxx = pkgs.runCommand "${stdenvLibcxx.name}-${llvmLibcxxVersion}" {
+        outputs = [ "out" "dev" ];
+        inherit cxxabi;
+        isLLVM = true;
+      } ''
+        mkdir -p "$dev/nix-support"
+        ln -s '${stdenvLibcxx}' "$out"
+        echo '${stdenvLibcxx}' > "$dev/nix-support/propagated-build-inputs"
+        ln -s '${lib.getDev llvmLibcxx}/include' "$dev/include"
+      '';
+
+      cxxabi = pkgs.runCommand "${stdenvCxxabi.name}-${llvmLibcxxVersion}" {
+        outputs = [ "out" "dev" ];
+        inherit (stdenvCxxabi) libName;
+      } ''
+        mkdir -p "$dev/nix-support"
+        ln -s '${stdenvCxxabi}' "$out"
+        echo '${stdenvCxxabi}' > "$dev/nix-support/propagated-build-inputs"
+        ln -s '${lib.getDev llvmCxxabi}/include' "$dev/include"
+      '';
+    in
+    overrideCC stdenv (stdenv.cc.override {
+      inherit libcxx;
+      extraPackages = [ cxxabi pkgs.pkgsTargetTarget."llvmPackages_${lib.versions.major llvmLibcxxVersion}".compiler-rt ];
+    });
+
   # Override the setup script of stdenv.  Useful for testing new
   # versions of the setup script without causing a rebuild of
   # everything.
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 676143844fc..d617407db47 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -25481,7 +25481,16 @@ with pkgs;
 
   ucommon = callPackage ../development/libraries/ucommon { };
 
-  v8 = darwin.apple_sdk_11_0.callPackage ../development/libraries/v8 { };
+  v8 = callPackage ../development/libraries/v8 (
+    let
+      stdenv' = if stdenv.cc.isClang && lib.versionAtLeast (lib.getVersion stdenv.cc.cc) "16"
+        then overrideLibcxx llvmPackages_15.stdenv
+        else stdenv;
+    in
+    {
+      stdenv = if stdenv'.isDarwin then overrideSDK stdenv' "11.0" else stdenv';
+    }
+  );
 
   intel-vaapi-driver = callPackage ../development/libraries/intel-vaapi-driver { };