Upstream hashes both the absolute file name and the content of a file to derive the name for the natively compiled files. This breaks the staged install used in guix, as any $GUIX_PROFILE is distinct from the build directory. Index: emacs-29.1/src/comp.c =================================================================== --- emacs-29.1.orig/src/comp.c +++ emacs-29.1/src/comp.c @@ -4399,8 +4399,8 @@ FILENAME must exist, and if it's a symli If FILENAME is compressed, it must have the \".gz\" extension, and Emacs must have been compiled with zlib; the file will be uncompressed on the fly to hash its contents. -Value includes the original base name, followed by 2 hash values, -one for the file name and another for its contents, followed by .eln. */) +Value includes the original base name, followed by a hash of its +content, followed by .eln. */) (Lisp_Object filename) { CHECK_STRING (filename); @@ -4423,64 +4423,26 @@ one for the file name and another for it filename = Fw32_long_file_name (filename); #endif - Lisp_Object content_hash = comp_hash_source_file (filename); - - if (suffix_p (filename, ".gz")) - filename = Fsubstring (filename, Qnil, make_fixnum (-3)); - - /* We create eln filenames with an hash in order to look-up these + /* We create eln filenames with a hash in order to look-up these starting from the source filename, IOW have a relation - /absolute/path/filename.el + content -> - eln-cache/filename-path_hash-content_hash.eln. + filename.el + content -> eln-cache/filename-content_hash.eln. 'dlopen' can return the same handle if two shared with the same filename are loaded in two different times (even if the first was deleted!). To prevent this scenario the source file content is - included in the hashing algorithm. + included in the hashing algorithm. */ - As at any point in time no more then one file can exist with the - same filename, should be possible to clean up all - filename-path_hash-* except the most recent one (or the new one - being recompiled). - - 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_REL_LOADSEARCH with '//' before computing the hash. */ + Lisp_Object content_hash = comp_hash_source_file (filename); + Lisp_Object separator = build_string ("-"); - if (NILP (loadsearch_re_list)) - { - Lisp_Object sys_re = - concat2 (build_string ("\\`[[:ascii:]]+"), - Fregexp_quote (build_string ("/" PATH_REL_LOADSEARCH "/"))); - Lisp_Object dump_load_search = - Fexpand_file_name (build_string (PATH_DUMPLOADSEARCH "/"), Qnil); -#ifdef WINDOWSNT - dump_load_search = Fw32_long_file_name (dump_load_search); -#endif - loadsearch_re_list = list2 (sys_re, Fregexp_quote (dump_load_search)); - } + if (suffix_p (filename, ".gz")) + filename = Fsubstring (filename, Qnil, make_fixnum (-3)); - Lisp_Object lds_re_tail = loadsearch_re_list; - FOR_EACH_TAIL (lds_re_tail) - { - Lisp_Object match_idx = - Fstring_match (XCAR (lds_re_tail), filename, Qnil, Qnil); - if (BASE_EQ (match_idx, make_fixnum (0))) - { - filename = - Freplace_match (build_string ("//"), Qt, Qt, filename, Qnil); - break; - } - } - Lisp_Object separator = build_string ("-"); - Lisp_Object path_hash = comp_hash_string (filename); filename = concat2 (Ffile_name_nondirectory (Fsubstring (filename, Qnil, make_fixnum (-3))), separator); - Lisp_Object hash = concat3 (path_hash, separator, content_hash); - return concat3 (filename, hash, build_string (NATIVE_ELISP_SUFFIX)); + return concat3 (filename, content_hash, build_string (NATIVE_ELISP_SUFFIX)); } DEFUN ("comp-el-to-eln-filename", Fcomp_el_to_eln_filename,