From afb765ab3cab7b6582d0def543b23603cd076445 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Sun, 4 Oct 2020 09:16:24 +0200 Subject: [PATCH] Make filename hashing compatible with self contained builds (bug#43532) * Makefile.in (lispdirrel): Add replace template. (epaths-force): Form correctly 'PATH_REL_LOADSEARCH' into epath.h * configure.ac (lispdirrel): Define variable (relative path of the lisp files from the installation directory). * src/comp.c (Fcomp_el_to_eln_filename): Update algorithm not to rely on 'PATH_DUMPLOADSEARCH' but on 'PATH_REL_LOADSEARCH'. * src/epaths.in (PATH_REL_LOADSEARCH): Add macro template. --- Makefile.in | 5 +++++ configure.ac | 7 +++++-- src/comp.c | 22 +++++----------------- src/epaths.in | 4 ++++ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Makefile.in b/Makefile.in index 2b47762b7bc..027dca0bd70 100644 --- a/Makefile.in +++ b/Makefile.in @@ -223,6 +223,10 @@ iconsrcdir=$(srcdir)/etc/images/icons # These variables hold the values Emacs will actually use. They are # based on the values of the standard Make variables above. +# Where lisp files are installed in a distributed with Emacs (relative +# path to the installation directory). +lispdirrel=@lispdirrel@ + # Where to install the lisp files distributed with Emacs. # This includes the Emacs version, so that the lisp files for different # versions of Emacs will install themselves in separate directories. @@ -368,6 +372,7 @@ epaths-force: @(gamedir='${gamedir}'; \ sed < ${srcdir}/src/epaths.in > epaths.h.$$$$ \ -e 's;\(#.*PATH_LOADSEARCH\).*$$;\1 "${standardlisppath}";' \ + -e 's;\(#.*PATH_REL_LOADSEARCH\).*$$;\1 "${lispdirrel}";' \ -e 's;\(#.*PATH_SITELOADSEARCH\).*$$;\1 "${locallisppath}";' \ -e 's;\(#.*PATH_DUMPLOADSEARCH\).*$$;\1 "${buildlisppath}";' \ -e '/^#define PATH_[^ ]*SEARCH /s/\([":]\):*/\1/g' \ diff --git a/configure.ac b/configure.ac index 3d24751c934..ead27d3dea9 100644 --- a/configure.ac +++ b/configure.ac @@ -187,7 +187,8 @@ dnl It is important that variables on the RHS not be expanded here, dnl hence the single quotes. This is per the GNU coding standards, see dnl (autoconf) Installation Directory Variables dnl See also epaths.h below. -lispdir='${datadir}/emacs/${version}/lisp' +lispdirrel='${version}/lisp' +lispdir='${datadir}/emacs/'${lispdirrel} standardlisppath='${lispdir}' locallisppath='${datadir}/emacs/${version}/site-lisp:'\ '${datadir}/emacs/site-lisp' @@ -1908,7 +1909,8 @@ if test "${with_ns}" != no; then NS_IMPL_COCOA=yes ns_appdir=`pwd`/nextstep/Emacs.app ns_appbindir=${ns_appdir}/Contents/MacOS - ns_appresdir=${ns_appdir}/Contents/Resources + lispdirrel=Contents/Resources + ns_appresdir=${ns_appdir}/{lispdirrel} ns_appsrc=Cocoa/Emacs.base ns_fontfile=macfont.o elif flags=$( (gnustep-config --objc-flags) 2>/dev/null); then @@ -5325,6 +5327,7 @@ AC_SUBST(sharedstatedir) AC_SUBST(libexecdir) AC_SUBST(mandir) AC_SUBST(infodir) +AC_SUBST(lispdirrel) AC_SUBST(lispdir) AC_SUBST(standardlisppath) AC_SUBST(locallisppath) diff --git a/src/comp.c b/src/comp.c index 058ce7e96ac..5663c9e5624 100644 --- a/src/comp.c +++ b/src/comp.c @@ -4050,27 +4050,15 @@ If BASE-DIR is nil use the first entry in `comp-eln-load-path'. */) As installing .eln files compiled during the build changes their absolute path we need an hashing mechanism that is not sensitive to that. For this we replace if match PATH_DUMPLOADSEARCH or - PATH_LOADSEARCH with '//' before generating the hash. */ + *PATH_REL_LOADSEARCH with '//' before computing the hash. */ if (NILP (loadsearch_re_list)) { - Lisp_Object sys_re; -#ifdef __APPLE__ - /* On MacOS we relax the match on PATH_LOADSEARCH making - everything before ".app/" a wildcard. This to obtain a - self-contained Emacs.app (bug#43532). */ - char *c; - if ((c = strstr (PATH_LOADSEARCH, ".app/"))) - sys_re = - concat2 (build_string ("\\`[[:ascii:]]+"), - Fregexp_quote (build_string (c))); - else - sys_re = Fregexp_quote (build_string (PATH_LOADSEARCH)); -#else - sys_re = Fregexp_quote (build_string (PATH_LOADSEARCH)); -#endif + Lisp_Object sys_re = + concat2 (build_string ("\\`[[:ascii:]]+"), + Fregexp_quote (build_string ("/" PATH_REL_LOADSEARCH "/"))); loadsearch_re_list = - list2 (sys_re, Fregexp_quote (build_string (PATH_DUMPLOADSEARCH))); + list2 (sys_re, Fregexp_quote (build_string (PATH_DUMPLOADSEARCH "/"))); } Lisp_Object lds_re_tail = loadsearch_re_list; diff --git a/src/epaths.in b/src/epaths.in index 3cadd160ecf..5b6c650b0da 100644 --- a/src/epaths.in +++ b/src/epaths.in @@ -27,6 +27,10 @@ along with GNU Emacs. If not, see . */ */ #define PATH_LOADSEARCH "/usr/local/share/emacs/lisp" +/* Like PATH_LOADSEARCH, but contains the relative path from the + installation directory. +*/ +#define PATH_REL_LOADSEARCH "" /* Like PATH_LOADSEARCH, but contains the non-standard pieces. These are the site-lisp directories. Configure sets this to -- 2.39.5