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 failing to build with clang 16 #259156

Open
Tracked by #234710
viraptor opened this issue Oct 5, 2023 · 11 comments
Open
Tracked by #234710

libredirect failing to build with clang 16 #259156

viraptor opened this issue Oct 5, 2023 · 11 comments

Comments

@viraptor
Copy link
Contributor

viraptor commented Oct 5, 2023

Steps To Reproduce

Steps to reproduce the behavior:
Build libredirect from reckenrode/nixpkgs/9ed7bfe46bf193e55a6fd8ae89dfe54b4dca2c18 (clang 16

Build log

...
nix/store/ymn78m6a3sgc8sja9j221s8ifaxzmymg-clang-16.0.6-lib/lib/clang/16/include/stdarg.h:36:50: note: expanded from macro 'va_arg'
#define va_arg(ap, type)    __builtin_va_arg(ap, type)
                                                 ^~~~
2 warnings generated.
ld: warning: object file /private/tmp/nix-build-libredirect-0.drv-0/libredirect-17ba7a/libredirect-arm64e.o was built with an incompatible arm64e ABI compiler
@nix { "action": "setPhase", "phase": "installPhase" }
installing
install: creating directory '/nix/store/lvshf2cdsip1bpcc9m702ysl9z5v8qpw-libredirect-0'
install: creating directory '/nix/store/lvshf2cdsip1bpcc9m702ysl9z5v8qpw-libredirect-0/lib'
'libredirect.dylib' -> '/nix/store/lvshf2cdsip1bpcc9m702ysl9z5v8qpw-libredirect-0/lib/libredirect.dylib'
@nix { "action": "setPhase", "phase": "fixupPhase" }
post-installation fixup
checking for references to /private/tmp/nix-build-libredirect-0.drv-0/ in /nix/store/lvshf2cdsip1bpcc9m702ysl9z5v8qpw-libredirect-0...
patching script interpreter paths in /nix/store/lvshf2cdsip1bpcc9m702ysl9z5v8qpw-libredirect-0
checking for references to /private/tmp/nix-build-libredirect-0.drv-0/ in /nix/store/x57vg821mgz9p6nmbppgyigqr1vqm4da-libredirect-0-hook...
patching script interpreter paths in /nix/store/x57vg821mgz9p6nmbppgyigqr1vqm4da-libredirect-0-hook
@nix { "action": "setPhase", "phase": "installCheckPhase" }
running install tests
dyld[56565]: terminating because inserted dylib '/nix/store/lvshf2cdsip1bpcc9m702ysl9z5v8qpw-libredirect-0/lib/libredirect.dylib' could not be loaded: tried: '/nix/store/lvshf2cdsip1bpcc9m702ysl9z5v8qpw-libredirect-0/lib/libredirect.dylib' (fat file, but missing compatible architecture (have 'x86_64,arm64,arm64e', need '')), '/System/Volumes/Preboot/Cryptexes/OS/nix/store/lvshf2cdsip1bpcc9m702ysl9z5v8qpw-libredirect-0/lib/libredirect.dylib' (no such file), '/nix/store/lvshf2cdsip1bpcc9m702ysl9z5v8qpw-libredirect-0/lib/libredirect.dylib' (fat file, but missing compatible architecture (have 'x86_64,arm64,arm64e', need ''))
dyld[56565]: tried: '/nix/store/lvshf2cdsip1bpcc9m702ysl9z5v8qpw-libredirect-0/lib/libredirect.dylib' (fat file, but missing compatible architecture (have 'x86_64,arm64,arm64e', need '')), '/System/Volumes/Preboot/Cryptexes/OS/nix/store/lvshf2cdsip1bpcc9m702ysl9z5v8qpw-libredirect-0/lib/libredirect.dylib' (no such file), '/nix/store/lvshf2cdsip1bpcc9m702ysl9z5v8qpw-libredirect-0/lib/libredirect.dylib' (fat file, but missing compatible architecture (have 'x86_64,arm64,arm64e', need ''))
Assertion failed: (system(TESTPATH) == 0), function test_system, file test.c, line 41.
/nix/store/5pppil6mnwrnvpfhsqlwabw1plw2kx7l-stdenv-darwin/setup: line 1608: 56562 Abort trap: 6           ( source "$hook/nix-support/setup-hook"; NIX_REDIRECTS="/foo/bar/test=/nix/store/h04p46axj6gkc6x31fd2fzayj4bv9ngx-coreutils-9.3/bin/true:/bar/baz=$(mktemp -d)" ./test )

Additional context

SIP disabled (I believe there were some SIP specific issues in #243558)

Notify maintainers

@reckenrode

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"aarch64-darwin"`
 - host os: `Darwin 22.5.0, macOS 13.4.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.13.3`
 - channels(viraptor): `"home-manager-22.11.tar.gz, nixpkgs-22.11"`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/Users/viraptor/.nix-defexpr/channels/nixpkgs`
@viraptor viraptor changed the title Build failure: PACKAGENAME libredirect failing to build with clang 16 Oct 5, 2023
@viraptor
Copy link
Contributor Author

viraptor commented Oct 5, 2023

One for the list in #234710

@viraptor
Copy link
Contributor Author

viraptor commented Oct 5, 2023

$ otool -f /nix/store/lvshf2cdsip1bpcc9m702ysl9z5v8qpw-libredirect-0/lib/libredirect.dylib
Fat headers
fat_magic 0xcafebabe
nfat_arch 3
architecture 0
    cputype 16777223
    cpusubtype 3
    capabilities 0x0
    offset 4096
    size 23104
    align 2^12 (4096)
architecture 1
    cputype 16777228
    cpusubtype 0
    capabilities 0x0
    offset 32768
    size 55936
    align 2^14 (16384)
architecture 2
    cputype 16777228
    cpusubtype 2
    capabilities 0x0
    offset 98304
    size 55440
    align 2^14 (16384)

@reckenrode
Copy link
Contributor

reckenrode commented Oct 5, 2023

According to the comments in #243558, the SIP issue existed prior to that change. Do you see the error if you build with SIP disabled without a clang 16 stdenv? In that case, it should be using clang 13.

I disabled SIP and dug into the issue. From what I can tell, DYLD_INSERT_LIBRARIES is really brittle. It only “works”1 for if the architectures in test matches those in libredirect.dylib. Either I also build test as a fat binary, or I build libredirect as arm64.


1 Meaning that the dyld error is gone. The install check phase still fails but in a different place.

Assertion failed: (testfp != NULL), function main, file test.c, line 86.
Abort trap: 6

@viraptor
Copy link
Contributor Author

viraptor commented Oct 5, 2023

Dropping down to v13 makes the libredirect work again. (SIP still disabled) Tested with viraptor@cb6a824

@reckenrode
Copy link
Contributor

Dropping down to v13 makes the libredirect work again. (SIP still disabled) Tested with viraptor@cb6a824

That would suggest it is indeed a regression. 😞

I’m building it with both clang 13 and clang 16, so I can compare the generated binaries for differences.

@reckenrode
Copy link
Contributor

I tried building the architectures individually then combining the dylibs with lipo. Even the standalone arm64 one doesn’t work.

@viraptor
Copy link
Contributor Author

viraptor commented Oct 7, 2023

Ok, I'm glad. I tried that too, it failed, and I assumed I did something stupid in another place so didn't report it at the time. 😂

@reckenrode
Copy link
Contributor

It was strange. If I used the arm64e one, the error was that it was missing a dylib for arm64. If I used the arm64 one, the error was that it was missing one for ''.

@reckenrode
Copy link
Contributor

reckenrode commented Oct 7, 2023

I tried building it with clang 14, which also fails. Why does only clang 13 work?

Edit: Actually, clang 13 is also failing for me.

@reckenrode
Copy link
Contributor

I added this to the tracking list in its own section. It’s not ideal, but users with SIP disabled should be able to get this from the cache once the stdenv update is merged.

@viraptor
Copy link
Contributor Author

Confirming - something happened after my initial test and I can't build it with clang 13 anymore either. (almost-latest staging)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants