From cb0db57251a9cd3974da0d5b669eacd2650c4029 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 10 Aug 2025 01:29:59 +0100 Subject: [PATCH] emacs-macport: use a different hammer for the `CF_NOESCAPE` bug 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. --- .../CoreFoundation/CFBase.h | 8 +++++ .../editors/emacs/macport_noescape_noop.h | 31 ------------------- .../applications/editors/emacs/make-emacs.nix | 9 ++---- 3 files changed, 10 insertions(+), 38 deletions(-) create mode 100644 pkgs/applications/editors/emacs/macport-noescape-noop/CoreFoundation/CFBase.h delete mode 100644 pkgs/applications/editors/emacs/macport_noescape_noop.h diff --git a/pkgs/applications/editors/emacs/macport-noescape-noop/CoreFoundation/CFBase.h b/pkgs/applications/editors/emacs/macport-noescape-noop/CoreFoundation/CFBase.h new file mode 100644 index 000000000000..2ade833151ef --- /dev/null +++ b/pkgs/applications/editors/emacs/macport-noescape-noop/CoreFoundation/CFBase.h @@ -0,0 +1,8 @@ +#if !defined(__COREFOUNDATION_CFBASE__) + +#include_next + +#undef CF_NOESCAPE +#define CF_NOESCAPE + +#endif diff --git a/pkgs/applications/editors/emacs/macport_noescape_noop.h b/pkgs/applications/editors/emacs/macport_noescape_noop.h deleted file mode 100644 index 64c65bd90f88..000000000000 --- a/pkgs/applications/editors/emacs/macport_noescape_noop.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef NOESCAPE_NOOP_H_ -#define NOESCAPE_NOOP_H_ - -// First, do some work to get definitions for *_WIDTH. Normally, Emacs would -// have these defined by headers in-tree, but clang's headers clash with those. -// Due to how include paths work, we have to include clang headers if we want to -// mess with CoreFoundation definitions. -#pragma push_macro("__STDC_VERSION__") -// Make the preprocessor think that we're on C2x. The macros we want are gated -// on it. -#undef __STDC_VERSION__ -#define __STDC_VERSION__ 202000L -// Include limits.h first, as stdint.h includes it. -#include - -// XX: clang's stdint.h is shy and won't give us its defs unless it thinks it's -// in freestanding mode. -#undef __STDC_HOSTED__ -#include -#define __STDC_HOSTED__ 1 - -#pragma pop_macro("__STDC_VERSION__") - -// Now, pull in the header that defines CF_NOESCAPE. -#include - -// Redefine CF_NOESCAPE as empty. -#undef CF_NOESCAPE -#define CF_NOESCAPE - -#endif // NOESCAPE_NOOP_H_ diff --git a/pkgs/applications/editors/emacs/make-emacs.nix b/pkgs/applications/editors/emacs/make-emacs.nix index b9f75464c793..cc5df12f973e 100644 --- a/pkgs/applications/editors/emacs/make-emacs.nix +++ b/pkgs/applications/editors/emacs/make-emacs.nix @@ -45,7 +45,6 @@ libtiff, libwebp, libxml2, - llvmPackages_14, m17n_lib, mailcap, mailutils, @@ -139,12 +138,8 @@ let ++ lib.optionals (stdenv.cc ? cc.lib.libgcc) [ "${lib.getLib stdenv.cc.cc.lib.libgcc}/lib" ]; - - inherit (if variant == "macport" then llvmPackages_14.stdenv else stdenv) - mkDerivation - ; in -mkDerivation (finalAttrs: { +stdenv.mkDerivation (finalAttrs: { pname = pname + ( @@ -430,7 +425,7 @@ mkDerivation (finalAttrs: { // lib.optionalAttrs (variant == "macport") { # Fixes intermittent segfaults when compiled with LLVM >= 7.0. # See https://github.com/NixOS/nixpkgs/issues/127902 - NIX_CFLAGS_COMPILE = "-include ${./macport_noescape_noop.h}"; + NIX_CFLAGS_COMPILE = "-isystem ${./macport-noescape-noop}"; }; enableParallelBuilding = true;