emacs: fix native compilation when launched without ${prefix}/bin on PATH

Set GCC_EXEC_PREFIX in site-start so libgccjit can locate the correct
gcc toolchain when Emacs is launched from the GUI, where ${prefix}/bin
may not be on PATH.

Closes: https://trac.macports.org/ticket/74008
Closes: https://trac.macports.org/ticket/74057
This commit is contained in:
Dan R. K. Ports
2026-06-18 14:20:29 -07:00
committed by Dan Ports
parent 568de98593
commit fab136dfea
3 changed files with 26 additions and 3 deletions
+10 -3
View File
@@ -26,6 +26,10 @@ master_sites gnu
set rpaths [list]
# GCC version used for the nativecomp variant's libgccjit; also used to point
# native compilation at the gcc toolchain via GCC_EXEC_PREFIX (see site-start).
set gcc_v 15
if {$subport eq $name} {
conflicts emacs-devel
}
@@ -105,6 +109,8 @@ post-destroot {
file mkdir ${destroot}${prefix}/share/emacs/site-lisp
file copy ${filespath}/site-start.el \
${destroot}${prefix}/share/emacs/site-lisp/site-start.el
reinplace "s|__GCC_EXEC_PREFIX__|${prefix}/lib/gcc${gcc_v}/gcc/|g" \
${destroot}${prefix}/share/emacs/site-lisp/site-start.el
}
}
@@ -138,7 +144,7 @@ platform darwin {
if {$subport eq $name || $subport eq "emacs-app"} {
version 30.2
revision 11
revision 12
checksums rmd160 fefdd3fcd453d733114f609a3e122b2529cc7410 \
sha256 1d79a4ba4d6596f302a7146843fe59cf5caec798190bcc07c907e7ba244b076d \
size 83059014
@@ -158,7 +164,7 @@ if {$subport eq "emacs-devel" || $subport eq "emacs-app-devel"} {
github.tarball_from archive
epoch 5
version 20260602
revision 0
revision 1
master_sites ${github.master_sites}
@@ -293,6 +299,8 @@ if {$subport eq "emacs-app" || $subport eq "emacs-app-devel"} {
${destroot}${applications_dir}/Emacs.app/Contents/Resources/site-lisp/site-start.el
reinplace "s|__APPLICATIONS_DIR__|${applications_dir}|g" \
${destroot}${applications_dir}/Emacs.app/Contents/Resources/site-lisp/site-start.el
reinplace "s|__GCC_EXEC_PREFIX__|${prefix}/lib/gcc${gcc_v}/gcc/|g" \
${destroot}${applications_dir}/Emacs.app/Contents/Resources/site-lisp/site-start.el
}
variant imagemagick description {Use ImageMagick} {
@@ -319,7 +327,6 @@ if {$subport eq "emacs-app" || $subport eq "emacs-app-devel"} {
# https://trac.macports.org/ticket/68382
if {${configure.build_arch} ni [list i386 ppc]} {
variant nativecomp description {Builds emacs with native compilation support} {
set gcc_v 15
depends_lib-append port:gcc${gcc_v}
configure.args-replace --with-native-compilation=no \
--with-native-compilation=aot
+8
View File
@@ -18,3 +18,11 @@
(set-fontset-font t 'emoji '("Apple Color Emoji" . "iso10646-1") nil 'prepend))
(setq etags-program-name "__APPLICATIONS_DIR__/Emacs.app/Contents/MacOS/bin/etags")
;; Point native compilation at the MacPorts gcc toolchain so libgccjit can
;; locate its support libraries when Emacs is launched without ${prefix}/bin
;; on PATH (e.g. from the Finder). https://trac.macports.org/ticket/74008
(when (and (fboundp 'native-comp-available-p)
(native-comp-available-p)
(not (getenv "GCC_EXEC_PREFIX")))
(setenv "GCC_EXEC_PREFIX" "__GCC_EXEC_PREFIX__"))
+8
View File
@@ -1,3 +1,11 @@
;; -*- lexical-binding: t; -*-
(setq etags-program-name "etags-emacs")
;; Point native compilation at the MacPorts gcc toolchain so libgccjit can
;; locate its support libraries when Emacs is launched without ${prefix}/bin
;; on PATH. https://trac.macports.org/ticket/74008
(when (and (fboundp 'native-comp-available-p)
(native-comp-available-p)
(not (getenv "GCC_EXEC_PREFIX")))
(setenv "GCC_EXEC_PREFIX" "__GCC_EXEC_PREFIX__"))