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-macport: build on LLVM 14 #252244

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkgs/applications/editors/emacs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 11 additions & 2 deletions pkgs/applications/editors/emacs/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
, libtiff
, libwebp
, libxml2
, llvmPackages_6
, llvmPackages_14
, m17n_lib
, makeWrapper
, motif
Expand Down Expand Up @@ -99,6 +99,7 @@
else "lucid")

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

Expand All @@ -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 {
Expand Down Expand Up @@ -287,13 +289,15 @@ mkDerivation (finalAttrs: (lib.optionalAttrs withNativeCompilation {
GSS
ImageIO
] ++ lib.optionals (variant == "macport") [
Accelerate
AppKit
Carbon
Cocoa
IOKit
OSAKit
Quartz
QuartzCore
UniformTypeIdentifiers
WebKit
# TODO are these optional?
GSS
Expand Down Expand Up @@ -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}";
tnytown marked this conversation as resolved.
Show resolved Hide resolved

enableParallelBuilding = true;

installTargets = [ "tags" "install" ];
Expand Down
31 changes: 31 additions & 0 deletions pkgs/applications/editors/emacs/macport_noescape_noop.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef NOESCAPE_NOOP_H_
Copy link
Member

Choose a reason for hiding this comment

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

Can this file be upstreamed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am doing so — figuring out what is happening with the Homebrew build first so I get a concrete diagnosis for the maintainer.

Copy link
Member

Choose a reason for hiding this comment

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

They use Apple Clang I believe which presumably behaves differently.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but their issue tracker has a few reports of similar issues when self-compiled :/

#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_
2 changes: 1 addition & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31477,7 +31477,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
Expand Down