From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id pkJBFQYkB2MoUQAAbAwnHQ (envelope-from ) for ; Thu, 25 Aug 2022 09:25:58 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id GL44FAYkB2NLLgAA9RJhRA (envelope-from ) for ; Thu, 25 Aug 2022 09:25:58 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 15A8B169D6 for ; Thu, 25 Aug 2022 09:25:58 +0200 (CEST) Received: from localhost ([::1]:34134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oR7FU-00051J-U2 for larch@yhetil.org; Thu, 25 Aug 2022 03:25:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oR7Ef-0004Tx-N6 for guix-patches@gnu.org; Thu, 25 Aug 2022 03:25:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59014) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oR7Ef-0006M3-DD for guix-patches@gnu.org; Thu, 25 Aug 2022 03:25:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oR7Ef-0000Bl-8F for guix-patches@gnu.org; Thu, 25 Aug 2022 03:25:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57086] [PATCH v3 4/7] gnu: emacs: Build with native compilation. References: <4c232648145659a2c3edca6d32725d8120cc14d3.camel@gmail.com> In-Reply-To: <4c232648145659a2c3edca6d32725d8120cc14d3.camel@gmail.com> Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 25 Aug 2022 07:25:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57086 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 57086@debbugs.gnu.org Received: via spool by 57086-submit@debbugs.gnu.org id=B57086.1661412292641 (code B ref 57086); Thu, 25 Aug 2022 07:25:05 +0000 Received: (at 57086) by debbugs.gnu.org; 25 Aug 2022 07:24:52 +0000 Received: from localhost ([127.0.0.1]:48755 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oR7ER-0000AA-TB for submit@debbugs.gnu.org; Thu, 25 Aug 2022 03:24:52 -0400 Received: from mail-ej1-f66.google.com ([209.85.218.66]:39812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oR7EB-00008S-NT for 57086@debbugs.gnu.org; Thu, 25 Aug 2022 03:24:39 -0400 Received: by mail-ej1-f66.google.com with SMTP id u15so29134007ejt.6 for <57086@debbugs.gnu.org>; Thu, 25 Aug 2022 00:24:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:content-transfer-encoding:to:mime-version:subject:date :from:from:to:cc; bh=PZf6U4gTPJ1aoEpXY6YT4gLXmbqqnqUaE06JB4w9isE=; b=opx/j/YeNNPgJE/8fW1rSRCRIXvkJVWH4+WEQCr6r9YFYnlfo23quZq7RDOTgDTbTh 3jv8H9w0Jycl+M+1OiM0vFdCHZCUhaTAuN3n1Y95CsCrIwH+oRtYQRwXo9zDavLfxaLM JWc9Q4E9TUu1z3XSykCH7XRzNdYrIgQ72MrklxffhWI4ZaY5/K6Aanrn791jmLG2TEN5 NL4d9pWu/t5TMBREoW/wbB2QBIYb6hUOaxWlzsFHzBmBxny2h053XTEZ/ww4B5pCA8od y7VA4hTE/N+rKF+LEBaOqmrhpN9P/J8KYua9aHhZ0e+3bDKl8JUws1s6VVfHCfxbg1sT wgrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=message-id:content-transfer-encoding:to:mime-version:subject:date :from:x-gm-message-state:from:to:cc; bh=PZf6U4gTPJ1aoEpXY6YT4gLXmbqqnqUaE06JB4w9isE=; b=iagFMttYwV9c1PrnrqoSC/OaHtErxnqhXv44mwxhCvyLXFxB2+SiRHgQ5usIDXKKeq 6OyWv08b+lmIwI1z8Xkp/3aoc6CcWIvBGnnFfPNNRNC773Z7w5TvoObYJkUwzMlagoxw lIsSi+dnFeVzsP8RpBs1eM4s0mp/CrOugNPMyYTxU6Jc54coq5RfgTsfROm1+2ceH4a6 YwcIogdhkRj9zlfp8jK2U8/4v0Ae6Dlh3xBZh3fxhTAZ1cnVkoA1uT+5CR7CYVtoH/rt Lgn0yYaNPF/SHK9O9mFLro4HcwADEb+wGKjIq+RDYIiKi9brWS0ZGMdTAeIMulgZRaSY 79IA== X-Gm-Message-State: ACgBeo1W9bioLbVxoTObOsoi0SBJqCMeVpcbAdN7Rmy1j6XQOyXikGpm xewHNczfLeOy19doUEGsQQlGj8n8IKc= X-Google-Smtp-Source: AA6agR6jd0DhXzxM2q3E7rQkLsV+gsDZVrSNBWFhfv+HZ19J40iagVwRV/bV4XO3j8fPY8uV638aXg== X-Received: by 2002:a17:906:8cb0:b0:731:5149:a983 with SMTP id qr48-20020a1709068cb000b007315149a983mr1544265ejc.549.1661412270157; Thu, 25 Aug 2022 00:24:30 -0700 (PDT) Received: from nijino.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id g2-20020a170906538200b0073d62cc3270sm2019690ejo.118.2022.08.25.00.24.28 for <57086@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Aug 2022 00:24:29 -0700 (PDT) From: Liliana Marie Prikler Date: Sat, 6 Aug 2022 00:37:43 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-ID: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1661412358; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=PZf6U4gTPJ1aoEpXY6YT4gLXmbqqnqUaE06JB4w9isE=; b=nHVgKk8fHxw8z8xJ/1QUJFa3yugJ9mh7JDtETygQ/5/w5V/u+KvB6wudTVYH0frq5Qskso DehFW13uNwfIWH6B2jq4aOpAo4trZsQxXsnlEyQ/uHv5vz6elTGm5n+729t1YTKw9IRgMV 3gmbjQGUwKI15MG1lp/+i0WWtmH42H7j11/+L/O1fDdYMUjam38nuwtifnxTfG39KlUJis K+DqswJZI9IQHYt1CaYh1NHN48T53uSYdWB3RxO/LbFJL24pFsWvLW0JG+1ACR7DWnjK3c nwsQyaytbpBNroCMrW2nYDkHPTYNGO5dJJyrxSZ1wnyUk2e2m65lvc5rV0T8gQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1661412358; a=rsa-sha256; cv=none; b=HMKVddP/Cw/bI14BzucW+c3nB02MjhpEDUowUWaitwbExNBcy7MWtQjvfEnkG9/k5eoKGD 7luOGpGxHXzKGf4YO4d+V1CFSXyCljXn6NNBtoMOlrKCzNYn5QlOFnXgs2OXIGhouNDyWU A+VoZINQldY0cyfxR4tMcTq79wElMxjApVlVndvvmhuwkXu5bDDr/hxUicp1U29sl0u8rX ZnZPbBcLdMD7/nyLUTEyJOhMibfnw7j/I92F0O1LPSNTCI53C/BcIqyk5PYrc3VPj57lRS Kj6g5v25iwugxzlO8rt3jmk6TLobWoVhui+hdl0MZ11IsUdNIeS9O3iJ3D/zQA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="opx/j/Ye"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 5.79 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="opx/j/Ye"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 15A8B169D6 X-Spam-Score: 5.79 X-Migadu-Scanner: scn0.migadu.com X-TUID: ARhIIOvi7tVx * gnu/packages/emacs.scm (%emacs-modules): New variable. (emacs)[arguments]<#:modules>: Use it here. <#:configure-flags> Add “--with-native-compilation”. <#:make-flags>: Add “NATIVE_FULL_AOT=1”. <#:phases>: Add ‘set-libgccjit-path’ and ‘patch-compilation-driver’. [inputs]: Add explicit ld-wrapper, binutils, glibc, and libgccjit. [search-paths]: Add EMACSNATIVELOADPATH. (emacs-minimal, emacs-xwidgets, emacs-no-x) (emacs-no-x-toolkit): Adjust accordingly. --- gnu/packages/emacs.scm | 67 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm index ffd1eda08e..6c3bee03d5 100644 --- a/gnu/packages/emacs.scm +++ b/gnu/packages/emacs.scm @@ -45,6 +45,7 @@ (define-module (gnu packages emacs) #:use-module (guix gexp) #:use-module (guix download) #:use-module (guix git-download) + #:use-module (guix build-system) #:use-module (guix build-system gnu) #:use-module (guix build-system glib-or-gtk) #:use-module (gnu packages) @@ -55,6 +56,7 @@ (define-module (gnu packages emacs) #:use-module (gnu packages fontutils) #:use-module (gnu packages freedesktop) #:use-module (gnu packages fribidi) + #:use-module (gnu packages gcc) #:use-module (gnu packages gd) #:use-module (gnu packages gettext) #:use-module (gnu packages ghostscript) @@ -81,6 +83,13 @@ (define-module (gnu packages emacs) #:use-module (ice-9 match) #:use-module (srfi srfi-1)) +(define (%emacs-modules build-system) + (let ((which (build-system-name build-system))) + `((guix build ,(symbol-append which '-build-system)) + (guix build utils) + (srfi srfi-1) + (ice-9 ftw)))) + (define-public emacs (package (name "emacs") @@ -129,11 +138,33 @@ (define-public emacs (arguments (list #:tests? #f ; no check target + #:modules (%emacs-modules build-system) #:configure-flags #~(list "--with-modules" "--with-cairo" + "--with-native-compilation" "--disable-build-details") + #:make-flags #~(list "NATIVE_FULL_AOT=1") #:phases #~(modify-phases %standard-phases + (add-after 'set-paths 'set-libgccjit-path + (lambda* (#:key inputs #:allow-other-keys) + (define (first-subdirectory/absolute directory) + (let ((files (scandir + directory + (lambda (file) + (and (not (member file '("." ".."))) + (file-is-directory? (string-append + directory "/" + file))))))) + (and (not (null? files)) + (string-append directory "/" (car files))))) + (let* ((libgccjit-libdir + (first-subdirectory/absolute ;; version + (first-subdirectory/absolute ;; host type + (search-input-directory inputs "lib/gcc"))))) + (setenv "LIBRARY_PATH" + (string-append (getenv "LIBRARY_PATH") + ":" libgccjit-libdir))))) (add-after 'unpack 'enable-elogind (lambda _ (substitute* "configure.ac" @@ -164,6 +195,20 @@ (define-public emacs (("\\(tramp-compat-process-running-p \"(.*)\"\\)" all process) (format #f "(or ~a (tramp-compat-process-running-p ~s))" all (string-append "." process "-real")))))) + (add-after 'unpack 'patch-compilation-driver + (lambda _ + (substitute* "lisp/emacs-lisp/comp.el" + (("\\(defcustom native-comp-driver-options nil") + (format + #f "(defcustom native-comp-driver-options '(~@{~s~^ ~})" + (string-append + "-B" #$(this-package-input "binutils") "/bin/") + (string-append + "-B" #$(this-package-input "glibc") "/lib/") + (string-append + "-B" #$(this-package-input "libgccjit") "/lib/") + (string-append + "-B" #$(this-package-input "libgccjit") "/lib/gcc/")))))) (add-before 'configure 'fix-/bin/pwd (lambda _ ;; Use `pwd', not `/bin/pwd'. @@ -256,6 +301,14 @@ (define* (emacs-byte-compile-directory dir) (list gnutls ncurses + ;; To "unshadow" ld-wrapper in native builds + (make-ld-wrapper "ld-wrapper" #:binutils binutils) + + ;; For native compilation + binutils + glibc + libgccjit + ;; Required for "core" functionality, such as dired and compression. coreutils gzip @@ -307,6 +360,9 @@ (define* (emacs-byte-compile-directory dir) (list (search-path-specification (variable "EMACSLOADPATH") (files '("share/emacs/site-lisp"))) + (search-path-specification + (variable "EMACSNATIVELOADPATH") + (files '("lib/emacs/native-site-lisp"))) (search-path-specification (variable "INFOPATH") (files '("share/info"))))) @@ -377,12 +433,16 @@ (define-public emacs-minimal (arguments (substitute-keyword-arguments (package-arguments emacs) ((#:configure-flags flags #~'()) - #~(list "--with-gnutls=no" "--disable-build-details")) + #~(list "--with-gnutls=no" "--with-native-compilation" + "--disable-build-details")) + ((#:modules _) (%emacs-modules build-system)) ((#:phases phases) #~(modify-phases #$phases (delete 'restore-emacs-pdmp) (delete 'strip-double-wrap))))) - (inputs (list ncurses coreutils gzip)) + (inputs (list ncurses coreutils gzip + (make-ld-wrapper "ld-wrapper" #:binutils binutils) + binutils glibc libgccjit zlib)) (native-inputs (list autoconf pkg-config)))) (define-public emacs-xwidgets @@ -395,6 +455,7 @@ (define-public emacs-xwidgets (substitute-keyword-arguments (package-arguments emacs) ((#:configure-flags flags #~'()) #~(cons "--with-xwidgets" #$flags)) + ((#:modules _) (%emacs-modules build-system)) ((#:phases phases) #~(modify-phases #$phases (delete 'restore-emacs-pdmp) @@ -419,6 +480,7 @@ (define-public emacs-no-x (substitute-keyword-arguments (package-arguments emacs) ((#:configure-flags flags #~'()) #~(delete "--with-cairo" #$flags)) + ((#:modules _) (%emacs-modules build-system)) ((#:phases phases) #~(modify-phases #$phases (delete 'restore-emacs-pdmp) @@ -437,6 +499,7 @@ (define-public emacs-no-x-toolkit (substitute-keyword-arguments (package-arguments emacs) ((#:configure-flags flags #~'()) #~(cons "--with-x-toolkit=no" #$flags)) + ((#:modules _) (%emacs-modules build-system)) ((#:phases phases) #~(modify-phases #$phases (delete 'restore-emacs-pdmp) -- 2.37.2