From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 wBokKeqs8mKswgAAbAwnHQ (envelope-from ) for ; Tue, 09 Aug 2022 20:52:26 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id WPU5KOqs8mIKjgAAG6o9tA (envelope-from ) for ; Tue, 09 Aug 2022 20:52:26 +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 4FA33395F2 for ; Tue, 9 Aug 2022 20:52:26 +0200 (CEST) Received: from localhost ([::1]:50236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLUL3-0000vl-H3 for larch@yhetil.org; Tue, 09 Aug 2022 14:52:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLUKj-0000pN-1W for guix-patches@gnu.org; Tue, 09 Aug 2022 14:52:08 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55269) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oLUKi-000265-GJ for guix-patches@gnu.org; Tue, 09 Aug 2022 14:52:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oLUKi-0003UJ-Ck for guix-patches@gnu.org; Tue, 09 Aug 2022 14:52:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57086] [PATCH 4/6] 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: Tue, 09 Aug 2022 18:52:04 +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.166007112313389 (code B ref 57086); Tue, 09 Aug 2022 18:52:04 +0000 Received: (at 57086) by debbugs.gnu.org; 9 Aug 2022 18:52:03 +0000 Received: from localhost ([127.0.0.1]:45014 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oLUKg-0003Th-GP for submit@debbugs.gnu.org; Tue, 09 Aug 2022 14:52:03 -0400 Received: from mail-ej1-f67.google.com ([209.85.218.67]:46619) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oLUKQ-0003S0-Ni for 57086@debbugs.gnu.org; Tue, 09 Aug 2022 14:51:52 -0400 Received: by mail-ej1-f67.google.com with SMTP id y13so23721492ejp.13 for <57086@debbugs.gnu.org>; Tue, 09 Aug 2022 11:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:date:subject:mime-version:to:content-transfer-encoding :message-id; bh=vIXn1YTjWBV2dpJfjS++khohfmDXUIxnzjr1/K22k38=; b=Jmq1mSHVbU9k2LSSkRfA8ysfOaGGvE+LvqoxcQy47DdSHSCEZs7Mo0s0CZmF/lfoEK tMYBbLnSXElQtChZHhfzoJIgbtV0aOEdnu7BIZLiojIyP44ifSQdz28FzIqejoBCNiSA 1KtrwcaIMpJ8qtY4AwaX3UzBIqneqrGJJ3zweH4SopUM3oSCQjt2UZGIH88BRFkjChPU Cne7kr03SGE0mtoKkKzJwUD2aegljKcvwtBxU3+jsCjjNIOQtlzLqWIgNIIn1KgOgrsJ I50JMgzvVZQgo9i4D4DI3tFRTYrgYbvFEP/+P46cUUofXba9nJanAEdWkH+L8Xn660li YoAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:date:subject:mime-version:to :content-transfer-encoding:message-id; bh=vIXn1YTjWBV2dpJfjS++khohfmDXUIxnzjr1/K22k38=; b=xwkOBq50qFMkTRR49Gikpue30zVJVVdTp3Nqo5TIsVxr259n6xWQWWRWRN6iw8CX2F uWtOtDyXS4C5dkQZXXg0B2mfqugWDca2l98G6PSbLS6wiyGYC47MYSZxTzT3VICDngS0 56YMp+hZDZmfWO6/j0g2vT6mfJ990sqCmg9JPUnIRbg/9UZ2c+/B0wjpGms2y7Gmwmy/ /82glggxcVLokD+5b2gFlziU4mGfQjdLva2hT3/dd78Y1fegrd8SqKA0IRxCgxVpCcV5 n0H2EexE4L9q0dKpOUcOrVD9eh0FDb7ZI3q6IU1fKPSAXcUqtZuXAFXx3xuCYNjwzKGX KuYg== X-Gm-Message-State: ACgBeo3Pt1WwzcptakMShw6nqUq2O1kePk8mfMs1CnE98PN9daX7gIgG 2oo4njNsbYEP8+sv613sW91brDzSGnA= X-Google-Smtp-Source: AA6agR7/LvDdki5eBukgutRJ8y4n00qKsfIWQ5Ybxd3icfZPFIuZBckgzBiT9Glgm55yU2IfyaLMUw== X-Received: by 2002:a17:907:b0d:b0:730:aa17:a0b7 with SMTP id h13-20020a1709070b0d00b00730aa17a0b7mr18166190ejl.661.1660071101073; Tue, 09 Aug 2022 11:51:41 -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 x24-20020a170906149800b00705cdfec71esm1422023ejc.7.2022.08.09.11.51.40 for <57086@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 11:51:40 -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=1660071146; 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=vIXn1YTjWBV2dpJfjS++khohfmDXUIxnzjr1/K22k38=; b=bob+gnAU4O690ooTBsC7VAtxNkqkEwvC85r9xIWDk4opIMipfzxApm3Pm2s9pmf5ycUvG9 Ao/lW/hYVAhyZUygLT0lKVkrKWKw7V1mwC85fyrOeUM4gKmjOmsll2kSdR4gDrBAyyvIKa KveRTRjC4JwNGuJhNQzoZ1epghJWxOJ/8OTdRN4i8tt1RGjKmtE6gGn0F3bZkKcy6p/cAy 8yFbuQwkY5ZCOdKCu9tsZzj82zt5ImDVlbtC5HuHm2rATtNupz5cmDXmUCaMnxat0p3doQ ZDOHr28JuDxYDiLReD+HqLYFSaytKeXKnAeihC2sU9QS+S2U2QIuQTVrK5Xw+A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1660071146; a=rsa-sha256; cv=none; b=lrx/wpgzkLJ+wfPjo9yXV8799vR7La6TByrSbpUSH1DieFpFQ7A0qdlxzIvhIihMx70ubb UpLy8kjsktrclcXyvLY3UzFEerIwhPg2am0OX3UhZQ+4PYwdpWlj3/9VfnusWpc0qvTOs2 FHJEw61RwxeDzzxL6HHgdWQImpth9qJuQbqwMOImtPLEpsokaNJz2/1b11lMX+lL+B2FUZ DfSpREKVz/5995ih9f5SqydrQp/WkeZe6iq5b9HYnFSnn6csU6mb0Hioz/49aOqOFRmXPU aIYKqmfl6AJldZO/3jGwwI+bDUH6NsVuHBmuAS6NOuWMmCTB9mewARDGZ6PFbw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=Jmq1mSHV; 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.51 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=Jmq1mSHV; 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: 4FA33395F2 X-Spam-Score: 5.51 X-Migadu-Scanner: scn0.migadu.com X-TUID: ctin3jfvkR/w * 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. (emacs-minimal, emacs-xwidgets, emacs-no-x) (emacs-no-x-toolkit): Adjust accordingly. --- gnu/packages/emacs.scm | 64 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm index ffd1eda08e..68afdb0446 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 @@ -377,12 +430,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 +452,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 +477,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 +496,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.0