Skip to content

emacs-macport: use a different hammer for the CF_NOESCAPE bug#435148

Merged
emilazy merged 2 commits intoNixOS:masterfrom
emilazy:push-xykrqotlpouv
Sep 3, 2025
Merged

emacs-macport: use a different hammer for the CF_NOESCAPE bug#435148
emilazy merged 2 commits intoNixOS:masterfrom
emilazy:push-xykrqotlpouv

Conversation

@emilazy
Copy link
Member

@emilazy emilazy commented Aug 20, 2025

The header was breaking compilation with modern versions of Clang, seemingly due to the limits.h stuff. Wrapping the header directly is simpler and fixes it.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@emilazy emilazy requested a review from jian-lin August 20, 2025 02:06
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. 6.topic: emacs Text editor labels Aug 20, 2025
Copy link
Contributor

@jian-lin jian-lin left a comment

Choose a reason for hiding this comment

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

I am not familiar with emacs-macport. Maybe @Atemu (#155360) and @tnytown (#252244) have something to say?

@emilazy
Copy link
Member Author

emilazy commented Aug 20, 2025

I’m pretty sure it works, FWIW. As in, I read the whole (wonderful) investigation by @tnytown, tried a bunch of less hacky things, and they all reproduced the original bug with both the old and new LLVM, but this keeps it fixed under LLVM 14 and keeps it fixed under the new LLVM. (I believe @Atemu no longer uses macOS.)

But certainly it would be good for someone who actually uses emacs-macport to take this for a little spin.

@tnytown
Copy link
Contributor

tnytown commented Aug 20, 2025

No idea why I did it the more complicated way, this looks more reasonable!

@AndersonTorres
Copy link
Member

Most probably something like "compiler said X, so let's fix it" and "use #define guards to not break on Linux" iterated six times?

But I digress.

Maybe this file should be sent to Mitsuharu-san?

@emilazy
Copy link
Member Author

emilazy commented Aug 21, 2025

It was the result of a long investigation in #127902 (comment) and #127902 (comment). I believe that the emacs-macport code is semantically incorrect but that a commit that is reverted in Apple’s Clang but not the vanilla one we use, that takes advantage of the incorrect annotations, means that it doesn’t break when compiled with the Xcode toolchain. So the correct upstream fix would involve fixing C memory management type issues. It being reported upstream would be good, but I think not a blocker for this fix (which is required to drop EOL LLVMs), and I don’t think the hack is upstreamable.

@jian-lin
Copy link
Contributor

This is not my area but I trust @emilazy. So please merge this as you see fit @emilazy :)

@kfiz
Copy link
Contributor

kfiz commented Aug 28, 2025

@emilazy I'm getting this, when trying to build this:

Running phase: configurePhase
@nix { "action": "setPhase", "phase": "configurePhase" }
patching script interpreter paths in ./configure
./configure: interpreter directive changed from "#! /bin/sh" to "/nix/store/3g3sgwpnig8sd0w9wbs7d5gy512r43cq-bash-5.3p3/bin/sh"
configure flags: --prefix=/nix/store/h3raf67dr2w6xs698nkfkwr97yra9sx8-emacs-mac-macport-30.2.50 --disable-build-details --with-modules --without-gif --without-jpeg --without-png --without-tiff --witho>
checking for xcrun... xcrun
checking for make... yes
checking for GNU Make... make
checking build system type... aarch64-apple-darwin24.6.0
checking host system type... aarch64-apple-darwin24.6.0
checking whether the C compiler works... no
configure: error: in '/nix/var/nix/builds/nix-build-emacs-mac-macport-30.2.50.drv-3/source':
configure: error: C compiler cannot create executables
See 'config.log' for more details

I don’t love how this is separated from the actual declaration of
the source, but it seems to be what we have to do.

Fixes: 4a2ad81
The header was breaking compilation with modern versions of Clang,
seemingly due to the `limits.h` stuff. Wrapping the header directly
is simpler and fixes it.
@emilazy
Copy link
Member Author

emilazy commented Sep 2, 2025

Hmm, I’m not getting that exact failure, but #437637 did regress the build. I’ve pushed a fix for that.

@emilazy
Copy link
Member Author

emilazy commented Sep 2, 2025

My test build passed. @kfiz, could you try it again and let me know exactly how you were testing?

I’ll let @jian-lin have another look given the new commit too.

Incidentally, I see that nobody has reported that emacs-macport currently fails to build on nixpkgs-unstable after 5 days. I’m wondering how popular the package is at this point.

@kfiz
Copy link
Contributor

kfiz commented Sep 2, 2025

My test build passed. @kfiz, could you try it again and let me know exactly how you were testing?

I’ll let @jian-lin have another look given the new commit too.

@emilazy works for me now.

@kfiz
Copy link
Contributor

kfiz commented Sep 2, 2025

Incidentally, I see that nobody has reported that emacs-macport currently fails to build on nixpkgs-unstable after 5 days. I’m wondering how popular the package is at this point.

@emilazy my strong assumption is that most of the emacs-macport users have temporarily switched to vanilla emacs to have a functional emacs v30 version. They will switch back if there is a v30 for emacs-macport.

Copy link
Contributor

@jian-lin jian-lin left a comment

Choose a reason for hiding this comment

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

The new commit "emacs-macport: fix build" looks good.

I don’t love how this is separated from the actual declaration of
the source

srcRepo is separated to let downstream users be able to change it.

@emilazy
Copy link
Member Author

emilazy commented Sep 3, 2025

Thanks for the reviews :)

Maybe we should check whether @juuyokka is still interested in working on #393512, as it seems like the emacs-macport package may become a maintenance burden if it stays on an old version indefinitely.

@emilazy emilazy merged commit 1ee59a3 into NixOS:master Sep 3, 2025
28 of 31 checks passed
@emilazy emilazy deleted the push-xykrqotlpouv branch September 3, 2025 00:30
@kfiz
Copy link
Contributor

kfiz commented Sep 3, 2025

Maybe we should check whether @juuyokka is still interested in working on #393512, as it seems like the emacs-macport package may become a maintenance burden if it stays on an old version indefinitely.

@emilazy agree. I think in the meantime we should switch to the fork that is already mentioned there https://github.com/jdtsmith/emacs-mac until it is clear what happens to the original package. I've been test driving it and it seems quite stable to me. I can send a new PR that is based on #393512.

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

Labels

6.topic: emacs Text editor 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages 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.

5 participants