Skip to content

libredirect fails to build on aarch64-darwin #152667

@angerman

Description

@angerman

With nixpkgs at 64c7e33 (tip of nixpkgs-21.11-darwin; though the same happens for master and nixos-21.11).

$ NIX_PATH=nixpkgs=$PWD/nixpkgs nix-build nixpkgs -A libredirect --check --argstr system aarch64-darwin
checking outputs of '/nix/store/n2jajggzh9rm02dkxdh2s65x5xsdycgn-libredirect-0.drv'...
unpacking sources
patching sources
updateAutotoolsGnuConfigScriptsPhase
configuring
no configure script, doing nothing
building
libredirect.c:102:11: warning: incompatible function pointer types initializing 'int (*)(const char *, int, mode_t)' (aka 'int (*)(const char *, int, unsigned short)') with an expression of type 'int (*)(const char *, int, ...)' [-Wincompatible-function-pointer-types]
    int (*open_real) (const char *, int, mode_t) = LOOKUP_REAL(open);
          ^                                        ~~~~~~~~~~~~~~~~~
libredirect.c:107:27: warning: second argument to 'va_arg' is of promotable type 'mode_t' (aka 'unsigned short'); this va_arg has undefined behavior because arguments will be promoted to 'int' [-Wvarargs]
        mode = va_arg(ap, mode_t);
                          ^~~~~~
/nix/store/7sfdssd4p5c6gh5dr2j1fy06fxky195q-clang-wrapper-11.1.0/resource-root/include/stdarg.h:19:50: note: expanded from macro 'va_arg'
#define va_arg(ap, type)    __builtin_va_arg(ap, type)
                                                 ^~~~
libredirect.c:134:11: warning: incompatible function pointer types initializing 'int (*)(int, const char *, int, mode_t)' (aka 'int (*)(int, const char *, int, unsigned short)') with an expression of type 'int (*)(int, const char *, int, ...)' [-Wincompatible-function-pointer-types]
    int (*openat_real) (int, const char *, int, mode_t) = LOOKUP_REAL(openat);
          ^                                               ~~~~~~~~~~~~~~~~~~~
libredirect.c:139:27: warning: second argument to 'va_arg' is of promotable type 'mode_t' (aka 'unsigned short'); this va_arg has undefined behavior because arguments will be promoted to 'int' [-Wvarargs]
        mode = va_arg(ap, mode_t);
                          ^~~~~~
/nix/store/7sfdssd4p5c6gh5dr2j1fy06fxky195q-clang-wrapper-11.1.0/resource-root/include/stdarg.h:19:50: note: expanded from macro 'va_arg'
#define va_arg(ap, type)    __builtin_va_arg(ap, type)
                                                 ^~~~
4 warnings generated.
installing
install: creating directory '/nix/store/1v371qinn0fivjc595yazzxbdb13k4ac-libredirect-0'
install: creating directory '/nix/store/1v371qinn0fivjc595yazzxbdb13k4ac-libredirect-0/lib'
'libredirect.dylib' -> '/nix/store/1v371qinn0fivjc595yazzxbdb13k4ac-libredirect-0/lib/libredirect.dylib'
post-installation fixup
patching script interpreter paths in /nix/store/1v371qinn0fivjc595yazzxbdb13k4ac-libredirect-0
patching script interpreter paths in /nix/store/cbzgblyik90wag4arznwrw5sx62xfqsa-libredirect-0-hook
running install tests
dyld: could not load inserted library '/nix/store/1v371qinn0fivjc595yazzxbdb13k4ac-libredirect-0/lib/libredirect.dylib' because no suitable image found.  Did find:
        /nix/store/1v371qinn0fivjc595yazzxbdb13k4ac-libredirect-0/lib/libredirect.dylib: mach-o, but wrong architecture
        /nix/store/1v371qinn0fivjc595yazzxbdb13k4ac-libredirect-0/lib/libredirect.dylib: stat() failed with errno=1

Assertion failed: (system(TESTPATH) == 0), function test_system, file test.c, line 37.
/nix/store/i97a6fwzdp2n2mb9crzhnvdb7r15arqi-stdenv-darwin/setup: line 1355:  3156 Abort trap: 6           NIX_REDIRECTS="/foo/bar/test=/nix/store/dwhdayp98xmpp9vzzb1qp4va1pjy65gz-coreutils-9.0/bin/true" ./test
builder for '/nix/store/n2jajggzh9rm02dkxdh2s65x5xsdycgn-libredirect-0.drv' failed with exit code 134
error: build of '/nix/store/n2jajggzh9rm02dkxdh2s65x5xsdycgn-libredirect-0.drv' failed

Now we could argue, alright you are building with an x86_64 nix executable, that might not work. So let's build a native nix for aarch64-darwin

NIX_PATH=nixpkgs=$PWD/nixpkgs nix-build nixpkgs -A nix --argstr system aarch64-darwin
these paths will be fetched (1.26 MiB download, 6.29 MiB unpacked):
  /nix/store/1hkdg2083q0w5y8n6j0nbr5ghpyi8ixl-boehm-gc-8.0.6
  /nix/store/1s9bhccsyicfil6am1wrmdwfg4akv9fg-nix-2.3.16
  /nix/store/fl7qafl1xwf006sir3ya4q05jkn2fkd7-nix-2.3.16-man
copying path '/nix/store/fl7qafl1xwf006sir3ya4q05jkn2fkd7-nix-2.3.16-man' from 'https://cache.nixos.org'...
copying path '/nix/store/1hkdg2083q0w5y8n6j0nbr5ghpyi8ixl-boehm-gc-8.0.6' from 'https://cache.nixos.org'...
copying path '/nix/store/1s9bhccsyicfil6am1wrmdwfg4akv9fg-nix-2.3.16' from 'https://cache.nixos.org'...
/nix/store/1s9bhccsyicfil6am1wrmdwfg4akv9fg-nix-2.3.16

This looks good:

/nix/store/1s9bhccsyicfil6am1wrmdwfg4akv9fg-nix-2.3.16/bin/nix-build: Mach-O 64-bit executable arm64

But that fails as well :-/

$ PATH=/nix/store/1s9bhccsyicfil6am1wrmdwfg4akv9fg-nix-2.3.16/bin:$PATH NIX_PATH=nixpkgs=$PWD/nixpkgs nix-build nixpkgs -A libredirect --check                                                                                          ~
checking outputs of '/nix/store/n2jajggzh9rm02dkxdh2s65x5xsdycgn-libredirect-0.drv'...
unpacking sources
patching sources
updateAutotoolsGnuConfigScriptsPhase
configuring
no configure script, doing nothing
building
libredirect.c:102:11: warning: incompatible function pointer types initializing 'int (*)(const char *, int, mode_t)' (aka 'int (*)(const char *, int, unsigned short)') with an expression of type 'int (*)(const char *, int, ...)' [-Wincompatible-function-pointer-types]
    int (*open_real) (const char *, int, mode_t) = LOOKUP_REAL(open);
          ^                                        ~~~~~~~~~~~~~~~~~
libredirect.c:107:27: warning: second argument to 'va_arg' is of promotable type 'mode_t' (aka 'unsigned short'); this va_arg has undefined behavior because arguments will be promoted to 'int' [-Wvarargs]
        mode = va_arg(ap, mode_t);
                          ^~~~~~
/nix/store/7sfdssd4p5c6gh5dr2j1fy06fxky195q-clang-wrapper-11.1.0/resource-root/include/stdarg.h:19:50: note: expanded from macro 'va_arg'
#define va_arg(ap, type)    __builtin_va_arg(ap, type)
                                                 ^~~~
libredirect.c:134:11: warning: incompatible function pointer types initializing 'int (*)(int, const char *, int, mode_t)' (aka 'int (*)(int, const char *, int, unsigned short)') with an expression of type 'int (*)(int, const char *, int, ...)' [-Wincompatible-function-pointer-types]
    int (*openat_real) (int, const char *, int, mode_t) = LOOKUP_REAL(openat);
          ^                                               ~~~~~~~~~~~~~~~~~~~
libredirect.c:139:27: warning: second argument to 'va_arg' is of promotable type 'mode_t' (aka 'unsigned short'); this va_arg has undefined behavior because arguments will be promoted to 'int' [-Wvarargs]
        mode = va_arg(ap, mode_t);
                          ^~~~~~
/nix/store/7sfdssd4p5c6gh5dr2j1fy06fxky195q-clang-wrapper-11.1.0/resource-root/include/stdarg.h:19:50: note: expanded from macro 'va_arg'
#define va_arg(ap, type)    __builtin_va_arg(ap, type)
                                                 ^~~~
4 warnings generated.
installing
install: creating directory '/nix/store/1v371qinn0fivjc595yazzxbdb13k4ac-libredirect-0'
install: creating directory '/nix/store/1v371qinn0fivjc595yazzxbdb13k4ac-libredirect-0/lib'
'libredirect.dylib' -> '/nix/store/1v371qinn0fivjc595yazzxbdb13k4ac-libredirect-0/lib/libredirect.dylib'
post-installation fixup
patching script interpreter paths in /nix/store/1v371qinn0fivjc595yazzxbdb13k4ac-libredirect-0
patching script interpreter paths in /nix/store/cbzgblyik90wag4arznwrw5sx62xfqsa-libredirect-0-hook
running install tests
dyld: could not load inserted library '/nix/store/1v371qinn0fivjc595yazzxbdb13k4ac-libredirect-0/lib/libredirect.dylib' because no suitable image found.  Did find:
        /nix/store/1v371qinn0fivjc595yazzxbdb13k4ac-libredirect-0/lib/libredirect.dylib: mach-o, but wrong architecture
        /nix/store/1v371qinn0fivjc595yazzxbdb13k4ac-libredirect-0/lib/libredirect.dylib: stat() failed with errno=1

Assertion failed: (system(TESTPATH) == 0), function test_system, file test.c, line 37.
/nix/store/i97a6fwzdp2n2mb9crzhnvdb7r15arqi-stdenv-darwin/setup: line 1355:  3594 Abort trap: 6           NIX_REDIRECTS="/foo/bar/test=/nix/store/dwhdayp98xmpp9vzzb1qp4va1pjy65gz-coreutils-9.0/bin/true" ./test
builder for '/nix/store/n2jajggzh9rm02dkxdh2s65x5xsdycgn-libredirect-0.drv' failed with exit code 134
error: build of '/nix/store/n2jajggzh9rm02dkxdh2s65x5xsdycgn-libredirect-0.drv' failed

am I holding it wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken6.topic: darwinRunning or building packages on Darwin
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions