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

emacs: fix for darwin's aarch64 codesigning issue #124888

Merged

Conversation

hlolli
Copy link
Member

@hlolli hlolli commented May 29, 2021

Motivation for this change

Excited to get started with aarch64 but Emacs doesn't compile
as well does #124571 not fix the issue I have for me.

Things done

Felt lucky to have bumped into this commit emacs-mirror/emacs@868f513 so the work has been done for us.

As well I remove the osx upper limit, I think it's fair to say that we are ok making assumtions about recency of aarch64 apple m1 computers. But please correct me if I'm wrong.

Screen:
built with nix-build -E 'with import <nixpkgs> { localSystem = "aarch64-darwin"; }; (import ./default.nix { localSystem = "aarch64-darwin"; }).emacs' -o result
2021-05-29 20 38 55

built with nix-build -E 'with import <nixpkgs> { localSystem = "x86_64-darwin"; }; (import ./default.nix { localSystem = "x86_64-darwin"; }).emacs' -o result
2021-05-29 20 54 43

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs 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/)
  • Added a release notes entry if the change is major or breaking
  • Fits CONTRIBUTING.md.

@hlolli hlolli requested a review from adisbladis as a code owner May 29, 2021 18:51
@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label May 29, 2021
@github-actions github-actions bot added the 6.topic: emacs Text editor label May 29, 2021
postPatch = lib.concatStringsSep "\n" [
(lib.optionalString srcRepo ''
rm -fr .git
'')

# Reduce closure size by cleaning the environment of the emacs dumper
''
(lib.optionalString ((stdenv.isDarwin && stdenv.isAarch64) == false) ''
Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is a red herring, I'm going to test if this works without this change...

Copy link
Member Author

Choose a reason for hiding this comment

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

not a red herring, needs to be there

Copy link
Member

@thefloweringash thefloweringash May 31, 2021

Choose a reason for hiding this comment

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

I don't see a failure if I remove this change. What error are you seeing?

Copy link
Member Author

Choose a reason for hiding this comment

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

double blunder, this really isn't needed, now removed.

@ofborg ofborg bot requested review from lovek323, peti and jwiegley May 29, 2021 19:01
@ofborg ofborg bot added 10.rebuild-darwin: 11-100 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels May 29, 2021
@hlolli hlolli changed the title emacs: add upstream patch for emacs fix of darwin's aarch64 codesigning issue emacs: emacs fix for darwin's aarch64 codesigning issue May 29, 2021
@hlolli hlolli changed the title emacs: emacs fix for darwin's aarch64 codesigning issue emacs: fix for darwin's aarch64 codesigning issue May 29, 2021
@ofborg ofborg bot added 10.rebuild-linux: 11-100 and removed 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels May 29, 2021
Copy link
Member

@purcell purcell left a comment

Choose a reason for hiding this comment

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

This looks good to me

Copy link
Member

@thefloweringash thefloweringash left a comment

Choose a reason for hiding this comment

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

Mostly seems reasonable, just a couple of comments.

@@ -46,10 +46,10 @@ assert withXwidgets -> withGTK3 && webkitgtk != null;
let emacs = stdenv.mkDerivation (lib.optionalAttrs nativeComp {
NATIVE_FULL_AOT = "1";
LIBRARY_PATH = "${lib.getLib stdenv.cc.libc}/lib";
} // lib.optionalAttrs stdenv.isDarwin {
} // lib.optionalAttrs (stdenv.isDarwin && !stdenv.isAarch64) {
Copy link
Member

Choose a reason for hiding this comment

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

This CFLAG was added in #41181, but I can't find the exact reason why this was added. It is it something we still need or can we drop it on all platforms? This controls the availability macros, and since we build against the SDK corresponding to our minimum version, this flag should have no effect.

If we keep it, it should probably follow the SDK version on all platforms, like in #124571.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, I build it with nix-build -E 'with import <nixpkgs> { localSystem = "x86_64-darwin"; }; (import ./default.nix { localSystem = "x86_64-darwin"; }).emacs' -o result and the binary (.App bundle) ran perfectly fine. Now removed for both platforms.


# Emacs checks for arm-apple-darwin, but our configuration is
# aarch64-apple-darwin. Force enable DO_CODESIGN.
preConfigure = lib.optionalString (stdenv.isDarwin && stdenv.isAarch64) ''
Copy link
Member

Choose a reason for hiding this comment

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

I looked at this in more detail, and it looks like emacs itself has been churning between arm and aarch64, but the most recent commit uses aarch64. If we backport this change as a patch then we know when to remove it (when it conflicts).

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, should we change the comment, or keep it like this?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm. Add a link to the upstream change for context. This sed is probably the easiest way to make the required change.

Copy link
Member

Choose a reason for hiding this comment

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

Add a link to the upstream change for context.

^ I think this suggestion is still open, @hlolli. 🙂

Looking forward to these changes getting merged.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for reminding me! I misunderstood as well. This part I copy pasted from the @thefloweringash's previous wip PR. Anyway, late for me here, tomorrow!

Copy link
Member Author

Choose a reason for hiding this comment

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

ok I pushed a fetchpatch call to the svannah commit. Which should error when the patch doesn't apply anymore!

@hlolli hlolli force-pushed the aarch64-darwin/fix-emacs-codesigning branch from ef3a770 to 91278c1 Compare May 31, 2021 17:54
@ofborg ofborg bot added 2.status: merge conflict This PR has merge conflicts with the target branch and removed 2.status: merge conflict This PR has merge conflicts with the target branch labels Jun 10, 2021
@thefloweringash
Copy link
Member

Change LGTM. The commit history needs tidying. See the guidelines for commit messages.

@hlolli hlolli force-pushed the aarch64-darwin/fix-emacs-codesigning branch from 1ac6f63 to 5efbcf8 Compare June 15, 2021 14:06
@hlolli
Copy link
Member Author

hlolli commented Jun 15, 2021

Change LGTM. The commit history needs tidying. See the guidelines for commit messages.

fixed

@domenkozar domenkozar merged commit 97ee9d3 into NixOS:master Jun 15, 2021
@github-actions
Copy link
Contributor

Backport failed for release-21.05, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally:

git fetch origin release-21.05
git worktree add -d .worktree/backport-124888-to-release-21.05 origin/release-21.05
cd .worktree/backport-124888-to-release-21.05
git checkout -b backport-124888-to-release-21.05
ancref=$(git merge-base 16b157c3462f547e989faf7a74203bf0f44a9c94 5efbcf8d7eef8a6380dafb9fbfb6420b1e051da9)
git cherry-pick -x $ancref..5efbcf8d7eef8a6380dafb9fbfb6420b1e051da9

@github-actions
Copy link
Contributor

Backport failed for release-21.05, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally:

git fetch origin release-21.05
git worktree add -d .worktree/backport-124888-to-release-21.05 origin/release-21.05
cd .worktree/backport-124888-to-release-21.05
git checkout -b backport-124888-to-release-21.05
ancref=$(git merge-base 16b157c3462f547e989faf7a74203bf0f44a9c94 5efbcf8d7eef8a6380dafb9fbfb6420b1e051da9)
git cherry-pick -x $ancref..5efbcf8d7eef8a6380dafb9fbfb6420b1e051da9

@hlolli hlolli deleted the aarch64-darwin/fix-emacs-codesigning branch June 15, 2021 20:59
@hlolli hlolli mentioned this pull request Apr 19, 2022
9 tasks
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.

6 participants