emacs: Set native-comp library path as linker flags instead

Since Darwin's linker does not understand LIBRARY_PATH, we have to set
the library path as explicit linker flags: This requires a very recent
feature/native-comp emacs revision, but it runs on Darwin and
correctly compiles files at runtime.
This commit is contained in:
Andreas Fuchs 2020-08-26 20:37:35 -04:00
parent 861f27018d
commit a891ae41b3

View file

@ -67,18 +67,18 @@ in stdenv.mkDerivation {
# Make native compilation work both inside and outside of nix build
(lib.optionalString nativeComp (let
libPath = lib.concatStringsSep ":" [
"${lib.getLib libgccjit}/lib/gcc/${targetPlatform.config}/${libgccjit.version}"
"${lib.getLib stdenv.cc.cc}/lib"
"${lib.getLib stdenv.libc}/lib"
];
libPath = (lib.concatStringsSep " "
(builtins.map (x: ''\"-L${x}\"'') [
"${lib.getLib libgccjit}/lib"
"${lib.getLib libgccjit}/lib/gcc/${targetPlatform.config}/${libgccjit.version}"
"${lib.getLib stdenv.cc.cc}/lib"
"${lib.getLib stdenv.libc}/lib"
]));
in ''
substituteInPlace lisp/emacs-lisp/comp.el --replace \
"(defcustom comp-async-env-modifier-form nil" \
"(defcustom comp-async-env-modifier-form '((setenv \"LIBRARY_PATH\" (string-join (seq-filter (lambda (v) (null (eq v nil))) (list (getenv \"LIBRARY_PATH\") \"${libPath}\")) \":\")))"
"(defcustom comp-native-driver-options nil" \
"(defcustom comp-native-driver-options '(${libPath})"
''))
""
];