emacs: change substituteInPlace invocation to an aligning patch

Commit 97b928ce09d6034ebcb541fb548e5d4862302add in Emacs
messed up the substituteInPlace. Use a patch instead to prevent silent failures.

https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=97b928ce09d6034ebcb541fb548e5d4862302add
This commit is contained in:
Brian Leung 2022-10-17 05:17:55 -07:00
parent 82d4c2c851
commit 8ede52a7c1
No known key found for this signature in database
GPG key ID: 2D86D6A94C8BB3B1
3 changed files with 55 additions and 21 deletions

View file

@ -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})"
''))
""
];

View file

@ -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

View file

@ -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