Commit f607a785 authored by Andrew Pan's avatar Andrew Pan Committed by Anderson Torres
Browse files

emacs-macport: build on LLVM 14

- Build on `apple_sdk_11_0` to support `aarch64-darwin`
- Add frameworks required for building on newer SDKs
  - `Accelerate`, `UniformTypeIdentifiers`
- Include header to work around `CF_NOESCAPE` issue circa LLVM 7.0
parent e161990d
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -8,9 +8,9 @@ lib.makeScope pkgs.newScope (self:
      inherit gconf;

      inherit (pkgs.darwin) sigtool;
      inherit (pkgs.darwin.apple_sdk.frameworks)
        AppKit Carbon Cocoa GSS ImageCaptureCore ImageIO IOKit OSAKit Quartz
        QuartzCore WebKit;
      inherit (pkgs.darwin.apple_sdk_11_0.frameworks)
        Accelerate AppKit Carbon Cocoa GSS ImageCaptureCore ImageIO IOKit OSAKit
        Quartz QuartzCore UniformTypeIdentifiers WebKit;
    };
  in {
    sources = import ./sources.nix {
+11 −2
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@
, libtiff
, libwebp
, libxml2
, llvmPackages_6
, llvmPackages_14
, m17n_lib
, makeWrapper
, motif
@@ -99,6 +99,7 @@
  else "lucid")

# macOS dependencies for NS and macPort
, Accelerate
, AppKit
, Carbon
, Cocoa
@@ -109,6 +110,7 @@
, OSAKit
, Quartz
, QuartzCore
, UniformTypeIdentifiers
, WebKit
}:

@@ -135,7 +137,7 @@ let
  ];

  inherit (if variant == "macport"
           then llvmPackages_6.stdenv
           then llvmPackages_14.stdenv
           else stdenv) mkDerivation;
in
mkDerivation (finalAttrs: (lib.optionalAttrs withNativeCompilation {
@@ -287,6 +289,7 @@ mkDerivation (finalAttrs: (lib.optionalAttrs withNativeCompilation {
    GSS
    ImageIO
  ] ++ lib.optionals (variant == "macport") [
    Accelerate
    AppKit
    Carbon
    Cocoa
@@ -294,6 +297,7 @@ mkDerivation (finalAttrs: (lib.optionalAttrs withNativeCompilation {
    OSAKit
    Quartz
    QuartzCore
    UniformTypeIdentifiers
    WebKit
    # TODO are these optional?
    GSS
@@ -337,6 +341,11 @@ mkDerivation (finalAttrs: (lib.optionalAttrs withNativeCompilation {
  ++ lib.optional withXwidgets "--with-xwidgets"
  ;

  # Fixes intermittent segfaults when compiled with LLVM >= 7.0.
  # See https://github.com/NixOS/nixpkgs/issues/127902
  env.NIX_CFLAGS_COMPILE = lib.optionalString (variant == "macport")
    "-include ${./macport_noescape_noop.h}";

  enableParallelBuilding = true;

  installTargets = [ "tags" "install" ];
+31 −0
Original line number Diff line number Diff line
#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_
+1 −1
Original line number Diff line number Diff line
@@ -31492,7 +31492,7 @@ with pkgs;
  em = callPackage ../applications/editors/em { };
  inherit (recurseIntoAttrs (callPackage ../applications/editors/emacs { }))
  inherit (recurseIntoAttrs (darwin.apple_sdk_11_0.callPackage ../applications/editors/emacs { }))
    emacs28
    emacs28-gtk2
    emacs28-gtk3