From 04fffd6cae88e676a13fa94e1f7abdaa3156e707 Mon Sep 17 00:00:00 2001 From: Andreas Fuchs Date: Mon, 31 Aug 2020 00:47:33 -0400 Subject: [PATCH] emacs: use -B flags for native compilation dependencies The -B flag to gcc (and libgccjit) allows us to specify where it can find things it needs to correctly compile code (both programs and libraries) without adjusting any environmental flags: So, no need to wrap the program for a PATH entry containing binutils, and no need to explicitly pass a linker path anymore. --- pkgs/applications/editors/emacs/generic.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkgs/applications/editors/emacs/generic.nix b/pkgs/applications/editors/emacs/generic.nix index b2d9b9a1367f..9a19fb787e12 100644 --- a/pkgs/applications/editors/emacs/generic.nix +++ b/pkgs/applications/editors/emacs/generic.nix @@ -67,13 +67,14 @@ in stdenv.mkDerivation { # Make native compilation work both inside and outside of nix build (lib.optionalString nativeComp (let - libPath = (lib.concatStringsSep " " + 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/${targetPlatform.config}/${libgccjit.version}" - "${lib.getLib stdenv.cc.cc}/lib" + "${lib.getLib libgccjit}/lib/gcc" "${lib.getLib stdenv.cc.libc}/lib" - "${lib.getBin stdenv.cc.cc}" + + # Executable paths necessary for compilation (ld, as): "${lib.getBin stdenv.cc.cc}" "${lib.getBin stdenv.cc.bintools}" "${lib.getBin stdenv.cc.bintools.bintools}" @@ -81,7 +82,7 @@ in stdenv.mkDerivation { in '' substituteInPlace lisp/emacs-lisp/comp.el --replace \ "(defcustom comp-native-driver-options nil" \ - "(defcustom comp-native-driver-options '(${libPath})" + "(defcustom comp-native-driver-options '(${backendPath})" '')) "" ];