summary refs log tree commit diff
diff options
context:
space:
mode:
authorRandy Eckenrode <randy@largeandhighquality.com>2023-07-12 08:31:30 -0600
committerRandy Eckenrode <randy@largeandhighquality.com>2023-07-14 18:10:13 -0600
commitd02150a7831d091cce0605b8532f1c4911bd9ae9 (patch)
treec1aeff8d427c9e5579a75b2975c6e05a492de7a2
parent97e406059790c6ff80b973e02c5816d1db6aca23 (diff)
downloadnixpkgs-d02150a7831d091cce0605b8532f1c4911bd9ae9.tar
nixpkgs-d02150a7831d091cce0605b8532f1c4911bd9ae9.tar.gz
nixpkgs-d02150a7831d091cce0605b8532f1c4911bd9ae9.tar.bz2
nixpkgs-d02150a7831d091cce0605b8532f1c4911bd9ae9.tar.lz
nixpkgs-d02150a7831d091cce0605b8532f1c4911bd9ae9.tar.xz
nixpkgs-d02150a7831d091cce0605b8532f1c4911bd9ae9.tar.zst
nixpkgs-d02150a7831d091cce0605b8532f1c4911bd9ae9.zip
libredirect: fix build with clang 16
* Preferentially use the stdenv clang if it is new enough to produce
  arm64e binaries; and
* Fix incompatible function pointer conversions (results in an error
  with clang 16).
-rw-r--r--pkgs/build-support/libredirect/default.nix19
-rw-r--r--pkgs/build-support/libredirect/libredirect.c4
2 files changed, 15 insertions, 8 deletions
diff --git a/pkgs/build-support/libredirect/default.nix b/pkgs/build-support/libredirect/default.nix
index 6e2de7fa11b..1ab4a0db827 100644
--- a/pkgs/build-support/libredirect/default.nix
+++ b/pkgs/build-support/libredirect/default.nix
@@ -1,5 +1,12 @@
-{ lib, stdenv, bintools-unwrapped, llvmPackages_13, coreutils }:
-
+{ lib, stdenv, bintools-unwrapped, llvmPackages, llvmPackages_13, coreutils }:
+
+let
+  # aarch64-darwin needs a clang that can build arm64e binaries, so make sure a version of LLVM
+  # is used that can do that, but prefer the stdenv one if it is new enough.
+  llvmPkgs = if (lib.versionAtLeast (lib.getVersion llvmPackages.clang) "13")
+    then llvmPackages
+    else llvmPackages_13;
+  in
 if stdenv.hostPlatform.isStatic
 then throw ''
   libredirect is not available on static builds.
@@ -39,11 +46,11 @@ else stdenv.mkDerivation rec {
     # and the library search directory for libdl.
     # We can't build this on x86_64, because the libSystem we point to doesn't
     # like arm64(e).
-    PATH=${bintools-unwrapped}/bin:${llvmPackages_13.clang-unwrapped}/bin:$PATH \
+    PATH=${bintools-unwrapped}/bin:${llvmPkgs.clang-unwrapped}/bin:$PATH \
       clang -arch x86_64 -arch arm64 -arch arm64e \
-      -isystem ${llvmPackages_13.clang.libc}/include \
-      -isystem ${llvmPackages_13.libclang.lib}/lib/clang/*/include \
-      -L${llvmPackages_13.clang.libc}/lib \
+      -isystem ${llvmPkgs.clang.libc}/include \
+      -isystem ${llvmPkgs.libclang.lib}/lib/clang/*/include \
+      -L${llvmPkgs.clang.libc}/lib \
       -Wl,-install_name,$libName \
       -Wall -std=c99 -O3 -fPIC libredirect.c \
       -shared -o "$libName"
diff --git a/pkgs/build-support/libredirect/libredirect.c b/pkgs/build-support/libredirect/libredirect.c
index 9ecc16450cc..19211a813eb 100644
--- a/pkgs/build-support/libredirect/libredirect.c
+++ b/pkgs/build-support/libredirect/libredirect.c
@@ -106,7 +106,7 @@ static int open_needs_mode(int flags)
 
 WRAPPER(int, open)(const char * path, int flags, ...)
 {
-    int (*open_real) (const char *, int, mode_t) = LOOKUP_REAL(open);
+    int (*open_real) (const char *, int, ...) = LOOKUP_REAL(open);
     mode_t mode = 0;
     if (open_needs_mode(flags)) {
         va_list ap;
@@ -139,7 +139,7 @@ WRAPPER_DEF(open64)
 
 WRAPPER(int, openat)(int dirfd, const char * path, int flags, ...)
 {
-    int (*openat_real) (int, const char *, int, mode_t) = LOOKUP_REAL(openat);
+    int (*openat_real) (int, const char *, int, ...) = LOOKUP_REAL(openat);
     mode_t mode = 0;
     if (open_needs_mode(flags)) {
         va_list ap;