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

yabai: refactor new sdk pattern; cleanup; switch to apple-sdk_15; build from source #352621

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

khaneliman
Copy link
Contributor

@khaneliman khaneliman commented Oct 31, 2024

Things done

Using the new sdk pattern and cleaning up derivation. Also changing yabai on arm to build from source, finally, by using the llvm 19 stdenv.

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@khaneliman khaneliman changed the title yabai: switch to apple-sdk_11 yabai: refactor new sdk pattern; cleanup; switch to apple-sdk_15 Oct 31, 2024
Upstream uses __builtin._available checks for sdk features. We can
leverage the newer sdk to make sure we keep up with new features as they
are added since they are careful with version checks.
@khaneliman khaneliman changed the title yabai: refactor new sdk pattern; cleanup; switch to apple-sdk_15 yabai: refactor new sdk pattern; cleanup; switch to apple-sdk_15; build from source Oct 31, 2024
@khaneliman khaneliman marked this pull request as draft October 31, 2024 18:47
@khaneliman
Copy link
Contributor Author

khaneliman commented Oct 31, 2024

Had a hash merge conflict hiding a build issue from source I need to find out. It looks like it's trying to do 2 builds at once and second xxd fails.

@khaneliman
Copy link
Contributor Author

Arm64 builds, just need to see if x86 builds with llvm 19.

@khaneliman khaneliman marked this pull request as ready for review October 31, 2024 22:42
# aarch64 code is compiled on all targets, which causes our Apple SDK headers to error out.
# Since multilib doesn't work on darwin i dont know of a better way of handling this.
substituteInPlace makefile \
--replace-fail "-arch arm64e" "" \
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure about this one? Since ptrauth.h is used I imagine it might be necessary for AArch64.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

 > ld: warning: ignoring file /private/tmp/nix-build-yabai-7.1.4.drv-0/payload-8bb724/payload-arm64e.o, building for macOS-arm64 but attempting to link with file built for unknown-arm64e
       > ld: warning: ignoring file /private/tmp/nix-build-yabai-7.1.4.drv-0/payload-ce652e/payload-arm64e.o, building for macOS-arm64 but attempting to link with file built for unknown-arm64e
       > fatal error: /nix/store/wli7d4k9sh4c6fwarw3afc5g5axwbjm8-cctools-binutils-darwin-1010.6/bin/lipo: /private/tmp/nix-build-yabai-7.1.4.drv-0/payload-e8e57e/payload-arm64.out and /private/tmp/nix-build-yabai-7.1.4.drv-0/payload-56e39e/payload-arm64e.out have the same architectures (arm64) and can't be in the same fat output file
       > clang: error: lipo command failed with exit code 1 (use -v to see invocation)
       > fatal error: /nix/store/wli7d4k9sh4c6fwarw3afc5g5axwbjm8-cctools-binutils-darwin-1010.6/bin/lipo: /private/tmp/nix-build-yabai-7.1.4.drv-0/payload-515dcf/payload-arm64.out and /private/tmp/nix-build-yabai-7.1.4.drv-0/payload-cdef29/payload-arm64e.out have the same architectures (arm64) and can't be in the same fat output file
       > clang: error: lipo command failed with exit code 1 (use -v to see invocation)

Copy link
Contributor Author

@khaneliman khaneliman Oct 31, 2024

Choose a reason for hiding this comment

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

My replaces in there are just to remove arm64e/x86 and replace it with arm64 basically. Is there a better way of doing this now?

Copy link
Member

Choose a reason for hiding this comment

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

Urgh. I guess we might need proper arm64e toolchain support?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we only actually get pointer auth with arm64e and can't build this from source still?

Copy link
Contributor

Choose a reason for hiding this comment

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

The scripting addition on aarch64-darwin need arm64e, here is my try azuwis@2725afe, it builds arm64e code, but scripting addition crashes when run.

Copy link
Contributor

@azuwis azuwis Nov 1, 2024

Choose a reason for hiding this comment

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

Use macOS CommandLineTools to build:

$ file src/osax/loader
src/osax/loader: Mach-O 64-bit arm64e (caps: PAC00) executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>
$ file src/osax/payload
src/osax/payload: Mach-O 64-bit arm64e (caps: PAC00) dynamically linked shared library, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|NO_REEXPORTED_DYLIBS>
$ ./src/osax/loader 
could not retrieve task port for pid: 47162

Use nix unwrapped clang to build:

$ file ./src/osax/loader
./src/osax/loader: Mach-O 64-bit arm64e 00) executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>
$ file ./src/osax/payload
./src/osax/payload: Mach-O 64-bit arm64e 00) dynamically linked shared library, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|NO_REEXPORTED_DYLIBS>
$ ./src/osax/loader 
Segmentation fault: 11
$ lldb ./src/osax/loader 
(lldb) target create "./src/osax/loader"
Current executable set to '/tmp/yabai/source/src/osax/loader' (arm64e).
(lldb) run 
Process 52946 launched: '/tmp/yabai/source/src/osax/loader' (arm64e)
Process 52946 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x200001fe3d05c0)
    frame #0: 0x0000000196189020 libobjc.A.dylib`objc_msgSend + 32
libobjc.A.dylib`objc_msgSend:
->  0x196189020 <+32>: ldr    x10, [x16, #0x10]
    0x196189024 <+36>: lsr    x11, x10, #48
    0x196189028 <+40>: and    x10, x10, #0xffffffffffff
    0x19618902c <+44>: and    w12, w1, w11
Target 0: (loader) stopped.

pkgs/by-name/ya/yabai/package.nix Outdated Show resolved Hide resolved
@khaneliman
Copy link
Contributor Author

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 352621


x86_64-linux


aarch64-linux


x86_64-darwin

✅ 1 package built:
  • yabai

aarch64-darwin

✅ 1 package built:
  • yabai

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

Successfully merging this pull request may close these issues.

3 participants