Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] emacs: enable support for native-compilation.
@ 2022-04-14 14:25 leahneukirchen
  2022-04-14 14:47 ` [PR PATCH] [Updated] " leahneukirchen
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: leahneukirchen @ 2022-04-14 14:25 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 928 bytes --]

There is a new pull request by leahneukirchen against master on the void-packages repository

https://github.com/leahneukirchen/void-packages emacs-native-comp
https://github.com/void-linux/void-packages/pull/36690

emacs: enable support for native-compilation.
**Needs #28785 to be merged first, then rebased!**

Closes #36543.

This enables native-compilation and provides precompiled elisp files
for emacs-x11 and emacs-gtk3.  The plain console emacs stays without
support for native compilation to keep it lean, as native-compilation
pulls in libgccjit (27MB) and gcc (172MB + deps)
as well as emacs-common-eln (15MB).

On slow machines, native compilation can be disabled by setting
```(setq comp-deferred-compilation nil)```
in your .emacs.

#### Testing the changes
- I tested the changes in this PR: **briefly**


A patch file from https://github.com/void-linux/void-packages/pull/36690.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-emacs-native-comp-36690.patch --]
[-- Type: text/x-diff, Size: 18574 bytes --]

From 047534209578f13302e6fb93ce4c3aad504e2201 Mon Sep 17 00:00:00 2001
From: lane-brain <lane@mailbox.org>
Date: Wed, 13 Apr 2022 23:00:33 -0400
Subject: [PATCH 1/2] New package: libgccjit-10.2.1_pre1

---
 common/shlibs                                |   1 +
 srcpkgs/libgccjit-devel                      |   1 +
 srcpkgs/libgccjit/files/gccgo-musl.patch     |   1 +
 srcpkgs/libgccjit/files/libgccjit-musl.patch |  63 +++++
 srcpkgs/libgccjit/files/libgnarl-musl.patch  |   1 +
 srcpkgs/libgccjit/files/libssp-musl.patch    |   1 +
 srcpkgs/libgccjit/patches                    |   1 +
 srcpkgs/libgccjit/template                   | 235 +++++++++++++++++++
 srcpkgs/libgccjit/update                     |   2 +
 9 files changed, 306 insertions(+)
 create mode 120000 srcpkgs/libgccjit-devel
 create mode 120000 srcpkgs/libgccjit/files/gccgo-musl.patch
 create mode 100644 srcpkgs/libgccjit/files/libgccjit-musl.patch
 create mode 120000 srcpkgs/libgccjit/files/libgnarl-musl.patch
 create mode 120000 srcpkgs/libgccjit/files/libssp-musl.patch
 create mode 120000 srcpkgs/libgccjit/patches
 create mode 100644 srcpkgs/libgccjit/template
 create mode 100644 srcpkgs/libgccjit/update

diff --git a/common/shlibs b/common/shlibs
index fc5a031056fc..0b6a0ed91f3f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -59,6 +59,7 @@ libitm.so.1 libitm-4.7.3_1
 liblto_plugin.so.0 gcc-4.7.3_1
 libgcc_s.so.1 libgcc-4.4.0_1
 libgo.so.16 libgo-10.2.0_1
+libgccjit.so.0 libgccjit-10.2.1pre1_1
 libperl.so.5.34 perl-5.34.0_1
 libgmp.so.10 gmp-5.0.1_1
 libgmpxx.so.4 gmpxx-6.0.0_2
diff --git a/srcpkgs/libgccjit-devel b/srcpkgs/libgccjit-devel
new file mode 120000
index 000000000000..ad6b9f7639f3
--- /dev/null
+++ b/srcpkgs/libgccjit-devel
@@ -0,0 +1 @@
+libgccjit
\ No newline at end of file
diff --git a/srcpkgs/libgccjit/files/gccgo-musl.patch b/srcpkgs/libgccjit/files/gccgo-musl.patch
new file mode 120000
index 000000000000..a093af857738
--- /dev/null
+++ b/srcpkgs/libgccjit/files/gccgo-musl.patch
@@ -0,0 +1 @@
+../../gcc/files/gccgo-musl.patch
\ No newline at end of file
diff --git a/srcpkgs/libgccjit/files/libgccjit-musl.patch b/srcpkgs/libgccjit/files/libgccjit-musl.patch
new file mode 100644
index 000000000000..d2ed16928c82
--- /dev/null
+++ b/srcpkgs/libgccjit/files/libgccjit-musl.patch
@@ -0,0 +1,63 @@
+diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
+index 5bccf591a..35f5e35ef 100644
+--- a/gcc/jit/jit-playback.c
++++ b/gcc/jit/jit-playback.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "diagnostic.h"
+ #include "stmt.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-playback.h"
+ #include "jit-result.h"
+ #include "jit-builtins.h"
+diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
+index a237d574f..5785e3269 100644
+--- a/gcc/jit/jit-recording.c
++++ b/gcc/jit/jit-recording.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "pretty-print.h"
+ #include "toplev.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-builtins.h"
+ #include "jit-recording.h"
+ #include "jit-playback.h"
+diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
+index f9c33c63c..75f21d275 100644
+--- a/gcc/jit/libgccjit.c
++++ b/gcc/jit/libgccjit.c
+@@ -18,13 +18,13 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+ #include "timevar.h"
+ #include "typed-splay-tree.h"
+ #include "cppbuiltin.h"
+-#include <pthread.h>
+ 
+ #include "libgccjit.h"
+ #include "jit-recording.h"
diff --git a/srcpkgs/libgccjit/files/libgnarl-musl.patch b/srcpkgs/libgccjit/files/libgnarl-musl.patch
new file mode 120000
index 000000000000..33ccc9789f93
--- /dev/null
+++ b/srcpkgs/libgccjit/files/libgnarl-musl.patch
@@ -0,0 +1 @@
+../../gcc/files/libgnarl-musl.patch
\ No newline at end of file
diff --git a/srcpkgs/libgccjit/files/libssp-musl.patch b/srcpkgs/libgccjit/files/libssp-musl.patch
new file mode 120000
index 000000000000..37a7489360f8
--- /dev/null
+++ b/srcpkgs/libgccjit/files/libssp-musl.patch
@@ -0,0 +1 @@
+../../gcc/files/libssp-musl.patch
\ No newline at end of file
diff --git a/srcpkgs/libgccjit/patches b/srcpkgs/libgccjit/patches
new file mode 120000
index 000000000000..c42218ef09df
--- /dev/null
+++ b/srcpkgs/libgccjit/patches
@@ -0,0 +1 @@
+../gcc/patches
\ No newline at end of file
diff --git a/srcpkgs/libgccjit/template b/srcpkgs/libgccjit/template
new file mode 100644
index 000000000000..04bc7135d6de
--- /dev/null
+++ b/srcpkgs/libgccjit/template
@@ -0,0 +1,235 @@
+# Template file for 'libgccjit'
+# Revbump libtool when updating gcc, since it hardcodes some internal compiler paths
+# which use the version number.
+
+pkgname=libgccjit
+# we are using a 10-stable git snapshot alpine is using in order
+# to get regression fixes not yet incorporate into a stable release
+# it should be possible to switch back to stable with 10.3 or 11
+version=10.2.1pre1
+revision=1
+_patchver="${version%pre*}"
+_minorver="${_patchver%.*}"
+_majorver="${_minorver%.*}"
+_gmp_version=6.2.0
+_mpfr_version=4.1.0
+_mpc_version=1.1.0
+_isl_version=0.21
+wrksrc=gcc-${version/pre/_pre}
+short_desc="Just-In-Time Compilation library for GCC"
+maintainer="Lane Biocini <lane@mailbox.org>"
+homepage="http://gcc.gnu.org"
+license="GFDL-1.2-or-later, GPL-3.0-or-later, LGPL-2.1-or-later"
+# *-musl builders have issues fetching https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz
+distfiles="
+ https://dev.alpinelinux.org/~nenolod/gcc-${version/pre/_pre}.tar.xz
+ https://gmplib.org/download/gmp/gmp-${_gmp_version}.tar.xz
+ ${GNU_SITE}/mpfr/mpfr-${_mpfr_version}.tar.xz
+ ${GNU_SITE}/mpc/mpc-${_mpc_version}.tar.gz
+ ${SOURCEFORGE_SITE}/libisl/isl-${_isl_version}.tar.bz2"
+checksum="772cfd5d30eb9cc5a996fec9ba8cdcb45d37df1c9b5770610103b814b732c590
+ 258e6cd51b3fbdfc185c716d55f82c08aff57df0c6fbd143cf6ed561267a1526
+ 0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f
+ 6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e
+ d18ca11f8ad1a39ab6d03d3dcb3365ab416720fcb65b42d69f34f51bf0a0e859"
+
+nopie=yes
+lib32disabled=yes
+makedepends="zlib-devel"
+hostmakedepends="tar texinfo perl flex"
+depends="gcc"
+checkdepends="dejagnu"
+
+post_extract() {
+	mv ${XBPS_BUILDDIR}/gmp-${_gmp_version} ${wrksrc}/gmp
+	mv ${XBPS_BUILDDIR}/mpfr-${_mpfr_version} ${wrksrc}/mpfr
+	mv ${XBPS_BUILDDIR}/mpc-${_mpc_version} ${wrksrc}/mpc
+	mv ${XBPS_BUILDDIR}/isl-${_isl_version} ${wrksrc}/isl
+}
+
+pre_configure() {
+	# _FORTIFY_SOURCE needs an optimization level.
+	sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {gcc,libiberty}/configure
+
+	# Do not run fixincludes
+	sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
+
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		for p in ${FILESDIR}/*-musl.patch; do
+			patch -p1 -i $p
+		done
+	fi
+}
+
+do_configure() {
+	# Define triplet for gcc build target
+	case "$XBPS_TARGET_MACHINE" in
+		i686) _target_triplet="i686-pc-linux-gnu";;
+		i686-musl) _target_triplet="i686-linux-musl";;
+		x86_64) _target_triplet="x86_64-unknown-linux-gnu";;
+		x86_64-musl) _target_triplet="x86_64-linux-musl";;
+		armv5tel) _target_triplet="arm-linux-gnueabi";;
+		armv5tel-musl) _target_triplet="arm-linux-musleabi";;
+		armv6l) _target_triplet="arm-linux-gnueabihf";;
+		armv7l) _target_triplet="armv7l-linux-gnueabihf";;
+		armv6l-musl) _target_triplet="arm-linux-musleabihf";;
+		armv7l-musl) _target_triplet="armv7l-linux-musleabihf";;
+		aarch64) _target_triplet="aarch64-linux-gnu";;
+		aarch64-musl) _target_triplet="aarch64-linux-musl";;
+		ppc) _target_triplet="powerpc-linux-gnu";;
+		ppc-musl) _target_triplet="powerpc-linux-musl";;
+		ppcle) _target_triplet="powerpcle-linux-gnu";;
+		ppcle-musl) _target_triplet="powerpcle-linux-musl";;
+		ppc64le) _target_triplet="powerpc64le-linux-gnu";;
+		ppc64le-musl) _target_triplet="powerpc64le-linux-musl";;
+		ppc64) _target_triplet="powerpc64-linux-gnu";;
+		ppc64-musl) _target_triplet="powerpc64-linux-musl";;
+		mips-musl) _target_triplet="mips-linux-musl";;
+		mipshf-musl) _target_triplet="mips-linux-muslhf";;
+		mipsel-musl) _target_triplet="mipsel-linux-musl";;
+		mipselhf-musl) _target_triplet="mipsel-linux-muslhf";;
+	esac
+
+	local _langs _args _hash
+	_hash=gnu
+	case "$XBPS_TARGET_MACHINE" in
+		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard"; _hash=sysv;;
+		mipsel-musl) _args+=" --with-arch=mips32r2 --with-float=soft"; _hash=sysv;;
+		mipshf-musl) _args+=" --with-arch=mips32r2 --with-float=hard";;
+		mips-musl) _args+=" --with-arch=mips32r2 --with-float=soft";;
+		armv5*) _args+=" --with-arch=armv5te --with-float=soft";;
+		armv6l*) _args+=" --with-arch=armv6 --with-fpu=vfp --with-float=hard";;
+		armv7l*) _args+=" --with-arch=armv7-a --with-fpu=vfpv3 --with-float=hard";;
+		aarch64*) _args+=" --with-arch=armv8-a";;
+		ppc64le*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpcle-linux";;
+		ppc64*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpc-linux";;
+		ppc*) _args+=" --enable-secureplt";;
+	esac
+
+	# fix: unknown long double size, cannot define BFP_FMT
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*-musl) _args+=" --disable-decimal-float";;
+	esac
+
+	if [ "$CROSS_BUILD" ]; then
+		export CC_FOR_TARGET="$CC"
+		export GCC_FOR_TARGET="$CC"
+		export CXX_FOR_TARGET="$CXX"
+
+		_args+=" --host=$XBPS_CROSS_TRIPLET"
+		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
+	elif [ -z "$CHROOT_READY" ]; then
+		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
+		_args+=" --build=${_target_triplet}"
+	else
+		_args+=" --build=${_target_triplet}"
+	fi
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		_args+=" --disable-gnu-unique-object"
+		_args+=" --disable-symvers"
+		_args+=" libat_cv_have_ifunc=no"
+	else
+		_args+=" --enable-gnu-unique-object"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) _args+=" --disable-vtable-verify";;
+		*) _args+=" --enable-vtable-verify";;
+	esac
+
+	export CFLAGS="${CFLAGS/-D_FORTIFY_SOURCE=2/}"
+	export CXXFLAGS="${CXXFLAGS/-D_FORTIFY_SOURCE=2/}"
+
+	# Disable explicit -fno-PIE, gcc will figure this out itself.
+	export CFLAGS="${CFLAGS//-fno-PIE/}"
+	export CXXFLAGS="${CXXFLAGS//-fno-PIE/}"
+	export LDFLAGS="${LDFLAGS//-no-pie/}"
+
+	# Needs explicit -fPIC
+	export CFLAGS+=" -fPIC"
+	export CXXFLAGS+=" -fPIC"
+
+	_args+=" --prefix=/usr"
+	_args+=" --mandir=/usr/share/man"
+	_args+=" --infodir=/usr/share/info"
+	_args+=" --libexecdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --libdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --enable-threads=posix"
+	_args+=" --enable-__cxa_atexit"
+	_args+=" --disable-multilib"
+	_args+=" --with-system-zlib"
+	_args+=" --enable-shared"
+	_args+=" --enable-lto"
+	_args+=" --enable-plugins"
+	_args+=" --enable-linker-build-id"
+	_args+=" --disable-werror"
+	_args+=" --disable-nls"
+	_args+=" --enable-default-pie"
+	_args+=" --enable-default-ssp"
+	_args+=" --enable-checking=release"
+	_args+=" --disable-libstdcxx-pch"
+	_args+=" --with-isl"
+	_args+=" --with-linker-hash-style=$_hash"
+	_args+=" --disable-sjlj-exceptions"
+	_args+=" --disable-target-libiberty"
+
+	# libgccjit compilation specific
+	_args+=" --enable-host-shared"
+	_args+=" --disable-bootstrap"
+	_args+=" --disable-libquadmath"
+	_args+=" --disable-libquadmath-support"
+	_args+=" --disable-libgomp"
+	_args+=" --disable-liboffloadmic"
+	_args+=" --disable-libada"
+	_args+=" --disable-libvtv"
+	_args+=" --disable-libsanitizer"
+	_args+=" --with-bugurl='https://github.com/void-linux/void-packages/issues'"
+
+	mkdir -p build
+	cd build
+
+	# If we are checking packages, we need to have c++ compiled
+	[ -z "$XBPS_CHECK_PKGS" ] && _langs="jit" || _langs="jit,c++"
+	_args+=" --enable-languages=${_langs}"
+	CONFIG_SHELL=/bin/bash \
+		${wrksrc}/configure ${_args}
+}
+
+do_build() {
+	cd build
+	make ${makejobs}
+}
+
+do_check() {
+	cd "${wrksrc}/build/gcc"
+	make check-jit RUNTESTFLAGS="-v -v -v"
+}
+
+pre_install() {
+	if [ "$CROSS_BUILD" ]; then
+		# XXX otherwise links to host libpthread
+		for f in $(find ${wrksrc}/build/${XBPS_CROSS_TRIPLET} -type f -name libtool); do
+			sed -e "s,add_dir=\"-L\$libdir\",add_dir=\"-L${XBPS_CROSS_BASE}\$libdir\",g" -i $f
+		done
+	fi
+}
+
+do_install() {
+	cd "${wrksrc}/build"
+	make DESTDIR=${DESTDIR} -C gcc jit.install-common jit.install-info
+}
+
+post_install() {
+	vlicense ${wrksrc}/COPYING.RUNTIME RUNTIME.LIBRARY.EXCEPTION
+}
+
+libgccjit-devel_package() {
+	short_desc+=" - development files"
+	depends="${sourcepkg}>=${version}_${revision}"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/*.so
+		vmove usr/share/info
+	}
+}
diff --git a/srcpkgs/libgccjit/update b/srcpkgs/libgccjit/update
new file mode 100644
index 000000000000..fb8dd58f2044
--- /dev/null
+++ b/srcpkgs/libgccjit/update
@@ -0,0 +1,2 @@
+site="https://gcc.gnu.org/releases.html"
+pattern="GCC \K[\d.]+(?=\<)"

From 64896e6de214cf3a5ad46b5f1f7cee2f5b3be03f Mon Sep 17 00:00:00 2001
From: Leah Neukirchen <leah@vuxu.org>
Date: Thu, 14 Apr 2022 15:54:16 +0200
Subject: [PATCH 2/2] emacs: enable support for native-compilation.

This enables native-compilation and provides precompiled elisp files
for emacs-x11 and emacs-gtk3.  The plain console emacs stays without
support for native compilation to keep it lean, as native-compilation
pulls in libgccjit (27MB) and gcc (172MB + deps)
as well as emacs-common-eln (15MB).

On slow machines, native compilation can be disabled by setting
(setq comp-deferred-compilation nil)
in your .emacs.
---
 srcpkgs/emacs/template | 46 +++++++++++++++++++++++++++++++++---------
 1 file changed, 36 insertions(+), 10 deletions(-)

diff --git a/srcpkgs/emacs/template b/srcpkgs/emacs/template
index 644e44cf4d06..aae0e3f6d225 100644
--- a/srcpkgs/emacs/template
+++ b/srcpkgs/emacs/template
@@ -1,13 +1,14 @@
 # Template file for 'emacs'
 pkgname=emacs
 version=28.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--with-file-notification=inotify --with-modules
  $(vopt_with jpeg) $(vopt_with tiff) $(vopt_with gif) $(vopt_with png)
  $(vopt_with xpm) $(vopt_with svg rsvg) $(vopt_with imagemagick)
  $(vopt_with xml xml2) $(vopt_with gnutls) $(vopt_with sound) $(vopt_with m17n m17n-flt)
- $(vopt_with json) $(vopt_with harfbuzz) $(vopt_with cairo) $(vopt_with gmp libgmp)"
+ $(vopt_with json) $(vopt_with harfbuzz) $(vopt_with cairo) $(vopt_with gmp libgmp)
+ $(vopt_with nativecomp native-compilation)"
 hostmakedepends="pkg-config tar"
 makedepends="ncurses-devel libXaw-devel gtk+3-devel webkit2gtk-devel
  dbus-devel acl-devel
@@ -17,7 +18,8 @@ makedepends="ncurses-devel libXaw-devel gtk+3-devel webkit2gtk-devel
  $(vopt_if xml libxml2-devel) $(vopt_if gnutls gnutls-devel)
  $(vopt_if sound alsa-lib-devel) $(vopt_if m17n m17n-lib-devel)
  $(vopt_if json jansson-devel) $(vopt_if harfbuzz harfbuzz-devel)
- $(vopt_if cairo cairo-devel) $(vopt_if gmp gmp-devel)"
+ $(vopt_if cairo cairo-devel) $(vopt_if gmp gmp-devel)
+ $(vopt_if nativecomp libgccjit-devel)"
 depends="emacs-common-${version}_${revision}"
 short_desc="GNU Emacs editor"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
@@ -29,12 +31,16 @@ nocross=yes
 nopie=yes
 
 # Package build options
-build_options="jpeg tiff gif png xpm svg xml imagemagick gnutls sound m17n dbus json harfbuzz cairo gmp"
-desc_option_xpm="Enable support for XPM images"
-desc_option_sound="Enable support for sound"
+build_options="jpeg tiff gif png xpm svg xml imagemagick gnutls sound m17n dbus json harfbuzz cairo gmp nativecomp"
+desc_option_cairo="Enable support for drawing with Cairo"
+desc_option_gmp="Enable support for big numbers using GMP"
+desc_option_json="Enable support for native JSON parsing"
 desc_option_m17n="Enable support for m17n multilingual text processing"
-build_options_default="cairo gif gmp gnutls harfbuzz jpeg json m17n png sound
- svg tiff xml xpm"
+desc_option_nativecomp="Enable support for native compilation"
+desc_option_sound="Enable support for sound"
+desc_option_xpm="Enable support for XPM images"
+build_options_default="cairo gif gmp gnutls harfbuzz jpeg json m17n nativecomp
+ png sound svg tiff xml xpm"
 
 pre_configure() {
 	# Just configuring in different directories results in
@@ -47,7 +53,8 @@ pre_configure() {
 
 do_configure() {
 	cd $wrksrc/nox
-	./configure --without-x $(vopt_with dbus) ${configure_args}
+	./configure --without-x $(vopt_with dbus) ${configure_args} \
+		--without-native-compilation
 
 	cd $wrksrc/x11
 	./configure --with-x-toolkit=athena --without-toolkit-scroll-bars \
@@ -60,12 +67,13 @@ do_configure() {
 
 do_build() {
 	make ${makejobs} -C nox
-	make ${makejobs} -C x11
+	make ${makejobs} -C x11 $(vopt_if nativecomp NATIVE_FULL_AOT=1)
 	make ${makejobs} -C gtk3
 }
 
 do_install() {
 	make DESTDIR=$DESTDIR -C ${wrksrc}/nox install
+	make DESTDIR=$DESTDIR -C ${wrksrc}/x11 install-eln
 	rm -f ${DESTDIR}/usr/bin/ctags
 	rm -f ${DESTDIR}/usr/lib/systemd/user/emacs.service
 	rm -f ${DESTDIR}/usr/share/man/man1/ctags.1*
@@ -84,8 +92,23 @@ emacs-common_package() {
 	}
 }
 
+emacs-common-eln_package() {
+	short_desc+=" - common precompiled elisp"
+	if [ -z "$build_option_nativecomp" ]; then
+		build_style=meta
+	fi
+	pkg_install() {
+		if [ "$build_option_nativecomp" ]; then
+			vmove usr/lib/emacs
+		fi
+	}
+}
+
 emacs-x11_package() {
 	depends="emacs-common-${version}_${revision}"
+	if [ "$build_option_nativecomp" ]; then
+		depends+=" emacs-common-eln-${version}_${revision}"
+	fi
 	provides="emacs-${version}_${revision}"
 	replaces="emacs>=0"
 	short_desc+=" - X11 version"
@@ -99,6 +122,9 @@ emacs-x11_package() {
 
 emacs-gtk3_package() {
 	depends="emacs-common-${version}_${revision} desktop-file-utils hicolor-icon-theme"
+	if [ "$build_option_nativecomp" ]; then
+		depends+=" emacs-common-eln-${version}_${revision}"
+	fi
 	provides="emacs-${version}_${revision}"
 	replaces="emacs>=0"
 	short_desc+=" - GTK+3 version"

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PR PATCH] [Updated] emacs: enable support for native-compilation.
  2022-04-14 14:25 [PR PATCH] emacs: enable support for native-compilation leahneukirchen
@ 2022-04-14 14:47 ` leahneukirchen
  2022-04-14 20:10 ` KSPAtlas
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: leahneukirchen @ 2022-04-14 14:47 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 933 bytes --]

There is an updated pull request by leahneukirchen against master on the void-packages repository

https://github.com/leahneukirchen/void-packages emacs-native-comp
https://github.com/void-linux/void-packages/pull/36690

emacs: enable support for native-compilation.
**Needs #28785 to be merged first, then rebased!**

Closes #36543.

This enables native-compilation and provides precompiled elisp files
for emacs-x11 and emacs-gtk3.  The plain console emacs stays without
support for native compilation to keep it lean, as native-compilation
pulls in libgccjit (27MB) and gcc (172MB + deps)
as well as emacs-common-eln (15MB).

On slow machines, native compilation can be disabled by setting
```(setq comp-deferred-compilation nil)```
in your .emacs.

#### Testing the changes
- I tested the changes in this PR: **briefly**


A patch file from https://github.com/void-linux/void-packages/pull/36690.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-emacs-native-comp-36690.patch --]
[-- Type: text/x-diff, Size: 18866 bytes --]

From 047534209578f13302e6fb93ce4c3aad504e2201 Mon Sep 17 00:00:00 2001
From: lane-brain <lane@mailbox.org>
Date: Wed, 13 Apr 2022 23:00:33 -0400
Subject: [PATCH 1/2] New package: libgccjit-10.2.1_pre1

---
 common/shlibs                                |   1 +
 srcpkgs/libgccjit-devel                      |   1 +
 srcpkgs/libgccjit/files/gccgo-musl.patch     |   1 +
 srcpkgs/libgccjit/files/libgccjit-musl.patch |  63 +++++
 srcpkgs/libgccjit/files/libgnarl-musl.patch  |   1 +
 srcpkgs/libgccjit/files/libssp-musl.patch    |   1 +
 srcpkgs/libgccjit/patches                    |   1 +
 srcpkgs/libgccjit/template                   | 235 +++++++++++++++++++
 srcpkgs/libgccjit/update                     |   2 +
 9 files changed, 306 insertions(+)
 create mode 120000 srcpkgs/libgccjit-devel
 create mode 120000 srcpkgs/libgccjit/files/gccgo-musl.patch
 create mode 100644 srcpkgs/libgccjit/files/libgccjit-musl.patch
 create mode 120000 srcpkgs/libgccjit/files/libgnarl-musl.patch
 create mode 120000 srcpkgs/libgccjit/files/libssp-musl.patch
 create mode 120000 srcpkgs/libgccjit/patches
 create mode 100644 srcpkgs/libgccjit/template
 create mode 100644 srcpkgs/libgccjit/update

diff --git a/common/shlibs b/common/shlibs
index fc5a031056fc..0b6a0ed91f3f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -59,6 +59,7 @@ libitm.so.1 libitm-4.7.3_1
 liblto_plugin.so.0 gcc-4.7.3_1
 libgcc_s.so.1 libgcc-4.4.0_1
 libgo.so.16 libgo-10.2.0_1
+libgccjit.so.0 libgccjit-10.2.1pre1_1
 libperl.so.5.34 perl-5.34.0_1
 libgmp.so.10 gmp-5.0.1_1
 libgmpxx.so.4 gmpxx-6.0.0_2
diff --git a/srcpkgs/libgccjit-devel b/srcpkgs/libgccjit-devel
new file mode 120000
index 000000000000..ad6b9f7639f3
--- /dev/null
+++ b/srcpkgs/libgccjit-devel
@@ -0,0 +1 @@
+libgccjit
\ No newline at end of file
diff --git a/srcpkgs/libgccjit/files/gccgo-musl.patch b/srcpkgs/libgccjit/files/gccgo-musl.patch
new file mode 120000
index 000000000000..a093af857738
--- /dev/null
+++ b/srcpkgs/libgccjit/files/gccgo-musl.patch
@@ -0,0 +1 @@
+../../gcc/files/gccgo-musl.patch
\ No newline at end of file
diff --git a/srcpkgs/libgccjit/files/libgccjit-musl.patch b/srcpkgs/libgccjit/files/libgccjit-musl.patch
new file mode 100644
index 000000000000..d2ed16928c82
--- /dev/null
+++ b/srcpkgs/libgccjit/files/libgccjit-musl.patch
@@ -0,0 +1,63 @@
+diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
+index 5bccf591a..35f5e35ef 100644
+--- a/gcc/jit/jit-playback.c
++++ b/gcc/jit/jit-playback.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "diagnostic.h"
+ #include "stmt.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-playback.h"
+ #include "jit-result.h"
+ #include "jit-builtins.h"
+diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
+index a237d574f..5785e3269 100644
+--- a/gcc/jit/jit-recording.c
++++ b/gcc/jit/jit-recording.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "pretty-print.h"
+ #include "toplev.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-builtins.h"
+ #include "jit-recording.h"
+ #include "jit-playback.h"
+diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
+index f9c33c63c..75f21d275 100644
+--- a/gcc/jit/libgccjit.c
++++ b/gcc/jit/libgccjit.c
+@@ -18,13 +18,13 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+ #include "timevar.h"
+ #include "typed-splay-tree.h"
+ #include "cppbuiltin.h"
+-#include <pthread.h>
+ 
+ #include "libgccjit.h"
+ #include "jit-recording.h"
diff --git a/srcpkgs/libgccjit/files/libgnarl-musl.patch b/srcpkgs/libgccjit/files/libgnarl-musl.patch
new file mode 120000
index 000000000000..33ccc9789f93
--- /dev/null
+++ b/srcpkgs/libgccjit/files/libgnarl-musl.patch
@@ -0,0 +1 @@
+../../gcc/files/libgnarl-musl.patch
\ No newline at end of file
diff --git a/srcpkgs/libgccjit/files/libssp-musl.patch b/srcpkgs/libgccjit/files/libssp-musl.patch
new file mode 120000
index 000000000000..37a7489360f8
--- /dev/null
+++ b/srcpkgs/libgccjit/files/libssp-musl.patch
@@ -0,0 +1 @@
+../../gcc/files/libssp-musl.patch
\ No newline at end of file
diff --git a/srcpkgs/libgccjit/patches b/srcpkgs/libgccjit/patches
new file mode 120000
index 000000000000..c42218ef09df
--- /dev/null
+++ b/srcpkgs/libgccjit/patches
@@ -0,0 +1 @@
+../gcc/patches
\ No newline at end of file
diff --git a/srcpkgs/libgccjit/template b/srcpkgs/libgccjit/template
new file mode 100644
index 000000000000..04bc7135d6de
--- /dev/null
+++ b/srcpkgs/libgccjit/template
@@ -0,0 +1,235 @@
+# Template file for 'libgccjit'
+# Revbump libtool when updating gcc, since it hardcodes some internal compiler paths
+# which use the version number.
+
+pkgname=libgccjit
+# we are using a 10-stable git snapshot alpine is using in order
+# to get regression fixes not yet incorporate into a stable release
+# it should be possible to switch back to stable with 10.3 or 11
+version=10.2.1pre1
+revision=1
+_patchver="${version%pre*}"
+_minorver="${_patchver%.*}"
+_majorver="${_minorver%.*}"
+_gmp_version=6.2.0
+_mpfr_version=4.1.0
+_mpc_version=1.1.0
+_isl_version=0.21
+wrksrc=gcc-${version/pre/_pre}
+short_desc="Just-In-Time Compilation library for GCC"
+maintainer="Lane Biocini <lane@mailbox.org>"
+homepage="http://gcc.gnu.org"
+license="GFDL-1.2-or-later, GPL-3.0-or-later, LGPL-2.1-or-later"
+# *-musl builders have issues fetching https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz
+distfiles="
+ https://dev.alpinelinux.org/~nenolod/gcc-${version/pre/_pre}.tar.xz
+ https://gmplib.org/download/gmp/gmp-${_gmp_version}.tar.xz
+ ${GNU_SITE}/mpfr/mpfr-${_mpfr_version}.tar.xz
+ ${GNU_SITE}/mpc/mpc-${_mpc_version}.tar.gz
+ ${SOURCEFORGE_SITE}/libisl/isl-${_isl_version}.tar.bz2"
+checksum="772cfd5d30eb9cc5a996fec9ba8cdcb45d37df1c9b5770610103b814b732c590
+ 258e6cd51b3fbdfc185c716d55f82c08aff57df0c6fbd143cf6ed561267a1526
+ 0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f
+ 6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e
+ d18ca11f8ad1a39ab6d03d3dcb3365ab416720fcb65b42d69f34f51bf0a0e859"
+
+nopie=yes
+lib32disabled=yes
+makedepends="zlib-devel"
+hostmakedepends="tar texinfo perl flex"
+depends="gcc"
+checkdepends="dejagnu"
+
+post_extract() {
+	mv ${XBPS_BUILDDIR}/gmp-${_gmp_version} ${wrksrc}/gmp
+	mv ${XBPS_BUILDDIR}/mpfr-${_mpfr_version} ${wrksrc}/mpfr
+	mv ${XBPS_BUILDDIR}/mpc-${_mpc_version} ${wrksrc}/mpc
+	mv ${XBPS_BUILDDIR}/isl-${_isl_version} ${wrksrc}/isl
+}
+
+pre_configure() {
+	# _FORTIFY_SOURCE needs an optimization level.
+	sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {gcc,libiberty}/configure
+
+	# Do not run fixincludes
+	sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
+
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		for p in ${FILESDIR}/*-musl.patch; do
+			patch -p1 -i $p
+		done
+	fi
+}
+
+do_configure() {
+	# Define triplet for gcc build target
+	case "$XBPS_TARGET_MACHINE" in
+		i686) _target_triplet="i686-pc-linux-gnu";;
+		i686-musl) _target_triplet="i686-linux-musl";;
+		x86_64) _target_triplet="x86_64-unknown-linux-gnu";;
+		x86_64-musl) _target_triplet="x86_64-linux-musl";;
+		armv5tel) _target_triplet="arm-linux-gnueabi";;
+		armv5tel-musl) _target_triplet="arm-linux-musleabi";;
+		armv6l) _target_triplet="arm-linux-gnueabihf";;
+		armv7l) _target_triplet="armv7l-linux-gnueabihf";;
+		armv6l-musl) _target_triplet="arm-linux-musleabihf";;
+		armv7l-musl) _target_triplet="armv7l-linux-musleabihf";;
+		aarch64) _target_triplet="aarch64-linux-gnu";;
+		aarch64-musl) _target_triplet="aarch64-linux-musl";;
+		ppc) _target_triplet="powerpc-linux-gnu";;
+		ppc-musl) _target_triplet="powerpc-linux-musl";;
+		ppcle) _target_triplet="powerpcle-linux-gnu";;
+		ppcle-musl) _target_triplet="powerpcle-linux-musl";;
+		ppc64le) _target_triplet="powerpc64le-linux-gnu";;
+		ppc64le-musl) _target_triplet="powerpc64le-linux-musl";;
+		ppc64) _target_triplet="powerpc64-linux-gnu";;
+		ppc64-musl) _target_triplet="powerpc64-linux-musl";;
+		mips-musl) _target_triplet="mips-linux-musl";;
+		mipshf-musl) _target_triplet="mips-linux-muslhf";;
+		mipsel-musl) _target_triplet="mipsel-linux-musl";;
+		mipselhf-musl) _target_triplet="mipsel-linux-muslhf";;
+	esac
+
+	local _langs _args _hash
+	_hash=gnu
+	case "$XBPS_TARGET_MACHINE" in
+		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard"; _hash=sysv;;
+		mipsel-musl) _args+=" --with-arch=mips32r2 --with-float=soft"; _hash=sysv;;
+		mipshf-musl) _args+=" --with-arch=mips32r2 --with-float=hard";;
+		mips-musl) _args+=" --with-arch=mips32r2 --with-float=soft";;
+		armv5*) _args+=" --with-arch=armv5te --with-float=soft";;
+		armv6l*) _args+=" --with-arch=armv6 --with-fpu=vfp --with-float=hard";;
+		armv7l*) _args+=" --with-arch=armv7-a --with-fpu=vfpv3 --with-float=hard";;
+		aarch64*) _args+=" --with-arch=armv8-a";;
+		ppc64le*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpcle-linux";;
+		ppc64*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpc-linux";;
+		ppc*) _args+=" --enable-secureplt";;
+	esac
+
+	# fix: unknown long double size, cannot define BFP_FMT
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*-musl) _args+=" --disable-decimal-float";;
+	esac
+
+	if [ "$CROSS_BUILD" ]; then
+		export CC_FOR_TARGET="$CC"
+		export GCC_FOR_TARGET="$CC"
+		export CXX_FOR_TARGET="$CXX"
+
+		_args+=" --host=$XBPS_CROSS_TRIPLET"
+		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
+	elif [ -z "$CHROOT_READY" ]; then
+		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
+		_args+=" --build=${_target_triplet}"
+	else
+		_args+=" --build=${_target_triplet}"
+	fi
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		_args+=" --disable-gnu-unique-object"
+		_args+=" --disable-symvers"
+		_args+=" libat_cv_have_ifunc=no"
+	else
+		_args+=" --enable-gnu-unique-object"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) _args+=" --disable-vtable-verify";;
+		*) _args+=" --enable-vtable-verify";;
+	esac
+
+	export CFLAGS="${CFLAGS/-D_FORTIFY_SOURCE=2/}"
+	export CXXFLAGS="${CXXFLAGS/-D_FORTIFY_SOURCE=2/}"
+
+	# Disable explicit -fno-PIE, gcc will figure this out itself.
+	export CFLAGS="${CFLAGS//-fno-PIE/}"
+	export CXXFLAGS="${CXXFLAGS//-fno-PIE/}"
+	export LDFLAGS="${LDFLAGS//-no-pie/}"
+
+	# Needs explicit -fPIC
+	export CFLAGS+=" -fPIC"
+	export CXXFLAGS+=" -fPIC"
+
+	_args+=" --prefix=/usr"
+	_args+=" --mandir=/usr/share/man"
+	_args+=" --infodir=/usr/share/info"
+	_args+=" --libexecdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --libdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --enable-threads=posix"
+	_args+=" --enable-__cxa_atexit"
+	_args+=" --disable-multilib"
+	_args+=" --with-system-zlib"
+	_args+=" --enable-shared"
+	_args+=" --enable-lto"
+	_args+=" --enable-plugins"
+	_args+=" --enable-linker-build-id"
+	_args+=" --disable-werror"
+	_args+=" --disable-nls"
+	_args+=" --enable-default-pie"
+	_args+=" --enable-default-ssp"
+	_args+=" --enable-checking=release"
+	_args+=" --disable-libstdcxx-pch"
+	_args+=" --with-isl"
+	_args+=" --with-linker-hash-style=$_hash"
+	_args+=" --disable-sjlj-exceptions"
+	_args+=" --disable-target-libiberty"
+
+	# libgccjit compilation specific
+	_args+=" --enable-host-shared"
+	_args+=" --disable-bootstrap"
+	_args+=" --disable-libquadmath"
+	_args+=" --disable-libquadmath-support"
+	_args+=" --disable-libgomp"
+	_args+=" --disable-liboffloadmic"
+	_args+=" --disable-libada"
+	_args+=" --disable-libvtv"
+	_args+=" --disable-libsanitizer"
+	_args+=" --with-bugurl='https://github.com/void-linux/void-packages/issues'"
+
+	mkdir -p build
+	cd build
+
+	# If we are checking packages, we need to have c++ compiled
+	[ -z "$XBPS_CHECK_PKGS" ] && _langs="jit" || _langs="jit,c++"
+	_args+=" --enable-languages=${_langs}"
+	CONFIG_SHELL=/bin/bash \
+		${wrksrc}/configure ${_args}
+}
+
+do_build() {
+	cd build
+	make ${makejobs}
+}
+
+do_check() {
+	cd "${wrksrc}/build/gcc"
+	make check-jit RUNTESTFLAGS="-v -v -v"
+}
+
+pre_install() {
+	if [ "$CROSS_BUILD" ]; then
+		# XXX otherwise links to host libpthread
+		for f in $(find ${wrksrc}/build/${XBPS_CROSS_TRIPLET} -type f -name libtool); do
+			sed -e "s,add_dir=\"-L\$libdir\",add_dir=\"-L${XBPS_CROSS_BASE}\$libdir\",g" -i $f
+		done
+	fi
+}
+
+do_install() {
+	cd "${wrksrc}/build"
+	make DESTDIR=${DESTDIR} -C gcc jit.install-common jit.install-info
+}
+
+post_install() {
+	vlicense ${wrksrc}/COPYING.RUNTIME RUNTIME.LIBRARY.EXCEPTION
+}
+
+libgccjit-devel_package() {
+	short_desc+=" - development files"
+	depends="${sourcepkg}>=${version}_${revision}"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/*.so
+		vmove usr/share/info
+	}
+}
diff --git a/srcpkgs/libgccjit/update b/srcpkgs/libgccjit/update
new file mode 100644
index 000000000000..fb8dd58f2044
--- /dev/null
+++ b/srcpkgs/libgccjit/update
@@ -0,0 +1,2 @@
+site="https://gcc.gnu.org/releases.html"
+pattern="GCC \K[\d.]+(?=\<)"

From 3939864ef0a97e426253c3fee511b790456923b1 Mon Sep 17 00:00:00 2001
From: Leah Neukirchen <leah@vuxu.org>
Date: Thu, 14 Apr 2022 15:54:16 +0200
Subject: [PATCH 2/2] emacs: enable support for native-compilation.

This enables native-compilation and provides precompiled elisp files
for emacs-x11 and emacs-gtk3.  The plain console emacs stays without
support for native compilation to keep it lean, as native-compilation
pulls in libgccjit (27MB) and gcc (172MB + deps)
as well as emacs-common-eln (15MB).

On slow machines, native compilation can be disabled by setting
(setq comp-deferred-compilation nil)
in your .emacs.
---
 srcpkgs/emacs-common-eln |  1 +
 srcpkgs/emacs/template   | 46 +++++++++++++++++++++++++++++++---------
 2 files changed, 37 insertions(+), 10 deletions(-)
 create mode 120000 srcpkgs/emacs-common-eln

diff --git a/srcpkgs/emacs-common-eln b/srcpkgs/emacs-common-eln
new file mode 120000
index 000000000000..a7642dd168d6
--- /dev/null
+++ b/srcpkgs/emacs-common-eln
@@ -0,0 +1 @@
+emacs
\ No newline at end of file
diff --git a/srcpkgs/emacs/template b/srcpkgs/emacs/template
index 644e44cf4d06..aae0e3f6d225 100644
--- a/srcpkgs/emacs/template
+++ b/srcpkgs/emacs/template
@@ -1,13 +1,14 @@
 # Template file for 'emacs'
 pkgname=emacs
 version=28.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--with-file-notification=inotify --with-modules
  $(vopt_with jpeg) $(vopt_with tiff) $(vopt_with gif) $(vopt_with png)
  $(vopt_with xpm) $(vopt_with svg rsvg) $(vopt_with imagemagick)
  $(vopt_with xml xml2) $(vopt_with gnutls) $(vopt_with sound) $(vopt_with m17n m17n-flt)
- $(vopt_with json) $(vopt_with harfbuzz) $(vopt_with cairo) $(vopt_with gmp libgmp)"
+ $(vopt_with json) $(vopt_with harfbuzz) $(vopt_with cairo) $(vopt_with gmp libgmp)
+ $(vopt_with nativecomp native-compilation)"
 hostmakedepends="pkg-config tar"
 makedepends="ncurses-devel libXaw-devel gtk+3-devel webkit2gtk-devel
  dbus-devel acl-devel
@@ -17,7 +18,8 @@ makedepends="ncurses-devel libXaw-devel gtk+3-devel webkit2gtk-devel
  $(vopt_if xml libxml2-devel) $(vopt_if gnutls gnutls-devel)
  $(vopt_if sound alsa-lib-devel) $(vopt_if m17n m17n-lib-devel)
  $(vopt_if json jansson-devel) $(vopt_if harfbuzz harfbuzz-devel)
- $(vopt_if cairo cairo-devel) $(vopt_if gmp gmp-devel)"
+ $(vopt_if cairo cairo-devel) $(vopt_if gmp gmp-devel)
+ $(vopt_if nativecomp libgccjit-devel)"
 depends="emacs-common-${version}_${revision}"
 short_desc="GNU Emacs editor"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
@@ -29,12 +31,16 @@ nocross=yes
 nopie=yes
 
 # Package build options
-build_options="jpeg tiff gif png xpm svg xml imagemagick gnutls sound m17n dbus json harfbuzz cairo gmp"
-desc_option_xpm="Enable support for XPM images"
-desc_option_sound="Enable support for sound"
+build_options="jpeg tiff gif png xpm svg xml imagemagick gnutls sound m17n dbus json harfbuzz cairo gmp nativecomp"
+desc_option_cairo="Enable support for drawing with Cairo"
+desc_option_gmp="Enable support for big numbers using GMP"
+desc_option_json="Enable support for native JSON parsing"
 desc_option_m17n="Enable support for m17n multilingual text processing"
-build_options_default="cairo gif gmp gnutls harfbuzz jpeg json m17n png sound
- svg tiff xml xpm"
+desc_option_nativecomp="Enable support for native compilation"
+desc_option_sound="Enable support for sound"
+desc_option_xpm="Enable support for XPM images"
+build_options_default="cairo gif gmp gnutls harfbuzz jpeg json m17n nativecomp
+ png sound svg tiff xml xpm"
 
 pre_configure() {
 	# Just configuring in different directories results in
@@ -47,7 +53,8 @@ pre_configure() {
 
 do_configure() {
 	cd $wrksrc/nox
-	./configure --without-x $(vopt_with dbus) ${configure_args}
+	./configure --without-x $(vopt_with dbus) ${configure_args} \
+		--without-native-compilation
 
 	cd $wrksrc/x11
 	./configure --with-x-toolkit=athena --without-toolkit-scroll-bars \
@@ -60,12 +67,13 @@ do_configure() {
 
 do_build() {
 	make ${makejobs} -C nox
-	make ${makejobs} -C x11
+	make ${makejobs} -C x11 $(vopt_if nativecomp NATIVE_FULL_AOT=1)
 	make ${makejobs} -C gtk3
 }
 
 do_install() {
 	make DESTDIR=$DESTDIR -C ${wrksrc}/nox install
+	make DESTDIR=$DESTDIR -C ${wrksrc}/x11 install-eln
 	rm -f ${DESTDIR}/usr/bin/ctags
 	rm -f ${DESTDIR}/usr/lib/systemd/user/emacs.service
 	rm -f ${DESTDIR}/usr/share/man/man1/ctags.1*
@@ -84,8 +92,23 @@ emacs-common_package() {
 	}
 }
 
+emacs-common-eln_package() {
+	short_desc+=" - common precompiled elisp"
+	if [ -z "$build_option_nativecomp" ]; then
+		build_style=meta
+	fi
+	pkg_install() {
+		if [ "$build_option_nativecomp" ]; then
+			vmove usr/lib/emacs
+		fi
+	}
+}
+
 emacs-x11_package() {
 	depends="emacs-common-${version}_${revision}"
+	if [ "$build_option_nativecomp" ]; then
+		depends+=" emacs-common-eln-${version}_${revision}"
+	fi
 	provides="emacs-${version}_${revision}"
 	replaces="emacs>=0"
 	short_desc+=" - X11 version"
@@ -99,6 +122,9 @@ emacs-x11_package() {
 
 emacs-gtk3_package() {
 	depends="emacs-common-${version}_${revision} desktop-file-utils hicolor-icon-theme"
+	if [ "$build_option_nativecomp" ]; then
+		depends+=" emacs-common-eln-${version}_${revision}"
+	fi
 	provides="emacs-${version}_${revision}"
 	replaces="emacs>=0"
 	short_desc+=" - GTK+3 version"

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emacs: enable support for native-compilation.
  2022-04-14 14:25 [PR PATCH] emacs: enable support for native-compilation leahneukirchen
  2022-04-14 14:47 ` [PR PATCH] [Updated] " leahneukirchen
@ 2022-04-14 20:10 ` KSPAtlas
  2022-04-14 20:14 ` leahneukirchen
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: KSPAtlas @ 2022-04-14 20:10 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 167 bytes --]

New comment by KSPAtlas on void-packages repository

https://github.com/void-linux/void-packages/pull/36690#issuecomment-1099581736

Comment:
I hope this gets merged.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emacs: enable support for native-compilation.
  2022-04-14 14:25 [PR PATCH] emacs: enable support for native-compilation leahneukirchen
  2022-04-14 14:47 ` [PR PATCH] [Updated] " leahneukirchen
  2022-04-14 20:10 ` KSPAtlas
@ 2022-04-14 20:14 ` leahneukirchen
  2022-04-16 12:06 ` [PR PATCH] [Updated] " leahneukirchen
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: leahneukirchen @ 2022-04-14 20:14 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 167 bytes --]

New comment by KSPAtlas on void-packages repository

https://github.com/void-linux/void-packages/pull/36690#issuecomment-1099581736

Comment:
I hope this gets merged.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PR PATCH] [Updated] emacs: enable support for native-compilation.
  2022-04-14 14:25 [PR PATCH] emacs: enable support for native-compilation leahneukirchen
                   ` (2 preceding siblings ...)
  2022-04-14 20:14 ` leahneukirchen
@ 2022-04-16 12:06 ` leahneukirchen
  2022-04-16 14:05 ` [PR PATCH] [Merged]: " leahneukirchen
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: leahneukirchen @ 2022-04-16 12:06 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 933 bytes --]

There is an updated pull request by leahneukirchen against master on the void-packages repository

https://github.com/leahneukirchen/void-packages emacs-native-comp
https://github.com/void-linux/void-packages/pull/36690

emacs: enable support for native-compilation.
**Needs #28785 to be merged first, then rebased!**

Closes #36543.

This enables native-compilation and provides precompiled elisp files
for emacs-x11 and emacs-gtk3.  The plain console emacs stays without
support for native compilation to keep it lean, as native-compilation
pulls in libgccjit (27MB) and gcc (172MB + deps)
as well as emacs-common-eln (15MB).

On slow machines, native compilation can be disabled by setting
```(setq comp-deferred-compilation nil)```
in your .emacs.

#### Testing the changes
- I tested the changes in this PR: **briefly**


A patch file from https://github.com/void-linux/void-packages/pull/36690.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-emacs-native-comp-36690.patch --]
[-- Type: text/x-diff, Size: 5301 bytes --]

From 1f6f76f69016090bba0d4c36a28e5faa21b82053 Mon Sep 17 00:00:00 2001
From: Leah Neukirchen <leah@vuxu.org>
Date: Thu, 14 Apr 2022 15:54:16 +0200
Subject: [PATCH] emacs: enable support for native-compilation.

This enables native-compilation and provides precompiled elisp files
for emacs-x11 and emacs-gtk3.  The plain console emacs stays without
support for native compilation to keep it lean, as native-compilation
pulls in libgccjit (27MB) and gcc (172MB + deps)
as well as emacs-common-eln (15MB).

On slow machines, native compilation can be disabled by setting
(setq comp-deferred-compilation nil)
in your .emacs.
---
 srcpkgs/emacs-common-eln |  1 +
 srcpkgs/emacs/template   | 46 +++++++++++++++++++++++++++++++---------
 2 files changed, 37 insertions(+), 10 deletions(-)
 create mode 120000 srcpkgs/emacs-common-eln

diff --git a/srcpkgs/emacs-common-eln b/srcpkgs/emacs-common-eln
new file mode 120000
index 000000000000..a7642dd168d6
--- /dev/null
+++ b/srcpkgs/emacs-common-eln
@@ -0,0 +1 @@
+emacs
\ No newline at end of file
diff --git a/srcpkgs/emacs/template b/srcpkgs/emacs/template
index 644e44cf4d06..aae0e3f6d225 100644
--- a/srcpkgs/emacs/template
+++ b/srcpkgs/emacs/template
@@ -1,13 +1,14 @@
 # Template file for 'emacs'
 pkgname=emacs
 version=28.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--with-file-notification=inotify --with-modules
  $(vopt_with jpeg) $(vopt_with tiff) $(vopt_with gif) $(vopt_with png)
  $(vopt_with xpm) $(vopt_with svg rsvg) $(vopt_with imagemagick)
  $(vopt_with xml xml2) $(vopt_with gnutls) $(vopt_with sound) $(vopt_with m17n m17n-flt)
- $(vopt_with json) $(vopt_with harfbuzz) $(vopt_with cairo) $(vopt_with gmp libgmp)"
+ $(vopt_with json) $(vopt_with harfbuzz) $(vopt_with cairo) $(vopt_with gmp libgmp)
+ $(vopt_with nativecomp native-compilation)"
 hostmakedepends="pkg-config tar"
 makedepends="ncurses-devel libXaw-devel gtk+3-devel webkit2gtk-devel
  dbus-devel acl-devel
@@ -17,7 +18,8 @@ makedepends="ncurses-devel libXaw-devel gtk+3-devel webkit2gtk-devel
  $(vopt_if xml libxml2-devel) $(vopt_if gnutls gnutls-devel)
  $(vopt_if sound alsa-lib-devel) $(vopt_if m17n m17n-lib-devel)
  $(vopt_if json jansson-devel) $(vopt_if harfbuzz harfbuzz-devel)
- $(vopt_if cairo cairo-devel) $(vopt_if gmp gmp-devel)"
+ $(vopt_if cairo cairo-devel) $(vopt_if gmp gmp-devel)
+ $(vopt_if nativecomp libgccjit-devel)"
 depends="emacs-common-${version}_${revision}"
 short_desc="GNU Emacs editor"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
@@ -29,12 +31,16 @@ nocross=yes
 nopie=yes
 
 # Package build options
-build_options="jpeg tiff gif png xpm svg xml imagemagick gnutls sound m17n dbus json harfbuzz cairo gmp"
-desc_option_xpm="Enable support for XPM images"
-desc_option_sound="Enable support for sound"
+build_options="jpeg tiff gif png xpm svg xml imagemagick gnutls sound m17n dbus json harfbuzz cairo gmp nativecomp"
+desc_option_cairo="Enable support for drawing with Cairo"
+desc_option_gmp="Enable support for big numbers using GMP"
+desc_option_json="Enable support for native JSON parsing"
 desc_option_m17n="Enable support for m17n multilingual text processing"
-build_options_default="cairo gif gmp gnutls harfbuzz jpeg json m17n png sound
- svg tiff xml xpm"
+desc_option_nativecomp="Enable support for native compilation"
+desc_option_sound="Enable support for sound"
+desc_option_xpm="Enable support for XPM images"
+build_options_default="cairo gif gmp gnutls harfbuzz jpeg json m17n nativecomp
+ png sound svg tiff xml xpm"
 
 pre_configure() {
 	# Just configuring in different directories results in
@@ -47,7 +53,8 @@ pre_configure() {
 
 do_configure() {
 	cd $wrksrc/nox
-	./configure --without-x $(vopt_with dbus) ${configure_args}
+	./configure --without-x $(vopt_with dbus) ${configure_args} \
+		--without-native-compilation
 
 	cd $wrksrc/x11
 	./configure --with-x-toolkit=athena --without-toolkit-scroll-bars \
@@ -60,12 +67,13 @@ do_configure() {
 
 do_build() {
 	make ${makejobs} -C nox
-	make ${makejobs} -C x11
+	make ${makejobs} -C x11 $(vopt_if nativecomp NATIVE_FULL_AOT=1)
 	make ${makejobs} -C gtk3
 }
 
 do_install() {
 	make DESTDIR=$DESTDIR -C ${wrksrc}/nox install
+	make DESTDIR=$DESTDIR -C ${wrksrc}/x11 install-eln
 	rm -f ${DESTDIR}/usr/bin/ctags
 	rm -f ${DESTDIR}/usr/lib/systemd/user/emacs.service
 	rm -f ${DESTDIR}/usr/share/man/man1/ctags.1*
@@ -84,8 +92,23 @@ emacs-common_package() {
 	}
 }
 
+emacs-common-eln_package() {
+	short_desc+=" - common precompiled elisp"
+	if [ -z "$build_option_nativecomp" ]; then
+		build_style=meta
+	fi
+	pkg_install() {
+		if [ "$build_option_nativecomp" ]; then
+			vmove usr/lib/emacs
+		fi
+	}
+}
+
 emacs-x11_package() {
 	depends="emacs-common-${version}_${revision}"
+	if [ "$build_option_nativecomp" ]; then
+		depends+=" emacs-common-eln-${version}_${revision}"
+	fi
 	provides="emacs-${version}_${revision}"
 	replaces="emacs>=0"
 	short_desc+=" - X11 version"
@@ -99,6 +122,9 @@ emacs-x11_package() {
 
 emacs-gtk3_package() {
 	depends="emacs-common-${version}_${revision} desktop-file-utils hicolor-icon-theme"
+	if [ "$build_option_nativecomp" ]; then
+		depends+=" emacs-common-eln-${version}_${revision}"
+	fi
 	provides="emacs-${version}_${revision}"
 	replaces="emacs>=0"
 	short_desc+=" - GTK+3 version"

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PR PATCH] [Merged]: emacs: enable support for native-compilation.
  2022-04-14 14:25 [PR PATCH] emacs: enable support for native-compilation leahneukirchen
                   ` (3 preceding siblings ...)
  2022-04-16 12:06 ` [PR PATCH] [Updated] " leahneukirchen
@ 2022-04-16 14:05 ` leahneukirchen
  2022-04-17 11:11 ` soanvig
  2022-04-17 19:24 ` leahneukirchen
  6 siblings, 0 replies; 8+ messages in thread
From: leahneukirchen @ 2022-04-16 14:05 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 715 bytes --]

There's a merged pull request on the void-packages repository

emacs: enable support for native-compilation.
https://github.com/void-linux/void-packages/pull/36690

Description:
Closes #36543.
Closes #24240.

This enables native-compilation and provides precompiled elisp files
for emacs-x11 and emacs-gtk3.  The plain console emacs stays without
support for native compilation to keep it lean, as native-compilation
pulls in libgccjit (27MB) and gcc (172MB + deps)
as well as emacs-common-eln (15MB).

On slow machines, native compilation can be disabled by setting
```(setq comp-deferred-compilation nil)```
in your .emacs.

#### Testing the changes
- I tested the changes in this PR: **briefly**


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emacs: enable support for native-compilation.
  2022-04-14 14:25 [PR PATCH] emacs: enable support for native-compilation leahneukirchen
                   ` (4 preceding siblings ...)
  2022-04-16 14:05 ` [PR PATCH] [Merged]: " leahneukirchen
@ 2022-04-17 11:11 ` soanvig
  2022-04-17 19:24 ` leahneukirchen
  6 siblings, 0 replies; 8+ messages in thread
From: soanvig @ 2022-04-17 11:11 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 389 bytes --]

New comment by soanvig on void-packages repository

https://github.com/void-linux/void-packages/pull/36690#issuecomment-1100854800

Comment:
How this works exactly? I've updated void, I have `emacs-28.1` executable now, but running command `emacs-lisp-native-compile-and-load` (emacs command) produces result `Emacs was not compiled with native compiler support --with-native-compilation`

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emacs: enable support for native-compilation.
  2022-04-14 14:25 [PR PATCH] emacs: enable support for native-compilation leahneukirchen
                   ` (5 preceding siblings ...)
  2022-04-17 11:11 ` soanvig
@ 2022-04-17 19:24 ` leahneukirchen
  6 siblings, 0 replies; 8+ messages in thread
From: leahneukirchen @ 2022-04-17 19:24 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 218 bytes --]

New comment by leahneukirchen on void-packages repository

https://github.com/void-linux/void-packages/pull/36690#issuecomment-1100936088

Comment:
As stated, only `emacs-x11` and `emacs-gtk3` have native compilation.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-04-17 19:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-14 14:25 [PR PATCH] emacs: enable support for native-compilation leahneukirchen
2022-04-14 14:47 ` [PR PATCH] [Updated] " leahneukirchen
2022-04-14 20:10 ` KSPAtlas
2022-04-14 20:14 ` leahneukirchen
2022-04-16 12:06 ` [PR PATCH] [Updated] " leahneukirchen
2022-04-16 14:05 ` [PR PATCH] [Merged]: " leahneukirchen
2022-04-17 11:11 ` soanvig
2022-04-17 19:24 ` leahneukirchen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).