1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 18:40:39 -08:00

Hash eln ABI once and add it to the output compilation path

This commit is contained in:
AndreaCorallo 2020-03-03 22:23:41 +00:00 committed by Andrea Corallo
parent f77f6ca770
commit 43b6f05dfb
5 changed files with 35 additions and 8 deletions

View file

@ -2125,7 +2125,7 @@ Return the compilation unit file name."
(file-name-as-directory
(concat
(file-name-directory exp-file)
system-configuration))
comp-native-path-postfix))
(file-name-sans-extension
(file-name-nondirectory exp-file))))))))
(comp-log "\n \n" 1)

View file

@ -250,8 +250,8 @@ format_string (const char *format, ...)
/* Produce a key hashing Vcomp_subr_list. */
static Lisp_Object
hash_subr_list (void)
void
hash_native_abi (void)
{
Lisp_Object string = Fmapconcat (intern_c_string ("subr-name"),
Vcomp_subr_list, build_string (" "));
@ -260,7 +260,17 @@ hash_subr_list (void)
sha512_buffer (SSDATA (string), SCHARS (string), SSDATA (digest));
hexbuf_digest (SSDATA (digest), SDATA (digest), SHA512_DIGEST_SIZE);
return digest;
/* Check runs once. */
eassert (Vcomp_abi_hash);
Vcomp_abi_hash = digest;
/* If 10 characters are usually sufficient for git I guess 16 are
fine for us here. */
Vcomp_native_path_postfix =
concat3 (Vsystem_configuration,
make_string ("-", 1),
Fsubstring_no_properties (Vcomp_abi_hash,
make_fixnum (0),
make_fixnum (16)));
}
static void
@ -1976,8 +1986,9 @@ emit_ctxt_code (void)
fields[n_frelocs++] = xmint_pointer (XCDR (el));
}
/* Compute and store function link table hash. */
emit_static_object (LINK_TABLE_HASH_SYM, hash_subr_list ());
/* Sign the .eln for the exposed ABI it expects at load. */
eassert (!NILP (Vcomp_abi_hash));
emit_static_object (LINK_TABLE_HASH_SYM, Vcomp_abi_hash);
Lisp_Object subr_l = Vcomp_subr_list;
FOR_EACH_TAIL (subr_l)
@ -3430,7 +3441,7 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump)
&& freloc_link_table
&& top_level_run)
|| NILP (Fstring_equal (load_static_obj (comp_u, LINK_TABLE_HASH_SYM),
hash_subr_list ())))
Vcomp_abi_hash)))
xsignal1 (Qnative_lisp_file_inconsistent, comp_u->file);
*current_thread_reloc = &current_thread;
@ -3657,6 +3668,12 @@ syms_of_comp (void)
doc: /* Hash table symbol-function -> function-c-name. For
internal use during */);
Vcomp_sym_subr_c_name_h = CALLN (Fmake_hash_table);
DEFVAR_LISP ("comp-abi-hash", Vcomp_abi_hash,
doc: /* String signing the ABI exposed to .eln files. */);
Vcomp_abi_hash = Qnil;
DEFVAR_LISP ("comp-native-path-postfix", Vcomp_native_path_postfix,
doc: /* Postifix to be added to the .eln compilation path. */);
Vcomp_native_path_postfix = Qnil;
}
#endif /* HAVE_NATIVE_COMP */

View file

@ -61,8 +61,12 @@ XNATIVE_COMP_UNIT (Lisp_Object a)
}
/* Defined in comp.c. */
extern void hash_native_abi (void);
extern void load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u,
bool loading_dump);
extern void syms_of_comp (void);
#endif
#endif

View file

@ -1949,6 +1949,11 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
keys_of_keyboard ();
keys_of_keymap ();
keys_of_window ();
#ifdef HAVE_NATIVE_COMP
/* Must be after the last defsubr has run. */
hash_native_abi ();
#endif
}
else
{

View file

@ -1068,7 +1068,7 @@ effective_load_path (void)
Lisp_Object el = XCAR (lp);
new_lp =
Fcons (concat2 (Ffile_name_as_directory (el),
Vsystem_configuration),
Vcomp_native_path_postfix),
new_lp);
new_lp = Fcons (el, new_lp);
}
@ -4427,6 +4427,7 @@ defsubr (union Aligned_Lisp_Subr *aname)
XSETSUBR (tem, sname);
set_symbol_function (sym, tem);
#ifdef HAVE_NATIVE_COMP
eassert (NILP (Vcomp_abi_hash));
Vcomp_subr_list = Fpurecopy (Fcons (tem, Vcomp_subr_list));
#endif
}