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.
This commit is contained in:
Emily
2025-09-02 18:55:38 +01:00
parent a8ea016dd8
commit cb0db57251
3 changed files with 10 additions and 38 deletions
@@ -0,0 +1,8 @@
#if !defined(__COREFOUNDATION_CFBASE__)
#include_next <CoreFoundation/CFBase.h>
#undef CF_NOESCAPE
#define CF_NOESCAPE
#endif
@@ -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 <limits.h>
// 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 <stdint.h>
#define __STDC_HOSTED__ 1
#pragma pop_macro("__STDC_VERSION__")
// Now, pull in the header that defines CF_NOESCAPE.
#include <CoreFoundation/CFBase.h>
// Redefine CF_NOESCAPE as empty.
#undef CF_NOESCAPE
#define CF_NOESCAPE
#endif // NOESCAPE_NOOP_H_
@@ -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;