Open asmeurer opened 10 months ago
No idea, but thanks for opening the issue! Pointers for whoever wants to take a look at this:
Would also love to have this on Mac, but I realize that's a much bigger ask.
Here is a proof of concept - at least the dependencies will need some work, but I managed to build emacs package with native compiler against it.
GCC recipe modifications:
diff -urN gcc.recipe.orig/build.sh gcc.recipe/build.sh
--- gcc.recipe.orig/build.sh 2024-06-27 20:45:24.121616100 -0400
+++ gcc.recipe/build.sh 2024-08-27 07:32:38.113190659 -0400
@@ -65,7 +65,7 @@
fi
mkdir -p build
-cd build
+pushd build
# We need to explicitly set the gxx include dir because previously
# with ct-ng, native build was not considered native because
@@ -110,3 +110,35 @@
"${GCC_CONFIGURE_OPTIONS[@]}"
make -j${CPU_COUNT} || (cat ${TARGET}/libgomp/config.log; false)
+popd
+
+mkdir -p build-jit
+pushd build-jit
+
+../configure \
+ --prefix="$PREFIX" \
+ --with-slibdir="$PREFIX/lib" \
+ --libdir="$PREFIX/lib" \
+ --mandir="$PREFIX/man" \
+ --build=$BUILD \
+ --host=$HOST \
+ --target=$TARGET \
+ --enable-languages=jit \
+ --enable-host-shared \
+ --disable-bootstrap \
+ --disable-multilib \
+ --enable-libquadmath \
+ --enable-libquadmath-support \
+ --enable-long-long \
+ --disable-libssp \
+ --disable-libmudflap \
+ --enable-gold \
+ --disable-nls \
+ --with-sysroot=${SYSROOT_DIR} \
+ --with-build-sysroot=${BUILD_PREFIX}/${TARGET}/sysroot \
+ --with-native-system-header-dir=${NATIVE_SYSTEM_HEADER_DIR} \
+ --with-gxx-include-dir="${PREFIX}/lib/gcc/${TARGET}/${gcc_version}/include/c++" \
+ "${GCC_CONFIGURE_OPTIONS[@]}"
+
+make -j${CPU_COUNT}
+popd
diff -urN gcc.recipe.orig/install-libgccjit.sh gcc.recipe/install-libgccjit.sh
--- gcc.recipe.orig/install-libgccjit.sh 1969-12-31 19:00:00.000000000 -0500
+++ gcc.recipe/install-libgccjit.sh 2024-08-27 06:49:59.675356512 -0400
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+source ${RECIPE_DIR}/setup_compiler.sh
+set -e -x
+
+rm -f ${PREFIX}/lib/libgccjit* || true
+
+mkdir -p ${PREFIX}/lib
+cp -f --no-dereference ${SRC_DIR}/build-jit/gcc/libgccjit*.so* ${PREFIX}/lib/
+
+install -Dm644 ${SRC_DIR}/gcc/jit/libgccjit.h ${PREFIX}/lib/gcc/${TARGET}/${gcc_version}/include/libgccjit.h
+
+# Install Runtime Library Exception
+install -Dm644 $SRC_DIR/COPYING.RUNTIME \
+ ${PREFIX}/share/licenses/libgccjit/RUNTIME.LIBRARY.EXCEPTION
diff -urN gcc.recipe.orig/meta.yaml gcc.recipe/meta.yaml
--- gcc.recipe.orig/meta.yaml 2024-06-27 20:45:24.121616100 -0400
+++ gcc.recipe/meta.yaml 2024-08-26 08:08:58.407197464 -0400
@@ -163,6 +163,7 @@
- {{ pin_subpackage("libgcc" ~ runtime_suffix, exact=True) }} # [target_platform == cross_target_platform]
- {{ pin_subpackage("libgfortran" ~ libgfortran_soname) }} # [target_platform == cross_target_platform]
- {{ pin_subpackage("libsanitizer", exact=True) }} # [target_platform == cross_target_platform and not win]
+ - {{ pin_subpackage("libgccjit", exact=True) }} # [target_platform == cross_target_platform]
run:
- binutils_impl_{{ cross_target_platform }} >={{ binutils_version }}
- {{ pin_subpackage("libgcc-devel_" ~ cross_target_platform, exact=True) }}
@@ -620,6 +621,31 @@
home: https://gcc.gnu.org/
license: GPL-3.0-only WITH GCC-exception-3.1
+ - name: libgccjit
+ target: {{ cross_target_platform }}
+ script: install-libgccjit.sh
+ build:
+ number: {{ build_num }}
+ detect_binary_files_with_prefix: False
+ skip: True # [target_platform != cross_target_platform]
+ missing_dso_whitelist:
+ - "*"
+ requirements:
+ build:
+ host:
+ - {{ cross_target_stdlib }}_{{ cross_target_platform }} {{ cross_target_stdlib_version }}
+ run:
+ - libgcc{{ runtime_suffix }} >={{ gcc_version }}
+ run_constrained:
+ - libgccjit{{ runtime_suffix }} {{ gcc_version }}
+ test:
+ commands:
+ - test -f ${PREFIX}/lib/libgccjit.so
+ about:
+ summary: The GNU GCC JIT compiler library
+ home: https://gcc.gnu.org/
+ license: GPL-3.0-only WITH GCC-exception-3.1
+
about:
summary: GNU Compiler Collection
Emacs recipe modifications:
diff --git a/emacs.recipe/build.sh b/emacs.recipe/build.sh
index 371e9504..51414629 100644
--- a/emacs.recipe/build.sh
+++ b/emacs.recipe/build.sh
@@ -11,9 +11,11 @@ if [ "$(uname)" == "Darwin" ]; then
# https://github.com/conda-forge/emacs-feedstock/pull/16#issuecomment-334241528
export LDFLAGS="${LDFLAGS} -ltinfo"
else
- OPTS="--x-includes=$PREFIX/include --x-libraries=$PREFIX/lib --with-x-toolkit=gtk3 --with-harfbuzz -with-cairo --with-tree-sitter --with-json"
+ OPTS="--x-includes=$PREFIX/include --x-libraries=$PREFIX/lib --with-x-toolkit=gtk3 --with-harfbuzz -with-cairo --with-tree-sitter --with-json --with-native-compilation=yes"
fi
+export LIBRARY_PATH=$BUILD_PREFIX/x86_64-conda-linux-gnu/sysroot/usr/lib:$BUILD_PREFIX/lib/gcc
+
autoreconf -vfi
if [[ "$CONDA_BUILD_CROSS_COMPILATION" == 1 ]]; then
diff --git a/emacs.recipe/conda_build_config.yaml b/emacs.recipe/conda_build_config.yaml
index 4294d2c1..a7960738 100644
--- a/emacs.recipe/conda_build_config.yaml
+++ b/emacs.recipe/conda_build_config.yaml
@@ -1,6 +1,6 @@
CI: azure
c_compiler: gcc
-c_compiler_version: '12'
+c_compiler_version: '14'
cairo: '1'
cdt_name: cos7
channel_sources: conda-forge
diff --git a/emacs.recipe/meta.yaml b/emacs.recipe/meta.yaml
index 735b3505..d11d038f 100644
--- a/emacs.recipe/meta.yaml
+++ b/emacs.recipe/meta.yaml
@@ -20,7 +20,7 @@ source:
- 0007-macos-cross-compile-lisp-makefile.patch # [osx and build_platform != target_platform]
build:
- number: 0
+ number: 1
skip: true # [win]
detect_binary_files_with_prefix: true
@@ -51,6 +51,7 @@ requirements:
- libtree-sitter
- jansson
- texinfo
+ - libgccjit
host:
- libxml2
@@ -83,6 +84,7 @@ requirements:
- zlib
- libtree-sitter
- jansson
+ - libgccjit
run:
- __osx >={{ MACOSX_DEPLOYMENT_TARGET|default("10.9") }} # [osx and x86_64]
@@ -115,6 +117,7 @@ requirements:
- zlib
- libtree-sitter
- jansson
+ - libgccjit
test:
commands:
Comment:
How hard would it be to add the libgccjit library to this package? It is needed for emacs native compilation. https://github.com/conda-forge/emacs-feedstock/pull/83