aboutsummaryrefslogtreecommitdiffstats
path: root/src/comp.c
diff options
context:
space:
mode:
authorAndreaCorallo2020-03-03 22:23:41 +0000
committerAndrea Corallo2020-03-03 22:23:41 +0000
commit43b6f05dfb46637a414520b27430fbe3b0f005fa (patch)
tree6c9a0e6a10a37644e1e6ca813e33db2b5157d25e /src/comp.c
parentf77f6ca77054ca6122df2742345710b7493ad293 (diff)
downloademacs-43b6f05dfb46637a414520b27430fbe3b0f005fa.tar.gz
emacs-43b6f05dfb46637a414520b27430fbe3b0f005fa.zip
Hash eln ABI once and add it to the output compilation path
Diffstat (limited to 'src/comp.c')
-rw-r--r--src/comp.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/comp.c b/src/comp.c
index 425784b9810..4940ae52b3d 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -250,8 +250,8 @@ format_string (const char *format, ...)
250 250
251/* Produce a key hashing Vcomp_subr_list. */ 251/* Produce a key hashing Vcomp_subr_list. */
252 252
253static Lisp_Object 253void
254hash_subr_list (void) 254hash_native_abi (void)
255{ 255{
256 Lisp_Object string = Fmapconcat (intern_c_string ("subr-name"), 256 Lisp_Object string = Fmapconcat (intern_c_string ("subr-name"),
257 Vcomp_subr_list, build_string (" ")); 257 Vcomp_subr_list, build_string (" "));
@@ -260,7 +260,17 @@ hash_subr_list (void)
260 sha512_buffer (SSDATA (string), SCHARS (string), SSDATA (digest)); 260 sha512_buffer (SSDATA (string), SCHARS (string), SSDATA (digest));
261 hexbuf_digest (SSDATA (digest), SDATA (digest), SHA512_DIGEST_SIZE); 261 hexbuf_digest (SSDATA (digest), SDATA (digest), SHA512_DIGEST_SIZE);
262 262
263 return digest; 263 /* Check runs once. */
264 eassert (Vcomp_abi_hash);
265 Vcomp_abi_hash = digest;
266 /* If 10 characters are usually sufficient for git I guess 16 are
267 fine for us here. */
268 Vcomp_native_path_postfix =
269 concat3 (Vsystem_configuration,
270 make_string ("-", 1),
271 Fsubstring_no_properties (Vcomp_abi_hash,
272 make_fixnum (0),
273 make_fixnum (16)));
264} 274}
265 275
266static void 276static void
@@ -1976,8 +1986,9 @@ emit_ctxt_code (void)
1976 fields[n_frelocs++] = xmint_pointer (XCDR (el)); 1986 fields[n_frelocs++] = xmint_pointer (XCDR (el));
1977 } 1987 }
1978 1988
1979 /* Compute and store function link table hash. */ 1989 /* Sign the .eln for the exposed ABI it expects at load. */
1980 emit_static_object (LINK_TABLE_HASH_SYM, hash_subr_list ()); 1990 eassert (!NILP (Vcomp_abi_hash));
1991 emit_static_object (LINK_TABLE_HASH_SYM, Vcomp_abi_hash);
1981 1992
1982 Lisp_Object subr_l = Vcomp_subr_list; 1993 Lisp_Object subr_l = Vcomp_subr_list;
1983 FOR_EACH_TAIL (subr_l) 1994 FOR_EACH_TAIL (subr_l)
@@ -3430,7 +3441,7 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump)
3430 && freloc_link_table 3441 && freloc_link_table
3431 && top_level_run) 3442 && top_level_run)
3432 || NILP (Fstring_equal (load_static_obj (comp_u, LINK_TABLE_HASH_SYM), 3443 || NILP (Fstring_equal (load_static_obj (comp_u, LINK_TABLE_HASH_SYM),
3433 hash_subr_list ()))) 3444 Vcomp_abi_hash)))
3434 xsignal1 (Qnative_lisp_file_inconsistent, comp_u->file); 3445 xsignal1 (Qnative_lisp_file_inconsistent, comp_u->file);
3435 3446
3436 *current_thread_reloc = &current_thread; 3447 *current_thread_reloc = &current_thread;
@@ -3657,6 +3668,12 @@ syms_of_comp (void)
3657 doc: /* Hash table symbol-function -> function-c-name. For 3668 doc: /* Hash table symbol-function -> function-c-name. For
3658 internal use during */); 3669 internal use during */);
3659 Vcomp_sym_subr_c_name_h = CALLN (Fmake_hash_table); 3670 Vcomp_sym_subr_c_name_h = CALLN (Fmake_hash_table);
3671 DEFVAR_LISP ("comp-abi-hash", Vcomp_abi_hash,
3672 doc: /* String signing the ABI exposed to .eln files. */);
3673 Vcomp_abi_hash = Qnil;
3674 DEFVAR_LISP ("comp-native-path-postfix", Vcomp_native_path_postfix,
3675 doc: /* Postifix to be added to the .eln compilation path. */);
3676 Vcomp_native_path_postfix = Qnil;
3660} 3677}
3661 3678
3662#endif /* HAVE_NATIVE_COMP */ 3679#endif /* HAVE_NATIVE_COMP */