diff --git a/pkgs/applications/editors/emacs/generic.nix b/pkgs/applications/editors/emacs/generic.nix index 486435cc86b4..3e195fdec6a9 100644 --- a/pkgs/applications/editors/emacs/generic.nix +++ b/pkgs/applications/editors/emacs/generic.nix @@ -7,7 +7,7 @@ , patches ? _: [ ] , macportVersion ? null }: -{ stdenv, llvmPackages_6, lib, fetchurl, fetchpatch, ncurses, xlibsWrapper, libXaw, libXpm +{ stdenv, llvmPackages_6, lib, fetchurl, fetchpatch, substituteAll, ncurses, xlibsWrapper, libXaw, libXpm , Xaw3d, libXcursor, pkg-config, gettext, libXft, dbus, libpng, libjpeg, giflib , libtiff, librsvg, libwebp, gconf, libxml2, imagemagick, gnutls, libselinux , alsa-lib, cairo, acl, gpm, m17n_lib, libotf @@ -67,7 +67,25 @@ let emacs = (if withMacport then llvmPackages_6.stdenv else stdenv).mkDerivation pname = pname + lib.optionalString ( !withX && !withNS && !withMacport && !withGTK2 && !withGTK3 ) "-nox"; inherit version; - patches = patches fetchpatch; + patches = patches fetchpatch ++ lib.optionals nativeComp [ + (substituteAll { + src = if lib.versionOlder version "29" + then ./native-comp-driver-options-28.patch + else ./native-comp-driver-options.patch; + backendPath = (lib.concatStringsSep " " + (builtins.map (x: ''"-B${x}"'') [ + # Paths necessary so the JIT compiler finds its libraries: + "${lib.getLib libgccjit}/lib" + "${lib.getLib libgccjit}/lib/gcc" + "${lib.getLib stdenv.cc.libc}/lib" + + # Executable paths necessary for compilation (ld, as): + "${lib.getBin stdenv.cc.cc}/bin" + "${lib.getBin stdenv.cc.bintools}/bin" + "${lib.getBin stdenv.cc.bintools.bintools}/bin" + ])); + }) + ]; src = if macportVersion != null then fetchFromBitbucket { owner = "mituharu"; @@ -112,25 +130,6 @@ let emacs = (if withMacport then llvmPackages_6.stdenv else stdenv).mkDerivation done '' - # Make native compilation work both inside and outside of nix build - (lib.optionalString nativeComp (let - backendPath = (lib.concatStringsSep " " - (builtins.map (x: ''\"-B${x}\"'') [ - # Paths necessary so the JIT compiler finds its libraries: - "${lib.getLib libgccjit}/lib" - "${lib.getLib libgccjit}/lib/gcc" - "${lib.getLib stdenv.cc.libc}/lib" - - # Executable paths necessary for compilation (ld, as): - "${lib.getBin stdenv.cc.cc}/bin" - "${lib.getBin stdenv.cc.bintools}/bin" - "${lib.getBin stdenv.cc.bintools.bintools}/bin" - ])); - in '' - substituteInPlace lisp/emacs-lisp/comp.el --replace \ - "(defcustom native-comp-driver-options nil" \ - "(defcustom native-comp-driver-options '(${backendPath})" - '')) "" ]; diff --git a/pkgs/applications/editors/emacs/native-comp-driver-options-28.patch b/pkgs/applications/editors/emacs/native-comp-driver-options-28.patch new file mode 100644 index 000000000000..98c6da305145 --- /dev/null +++ b/pkgs/applications/editors/emacs/native-comp-driver-options-28.patch @@ -0,0 +1,16 @@ +diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el +index a5ab12ae38..e33e71cb55 100644 +--- a/lisp/emacs-lisp/comp.el ++++ b/lisp/emacs-lisp/comp.el +@@ -178,7 +178,7 @@ native-comp-compiler-options + :type '(repeat string) + :version "28.1") + +-(defcustom native-comp-driver-options nil ++(defcustom native-comp-driver-options '(@backendPath@) + "Options passed verbatim to the native compiler's back-end driver. + Note that not all options are meaningful; typically only the options + affecting the assembler and linker are likely to be useful. +-- +2.37.3 + diff --git a/pkgs/applications/editors/emacs/native-comp-driver-options.patch b/pkgs/applications/editors/emacs/native-comp-driver-options.patch new file mode 100644 index 000000000000..58eee35aed0a --- /dev/null +++ b/pkgs/applications/editors/emacs/native-comp-driver-options.patch @@ -0,0 +1,19 @@ +diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el +index 2c9b79334b..50c6b5ac85 100644 +--- a/lisp/emacs-lisp/comp.el ++++ b/lisp/emacs-lisp/comp.el +@@ -178,8 +178,9 @@ native-comp-compiler-options + :type '(repeat string) + :version "28.1") + +-(defcustom native-comp-driver-options (when (eq system-type 'darwin) +- '("-Wl,-w")) ++(defcustom native-comp-driver-options (append (when (eq system-type 'darwin) ++ '("-Wl,-w")) ++ '(@backendPath@)) + "Options passed verbatim to the native compiler's back-end driver. + Note that not all options are meaningful; typically only the options + affecting the assembler and linker are likely to be useful. +-- +2.37.3 +