Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libredirect: fix build with clang 16 #243558

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions pkgs/build-support/libredirect/default.nix
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions pkgs/build-support/libredirect/libredirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, I expect someone was looking at Linux docs instead of POSIX. I'm prone to doing that mistake, too.

mode_t mode = 0;
if (open_needs_mode(flags)) {
va_list ap;
Expand Down