diff --git a/pkgs/applications/editors/emacs/generic.nix b/pkgs/applications/editors/emacs/generic.nix index 69bb51e10f20..9a19fb787e12 100644 --- a/pkgs/applications/editors/emacs/generic.nix +++ b/pkgs/applications/editors/emacs/generic.nix @@ -11,7 +11,7 @@ , libtiff, librsvg, gconf, libxml2, imagemagick, gnutls, libselinux , alsaLib, cairo, acl, gpm, AppKit, GSS, ImageIO, m17n_lib, libotf , jansson, harfbuzz -, libgccjit, targetPlatform, binutils, binutils-unwrapped, makeWrapper # native-comp params +, libgccjit, targetPlatform, makeWrapper # native-comp params , systemd ? null , withX ? !stdenv.isDarwin , withNS ? stdenv.isDarwin @@ -67,18 +67,23 @@ 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.glibc}/lib" - ]; + 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}" + "${lib.getBin stdenv.cc.bintools}" + "${lib.getBin stdenv.cc.bintools.bintools}" + ])); 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 '(${backendPath})" '')) - "" ]; @@ -156,11 +161,6 @@ in stdenv.mkDerivation { "$out/bin/emacs" patchelf --add-needed "libXcursor.so.1" "$out/bin/emacs" '') - - (lib.optionalString nativeComp '' - wrapProgram $out/bin/emacs-* --prefix PATH : "${lib.makeBinPath [ binutils binutils-unwrapped ]}" - '') - ]; passthru = { diff --git a/pkgs/development/compilers/gcc/9/default.nix b/pkgs/development/compilers/gcc/9/default.nix index 7cfc977b3f4c..305ed56df78c 100644 --- a/pkgs/development/compilers/gcc/9/default.nix +++ b/pkgs/development/compilers/gcc/9/default.nix @@ -184,7 +184,7 @@ stdenv.mkDerivation ({ preConfigure = import ../common/pre-configure.nix { inherit (stdenv) lib; - inherit version hostPlatform gnatboot langAda langGo; + inherit version hostPlatform gnatboot langAda langGo langJit; }; dontDisableStatic = true; diff --git a/pkgs/development/compilers/gcc/builder.sh b/pkgs/development/compilers/gcc/builder.sh index d242f1a822cd..2204744a4b59 100644 --- a/pkgs/development/compilers/gcc/builder.sh +++ b/pkgs/development/compilers/gcc/builder.sh @@ -261,7 +261,7 @@ postInstall() { fi if type "install_name_tool"; then - for i in "${!outputLib}"/lib/*.*.dylib; do + for i in "${!outputLib}"/lib/*.*.dylib "${!outputLib}"/lib/*.so.[0-9]; do install_name_tool -id "$i" "$i" || true for old_path in $(otool -L "$i" | grep "$out" | awk '{print $1}'); do new_path=`echo "$old_path" | sed "s,$out,${!outputLib},"` diff --git a/pkgs/development/compilers/gcc/common/pre-configure.nix b/pkgs/development/compilers/gcc/common/pre-configure.nix index fff490148007..1c65b4a8ba64 100644 --- a/pkgs/development/compilers/gcc/common/pre-configure.nix +++ b/pkgs/development/compilers/gcc/common/pre-configure.nix @@ -2,6 +2,7 @@ , gnatboot ? null , langAda ? false , langJava ? false +, langJit ? false , langGo }: assert langJava -> lib.versionOlder version "7"; @@ -49,3 +50,11 @@ lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' + lib.optionalString (hostPlatform.isDarwin) '' export ac_cv_func_aligned_alloc=no '' + +# In order to properly install libgccjit on macOS Catalina, strip(1) +# upon installation must not remove external symbols, otherwise the +# install step errors with "symbols referenced by indirect symbol +# table entries that can't be stripped". ++ lib.optionalString (hostPlatform.isDarwin && langJit) '' + export STRIP='strip -x' +''