Skip to content

emacsMacport: get rid of stdenv override, fix aarch64-darwin build#138424

Closed
mikroskeem wants to merge 1 commit intoNixOS:masterfrom
mikroskeem:emacs-macport-m1
Closed

emacsMacport: get rid of stdenv override, fix aarch64-darwin build#138424
mikroskeem wants to merge 1 commit intoNixOS:masterfrom
mikroskeem:emacs-macport-m1

Conversation

@mikroskeem
Copy link
Member

@mikroskeem mikroskeem commented Sep 18, 2021

Motivation for this change
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.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.

@github-actions github-actions bot added the 6.topic: emacs Text editor label Sep 18, 2021
@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Sep 18, 2021
@ofborg ofborg bot requested review from jwiegley and matthewbauer September 18, 2021 14:25
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Sep 18, 2021
@mikroskeem
Copy link
Member Author

Tested with sandboxing natively, skipped sandbox on x86_64-darwin arch (via Rosetta) because it takes painfully long time to finish.

Note: to get Rosetta working under Nix with sandbox = true, you need to configure following:

{
  nix.sandboxPaths = [
    "/private/var/db/oah" # aot files
    "/Library/Apple"      # rosetta runtime
  ];
}

@mikroskeem
Copy link
Member Author

mikroskeem commented Sep 18, 2021

OK, seems like it's unstable on aarch64 suddenly. Investigating.

Process 11508 launched: '/nix/store/9kznfvwsww0gy6f6hyhnr2pm0d5jq437-emacs-mac-27.2-8.2/Applications/Emacs.app/Contents/MacOS/Emacs' (arm64)
2021-09-18 18:21:25.430863+0300 Emacs[11508:927600] +[MTLIOAccelDevice registerDevices]: Zero Metal services found
Process 11508 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000191fef254 libobjc.A.dylib`objc_msgSend + 52
libobjc.A.dylib`objc_msgSend:
->  0x191fef254 <+52>: ldp    x17, x9, [x13], #-0x10
    0x191fef258 <+56>: cmp    x9, x1
    0x191fef25c <+60>: b.ne   0x191fef26c               ; <+76>
    0x191fef260 <+64>: eor    x10, x10, x1
Target 0: (Emacs) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x0000000191fef254 libobjc.A.dylib`objc_msgSend + 52
    frame #1: 0x000000019201280c libobjc.A.dylib`AutoreleasePoolPage::releaseUntil(objc_object**) + 204
    frame #2: 0x0000000191ff0e0c libobjc.A.dylib`objc_autoreleasePoolPop + 212
    frame #3: 0x000000010020d37c Emacs`mac_gui_loop + 92
    frame #4: 0x000000010020d2a8 Emacs`main + 1116
    frame #5: 0x0000000192175430 libdyld.dylib`start + 4
(lldb)

@mikroskeem mikroskeem marked this pull request as draft September 18, 2021 15:29
@mikroskeem mikroskeem marked this pull request as ready for review December 29, 2021 13:14
@mikroskeem
Copy link
Member Author

Got it working, apparently launching Emacs inside app bundle from terminal is a bad idea.

Comment on lines +41 to +43
] ++ lib.optionals stdenv.isAarch64 [
sigtool
];
Copy link
Member

Choose a reason for hiding this comment

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

Why only on aarch64?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's been a while, so I'm unable to give a proper answer. But something to do with ARM macOS requiring a code signature, while Intel macOS does not.

Copy link
Member Author

Choose a reason for hiding this comment

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

IIRC emacs build system does not invoke sigtool on x86_64-darwin at all, so I didn't find it necessary to declare it as a dependency for it. Doesn't hurt to remove conditional, I just go by declaring bare minimum required to build & run the thing successfully.

@Atemu
Copy link
Member

Atemu commented Mar 1, 2022

FYI: #155360. I'm trying to integrate your patch and got it working but both patches still crash on startup.

It's inconsistent, so perhaps, just by chance, the time you ran it via open worked.

@Atemu
Copy link
Member

Atemu commented Mar 1, 2022

I wonder why our emacsMacport crashes but @railwaycat's build doesn't.

Fatal error 11: Segmentation fault
Backtrace:
0   Emacs                               0x0000000102389c24 deliver_thread_signal + 60
1   Emacs                               0x00000001023885d0 seed_random + 0
2   Emacs                               0x0000000102389ca0 handle_sigsegv + 64
3   libsystem_platform.dylib            0x000000018c6704e4 _sigtramp + 56
4   ???                                 0xffff80018c4e4664 0x0 + 18446603342870103652
5   libobjc.A.dylib                     0x000000018c4e4664 _objc_msgSend_uncached + 68
6   libobjc.A.dylib                     0x000000018c508f70 _ZN11objc_object17sidetable_releaseEbb + 228
7   libobjc.A.dylib                     0x000000018c4eb38c _ZN19AutoreleasePoolPage12releaseUntilEPP11objc_object + 200
8   libobjc.A.dylib                     0x000000018c4e7d68 objc_autoreleasePoolPop + 208
9   Emacs                               0x00000001024b90b4 mac_gui_loop + 92
10  Emacs                               0x00000001024b8fe0 main + 1116
11  dyld                                0x0000000102cf90f4 start + 520
Segmentation fault: 11

@mikroskeem
Copy link
Member Author

I don't need this PR anymore, someone else feel free to pick this up.

@mikroskeem mikroskeem closed this Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: darwin Running or building packages on Darwin 6.topic: emacs Text editor 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants