From 4478d21b5548b084bb365b2ee5a3364a576076ca Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sat, 8 Mar 2025 21:58:19 +0800 Subject: [PATCH] ; Enable pdumper on some buggy versions of Sun C * src/pdumper.c (dump_sort_copied_objects, drain_reloc_list) (dump_do_fixups, dump_do_dump_relocation): Do not expand Fnreverse multiple times in CALLN. Sun C 5.12 evaluates the arguments to array initializers to which it expands, which clobbers the lists being reversed. (cherry picked from commit b36abc76ae3583ae30f9883ca276ff66d522bac1) --- src/pdumper.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/pdumper.c b/src/pdumper.c index 7a8c5bba9ad..342c37b5e62 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -3388,13 +3388,16 @@ dump_metadata_for_pdumper (struct dump_context *ctx) static void dump_sort_copied_objects (struct dump_context *ctx) { + Lisp_Object queue_reversed; + + queue_reversed = Fnreverse (ctx->copied_queue); /* Sort the objects into the order in which they'll appear in the Emacs: this way, on startup, we'll do both the IO from the dump file and the copy into Emacs in-order, where prefetch will be most effective. */ - ctx->copied_queue = - CALLN (Fsort, Fnreverse (ctx->copied_queue), - Qdump_emacs_portable__sort_predicate_copied); + ctx->copied_queue + = CALLN (Fsort, queue_reversed, + Qdump_emacs_portable__sort_predicate_copied); } /* Dump parts of copied objects we need at runtime. */ @@ -3959,9 +3962,11 @@ drain_reloc_list (struct dump_context *ctx, struct dump_table_locator *out_locator) { struct dump_flags old_flags = ctx->flags; + Lisp_Object list_reversed, relocs; ctx->flags.pack_objects = true; - Lisp_Object relocs = CALLN (Fsort, Fnreverse (*reloc_list), - Qdump_emacs_portable__sort_predicate); + list_reversed = Fnreverse (*reloc_list); + relocs = CALLN (Fsort, list_reversed, + Qdump_emacs_portable__sort_predicate); *reloc_list = Qnil; dump_align_output (ctx, max (alignof (struct dump_reloc), alignof (struct emacs_reloc))); @@ -4082,8 +4087,9 @@ static void dump_do_fixups (struct dump_context *ctx) { dump_off saved_offset = ctx->offset; - Lisp_Object fixups = CALLN (Fsort, Fnreverse (ctx->fixups), - Qdump_emacs_portable__sort_predicate); + Lisp_Object fixups_reversed = Fnreverse (ctx->fixups); + Lisp_Object fixups = CALLN (Fsort, fixups_reversed, + Qdump_emacs_portable__sort_predicate); Lisp_Object prev_fixup = Qnil; ctx->fixups = Qnil; while (!NILP (fixups)) @@ -5430,8 +5436,8 @@ dump_do_dump_relocation (const uintptr_t dump_base, case RELOC_NATIVE_COMP_UNIT: { static enum { UNKNOWN, LOCAL_BUILD, INSTALLED } installation_state; - struct Lisp_Native_Comp_Unit *comp_u = - dump_ptr (dump_base, reloc_offset); + struct Lisp_Native_Comp_Unit *comp_u + = dump_ptr (dump_base, reloc_offset); comp_u->lambda_gc_guard_h = CALLN (Fmake_hash_table, QCtest, Qeq); if (STRINGP (comp_u->file)) error ("trying to load incoherent dumped eln file %s", -- 2.39.5