emacsのコンパイルエラーだけど、なんで??
native-compilation1 は libgcccjit を使うんだけど、 libgcc_s.1.1.dylib は gcc の動的ライブラリ なんだけど。
寝てれば小人さんが直してくれるかな🤔
otool -L libgccjit.0.dylib
libgccjit.0.dylib:
/usr/local/opt/libgccjit/lib/gcc/current/libgccjit.0.dylib (compatibility version 0.0.0, current version 26.0.26)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/local/opt/isl/lib/libisl.23.dylib (compatibility version 27.0.0, current version 27.0.0)
/usr/local/opt/libmpc/lib/libmpc.3.dylib (compatibility version 7.0.0, current version 7.1.0)
/usr/local/opt/mpfr/lib/libmpfr.6.dylib (compatibility version 9.0.0, current version 9.1.0)
/usr/local/opt/gmp/lib/libgmp.10.dylib (compatibility version 16.0.0, current version 16.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.12)
/usr/local/opt/zstd/lib/libzstd.1.dylib (compatibility version 1.0.0, current version 1.5.6)
@rpath/libgcc_s.1.1.dylib (compatibility version 1.0.0, current version 1.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.100.2)
config.log 抜粋
configure:27351: ./conftest
dyld[62999]: Library not loaded: @rpath/libgcc_s.1.1.dylib
Referenced from: <C93A88B4-A5C5-3C6F-9F9B-CB9D58FF003E> /usr/local/Cellar/libgccjit/14.1.0/lib/gcc/current/libgccjit.0.dylib
Reason: tried: '/usr/local/Cellar/libgccjit/14.1.0/lib/gcc/current/libgcc_s.1.1.dylib' (no such file), '/usr/local/lib/libgcc_s.1.1.dylib' (no such file), '/usr/lib/libgcc_s.1.1.dylib' (no such file, not in dyld cache)
./configure: line 3628: 62999 Abort trap: 6 ./conftest$ac_exeext
configure:27351: $? = 134
configure: program exited with status 134
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GNU Emacs"
| #define PACKAGE_TARNAME "emacs"
| #define PACKAGE_VERSION "30.0.50"
| #define PACKAGE_STRING "GNU Emacs 30.0.50"
| #define PACKAGE_BUGREPORT "[email protected]"
| #define PACKAGE_URL "https://www.gnu.org/software/emacs/"
| #define HAVE_PDUMPER 1
| #define HAVE_MAILUTILS 1
| #define HAVE_STDIO_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_WCHAR_H 1
| #define HAVE_SYS_RESOURCE_H 1
| #define HAVE_SYS_UTSNAME_H 1
| #define HAVE_PWD_H 1
| #define HAVE_UTIL_H 1
| #define HAVE_SANITIZER_LSAN_INTERFACE_H 1
| #define HAVE_SANITIZER_ASAN_INTERFACE_H 1
| #define HAVE_SANITIZER_COMMON_INTERFACE_DEFS_H 1
| #define HAVE_SYS_SOCKET_H 1
| #define HAVE_SYS_PARAM_H 1
| #define HAVE_PTHREAD_H 1
| #define HAVE_MALLOC_MALLOC_H 1
| #define HAVE_SYS_UN_H 1
| #define HAVE_UTMP_H 1
| #define HAVE_UTMPX_H 1
| #define HAVE_DIRENT_H 1
| #define HAVE_EXECINFO_H 1
| #define HAVE_GETOPT_H 1
| #define HAVE_SYS_CDEFS_H 1
| #define HAVE_SYS_TIME_H 1
| #define HAVE_LIMITS_H 1
| #define HAVE_SYS_SELECT_H 1
| #define HAVE_STDBOOL_H 1
| #define HAVE_SYS_RANDOM_H 1
| #define STDC_HEADERS 1
| #define _ALL_SOURCE 1
| #define _DARWIN_C_SOURCE 1
| #define _GNU_SOURCE 1
| #define _HPUX_ALT_XOPEN_SOCKET_API 1
| #define _NETBSD_SOURCE 1
| #define _OPENBSD_SOURCE 1
| #define _POSIX_PTHREAD_SEMANTICS 1
| #define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1
| #define __STDC_WANT_IEC_60559_BFP_EXT__ 1
| #define __STDC_WANT_IEC_60559_DFP_EXT__ 1
| #define __STDC_WANT_IEC_60559_EXT__ 1
| #define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1
| #define __STDC_WANT_IEC_60559_TYPES_EXT__ 1
| #define __STDC_WANT_LIB_EXT2__ 1
| #define __STDC_WANT_MATH_SPEC_FUNCS__ 1
| #define _TANDEM_SOURCE 1
| #define __EXTENSIONS__ 1
| #define __USE_MINGW_ANSI_STDIO 1
| #define GCC_LINT 1
| #define SYSTEM_TYPE "darwin"
| #define HAVE_STRUCT_PASSWD_PW_GECOS 1
| #define HAVE_TERM_H 1
| #define HAVE_SYS_WAIT_H 1
| #define HAVE_NET_IF_H 1
| #define HAVE_IFADDRS_H 1
| #define HAVE_NET_IF_DL_H 1
| #define HAVE_STRUCT_IFREQ_IFR_FLAGS 1
| #define HAVE_STRUCT_IFREQ_IFR_BROADADDR 1
| #define HAVE_STRUCT_IFREQ_IFR_ADDR 1
| #define HAVE_STRUCT_IFREQ_IFR_ADDR_SA_LEN 1
| #define HAVE_NATIVE_IMAGE_API 1
| #define NS_SELF_CONTAINED 1
| #define NATIVE_OBJC_INSTANCETYPE 1
| #define HAVE_SBRK 1
| #define HAVE_GETPAGESIZE 1
| #define HAVE_FORK 1
| #define HAVE_VFORK 1
| #define HAVE_FCHMOD 1
| #define HAVE_UTMPXNAME 1
| #define HAVE_REALPATH 1
| #define HAVE_LSTAT 1
| #define HAVE_FCHMODAT 1
| #define HAVE_LCHMOD 1
| #define HAVE_FCNTL 1
| #define HAVE_FDOPENDIR 1
| #define HAVE_LISTXATTR 1
| #define HAVE_FSTATAT 1
| #define HAVE_FSYNC 1
| #define HAVE_GETTIMEOFDAY 1
| #define HAVE_MEMSET_S 1
| #define HAVE_PSELECT 1
| #define HAVE_PTHREAD_SIGMASK 1
| #define HAVE_READLINK 1
| #define HAVE_ISBLANK 1
| #define HAVE_ISWCTYPE 1
| #define HAVE_STRTOIMAX 1
| #define HAVE_SYMLINK 1
| #define HAVE_LOCALTIME_R 1
| #define HAVE_GETDTABLESIZE 1
| #define SYSTEM_MALLOC 1
| #define HAVE_MMAP 1
| #define HAVE_PTHREAD 1
| #define THREADS_ENABLED 1
| #define HAVE_RSVG 1
| #define HAVE_WEBP 1
| #define HAVE_SQLITE3 1
| #define HAVE_GNUTLS 1
| #define HAVE_TREE_SITTER 1
| #define HAVE_KQUEUE 1
| #define USE_FILE_NOTIFY 1
| #define USE_TOOLKIT_SCROLL_BARS 1
| #define HAVE_XIM 1
| #define USE_XIM 1
| #define HAVE_JPEG 1
| #define HAVE_LCMS2 1
| #define HAVE_ZLIB 1
| #define DYNAMIC_LIB_SUFFIX ".dylib"
| #define DYNAMIC_LIB_SECONDARY_SUFFIX ".so"
| #define HAVE_DLADDR 1
| #define HAVE_MODULES 1
| #define MODULES_SUFFIX ".dylib"
| #define MODULES_SECONDARY_SUFFIX ".so"
| #define HAVE_LIBGCCJIT 1
| #define HAVE_LIBGCCJIT_H 1
| /* end confdefs.h. */
|
| #include <libgccjit.h>
| #include <stdlib.h>
| #include <stdio.h>
| int
| main (int argc, char **argv)
| {
| gcc_jit_context *ctxt;
| gcc_jit_result *result;
| ctxt = gcc_jit_context_acquire ();
| if (!ctxt)
| exit (1);
| gcc_jit_type *int_type =
| gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
| gcc_jit_function *func =
| gcc_jit_context_new_function (ctxt, NULL,
| GCC_JIT_FUNCTION_EXPORTED,
| int_type, "foo", 0, NULL, 0);
| gcc_jit_block *block = gcc_jit_function_new_block (func, "foo");
| gcc_jit_block_end_with_return (
| block,
| NULL,
| gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 1));
| result = gcc_jit_context_compile (ctxt);
| if (!result)
| exit (1);
| typedef int (*fn_type) (void);
| fn_type foo =
| (fn_type)gcc_jit_result_get_code (result, "foo");
| if (!foo)
| exit (1);
| if (foo () != 1)
| exit (1);
| gcc_jit_context_release (ctxt);
| gcc_jit_result_release (result);
| return 0;
| }
configure:27356: error: The installed libgccjit failed to compile and run a test program using
the libgccjit library; see config.log for the details of the failure.
The test program can be found here:
<https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html>.
You can try compiling it yourself to investigate the issues.
Please report the issue to your distribution if libgccjit was installed
through that.
You can find the instructions on how to compile and install libgccjit from
source on this site:
<https://gcc.gnu.org/wiki/JIT>.
build-emacs.sh
#! /usr/bin/env bash
# Prequisites
# - Xcode
# - git
# - imagemagick (allows image viewing)
# - gnutls (allows communication via SSL, TLS, amd DTLS)
# - autoconf
# - automake
# $ ./autogen.sh && \
# ./configure --with-native-compilation=aot --without-ns --without-x --with-libxml2=/usr/bin/xml2-config && make -j8
DO_BREW_PACKAGES=(
# Build dependencies
# brew install pkg-config automake texinfo jpeg giflib \
# libtiff jansson libpng librsvg gnutls cmake
#@ cairo
#@imagemagick
autoconf
cmake
gcc
giflib
gnupg
gnutls
jansson
libgccjit
libtiff
librsvg
libxml2
pkg-config
# Runtime dependencies
texinfo
ripgrep
fd
node
python
shfmt
mupdf
# mupdf-tools
)
DO_BREW_CASKS=(
mactex-no-gui
)
# ./configure --disable-dependency-tracking --disable-silent-rules \
# --enable-locallisppath=/opt/homebrew/share/emacs/site-lisp \
# --infodir=/opt/homebrew/Cellar/emacs-plus@29/29.2/share/info/emacs \
# --prefix=/opt/homebrew/Cellar/emacs-plus@29/29.2 \
# --with-xml2 --with-gnutls --with-native-compilation --without-compress-install \
# --without-dbus --without-imagemagick --with-modules --with-rsvg --without-pop \
# --with-ns --disable-ns-self-contained
DO_CONFIGURE_OPTS=(
# --with-native-compilation=aot
--disable-dependency-tracking
--disable-silent-rule
--without-compress-install
--without-dbus
--without-imagemagick
--without-pop
# --without-x
# --with-cairo
--with-gnutls=ifavailable
--with-json
--with-modules
--with-native-compilation=yes
# --with-native-compilation=no
--with-rsvg
--with-ns
--with-tree-sitter=ifavailable
--with-xml2
)
# Print the given arguments out in a nice heading
do_heading() {
printf "\n\033[38;5;013m * %s \033[0m \n\n" "$*"
}
# Return exit code 0 if $1 is the same as any of the rest of the arguments
contains() {
local e match="$1"
shift
for e in "$@"; do [ "$e" = "$match" ] && return 0; done
return 1
}
# Ensure the given homebrew packages are installed and up to date
# brew_ensure [ cask ] dep1 [ dep2 ] [ ... ]
do_brew_ensure() {
do_heading "Ensuring Homebrew packages..."
echo "$@"
local brew_type installed required missing outdated upgrade
brew_type="$1"
shift
# List installed packages
installed=($(brew list $brew_type -q))
# strip off the "@version" part, e.g. "[email protected]" becomes "python"
for i in "${!installed[@]}"; do
installed[$i]="${installed[$i]%%@*}"
done
# List missing packages (required but not installed)
required=("$@")
missing=()
for p in "${required[@]}"; do
contains "$p" "${installed[@]}" || missing+=("$p")
done
# Install missing packages
if [ -n "${missing[*]:-}" ]; then
echo "Installing packages: ${missing[*]}"
brew install $brew_type "${missing[@]}"
fi
# List of outdated packages
outdated="$(brew outdated $brew_type -q)"
upgrade=()
for p in "${required[@]}"; do
contains "$p" "${outdated[@]}" && upgrade+=("$p")
done
# Upgrade out outdated packages
if [ -n "${upgrade[*]:-}" ]; then
echo "Upgrading packages: ${upgrade[*]}"
brew upgrade $brew_type "${upgrade[@]}"
fi
}
# Print the number of CPU cores on the local machine
do_how_many_cores() {
case "$(uname)" in
Darwin)
sysctl -n hw.ncpu
;;
Linux)
awk '/^processor/ {++n} END {print n}' /proc/cpuinfo
;;
esac
}
SRC_REPOS="https://github.com/emacs-mirror/emacs.git"
TARGET="${GITHUB_REPOS}/github.com/emacs-mirror/emacs"
do_heading "Pulling Git ${SRC_REPOS}"
test -x ~/.bin/hub-clone.sh || exit 9
if [ -d "${TARGET}" ]; then
cd "${TARGET}" || exit
git reset --hard
git clean -xdf
git pull
else
~/.bin/hub-clone.sh "${SRC_REPOS}" # https://github.com/emacs-mirror/emacs.git
fi
DO_CORES=$((2 * $(do_how_many_cores)))
do_brew_ensure --formula "${DO_BREW_PACKAGES[@]}"
do_brew_ensure --cask "${DO_BREW_CASKS[@]}"
cd "${TARGET}" || exit
make distclean && ./autogen.sh && \
CFLAGS=$(xml2-config --cflags) ./configure "${DO_CONFIGURE_OPTS[@]}" && \
make V=0 -j "${DO_CORES}" && make install && (
test -d "${APPS}" && rm -fr "${APPS}"
open -R nextstep/Emacs.app
)
パッケージ管理に手を入れるのは、シンボリックリンクを追加するだけでも嫌なんだけど、使えないのはストレスになる。
cd "$(brew --prefix)/lib"
ln -s ../Cellar/libgccjit/12.2.0/lib/gcc/12/libgccjit.dylib ./
ln -s ../Cellar/libgccjit/12.2.0/lib/gcc/12/libgccjit.0.dylib ./
ln -s ../Cellar/gcc/14.1.0/lib/gcc/current/libgcc_s.1.dylib ./
ln -s ../Cellar/gcc/14.1.0/lib/gcc/current/libgcc_s.1.1.dylib ./
GITHUB_REPOS=/Users/ac1965/devel/src LIBRARY_PATH="$(brew --prefix)/lib" build-emacs.sh
M-x describe-variable RET system-configuration-features RET
Helpバッファの Its value is に =NATIVE_COMP= が含まれていればOK
system-configuration-features is a variable defined in ‘C source code’.
Its value is
"ACL GIF GLIB GMP GNUTLS JPEG LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM ZLIB"
String listing some of the main features this Emacs was compiled with.
An element of the form "FOO" generally means that HAVE_FOO was
defined during the build.
This is mainly intended for diagnostic purposes in bug reports.
Don’t rely on it for testing whether a feature you want to use is available.
Probably introduced at or before Emacs version 25.1.
[修正] build-emacs.sh
#! /usr/bin/env bash
# Prequisites
# - Xcode
# - git
# - imagemagick (allows image viewing)
# - gnutls (allows communication via SSL, TLS, amd DTLS)
# - autoconf
# - automake
# $ ./autogen.sh && \
# ./configure --with-native-compilation=aot --without-ns --without-x --with-libxml2=/usr/bin/xml2-config && make -j8
DO_BREW_PACKAGES=(
# Build dependencies
# brew install pkg-config automake texinfo jpeg giflib \
# libtiff jansson libpng librsvg gnutls cmake
#@ cairo
#@imagemagick
autoconf
cmake
gcc
giflib
gnupg
gnutls
jansson
libgccjit
libtiff
librsvg
libxml2
pkg-config
# Runtime dependencies
texinfo
ripgrep
fd
node
python
shfmt
mupdf
# mupdf-tools
)
DO_BREW_CASKS=(
mactex-no-gui
)
# ./configure --disable-dependency-tracking --disable-silent-rules \
# --enable-locallisppath=/opt/homebrew/share/emacs/site-lisp \
# --infodir=/opt/homebrew/Cellar/emacs-plus@29/29.2/share/info/emacs \
# --prefix=/opt/homebrew/Cellar/emacs-plus@29/29.2 \
# --with-xml2 --with-gnutls --with-native-compilation --without-compress-install \
# --without-dbus --without-imagemagick --with-modules --with-rsvg --without-pop \
# --with-ns --disable-ns-self-contained
#
DO_CONFIGURE_OPTS=(
--disable-dependency-tracking
--disable-silent-rule
--without-compress-install
--without-dbus
--without-imagemagick
--without-pop
--with-gnutls=ifavailable
--with-json
--with-modules
--with-native-compilation=yes
--with-rsvg
--with-ns
--with-tree-sitter=ifavailable
--with-xml2
)
# Print the given arguments out in a nice heading
do_heading() {
printf "\n\033[38;5;013m * %s \033[0m \n\n" "$*"
}
# Return exit code 0 if $1 is the same as any of the rest of the arguments
contains() {
local e match="$1"
shift
for e in "$@"; do [ "$e" = "$match" ] && return 0; done
return 1
}
# Ensure the given homebrew packages are installed and up to date
# brew_ensure [ cask ] dep1 [ dep2 ] [ ... ]
do_brew_ensure() {
do_heading "Ensuring Homebrew packages..."
echo "$@"
local brew_type installed required missing outdated upgrade
brew_type="$1"
shift
# List installed packages
installed=($(brew list $brew_type -q))
# strip off the "@version" part, e.g. "[email protected]" becomes "python"
for i in "${!installed[@]}"; do
installed[$i]="${installed[$i]%%@*}"
done
# List missing packages (required but not installed)
required=("$@")
missing=()
for p in "${required[@]}"; do
contains "$p" "${installed[@]}" || missing+=("$p")
done
# Install missing packages
if [ -n "${missing[*]:-}" ]; then
echo "Installing packages: ${missing[*]}"
brew install $brew_type "${missing[@]}"
fi
# List of outdated packages
outdated="$(brew outdated $brew_type -q)"
upgrade=()
for p in "${required[@]}"; do
contains "$p" "${outdated[@]}" && upgrade+=("$p")
done
# Upgrade out outdated packages
if [ -n "${upgrade[*]:-}" ]; then
echo "Upgrading packages: ${upgrade[*]}"
brew upgrade $brew_type "${upgrade[@]}"
fi
}
# Print the number of CPU cores on the local machine
do_how_many_cores() {
case "$(uname)" in
Darwin)
sysctl -n hw.ncpu
;;
Linux)
awk '/^processor/ {++n} END {print n}' /proc/cpuinfo
;;
esac
}
SRC_REPOS="https://github.com/emacs-mirror/emacs.git"
TARGET="${GITHUB_REPOS}/github.com/emacs-mirror/emacs"
do_heading "Pulling Git ${SRC_REPOS}"
test -x ~/.bin/hub-clone.sh || exit 9
if [ -d "${TARGET}" ]; then
cd "${TARGET}" || exit
git reset --hard
git clean -xdf
git pull
else
~/.bin/hub-clone.sh "${SRC_REPOS}" # https://github.com/emacs-mirror/emacs.git
fi
DO_CORES=$((2 * $(do_how_many_cores)))
do_brew_ensure --formula "${DO_BREW_PACKAGES[@]}"
do_brew_ensure --cask "${DO_BREW_CASKS[@]}"
# cd "$(brew --prefix)/lib"
# ln -s ../Cellar/libgccjit/12.2.0/lib/gcc/12/libgccjit.dylib ./
# ln -s ../Cellar/libgccjit/12.2.0/lib/gcc/12/libgccjit.0.dylib ./
# ln -s ../Cellar/gcc/14.1.0/lib/gcc/current/libgcc_s.1.dylib ./
# ln -s ../Cellar/gcc/14.1.0/lib/gcc/current/libgcc_s.1.1.dylib ./
cd "${TARGET}" || exit
make distclean && ./autogen.sh && \
LIBRARY_PATH="$(brew --prefix)/lib" CFLAGS=$(xml2-config --cflags) ./configure "${DO_CONFIGURE_OPTS[@]}" && \
make V=0 -j "${DO_CORES}" && make install && (
test -d "${APPS}" && rm -fr "${APPS}"
open -R nextstep/Emacs.app
)
-
Emacsのエディタ機能は大量のLispで作られているため処理速度は遅く重たい。ネイティブコードとは実行する都度読んで解釈していたLispコードをバイナリコードにバックグラウンドで自動的にコンパイルする機能で、次回から最速で動作することが期待される。 ↩︎