Skip to content

Commit

Permalink
emacs: use -B flags for native compilation dependencies
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
antifuchs committed Sep 2, 2020
1 parent 6ad323d commit 04fffd6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkgs/applications/editors/emacs/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,22 @@ 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}"
]));
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})"
''))
""
];
Expand Down

2 comments on commit 04fffd6

@acowley
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think the issue I see with compilation failures is related to this? I had guessed that fixing the error I see would require a wrapper, but this commit message seems to be suggesting the opposite.

@acowley
Copy link
Contributor

Choose a reason for hiding this comment

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

I've opened a PR that seems to fix this for me, but I'm surprised nobody else has reported an issue. @antifuchs

Please sign in to comment.