Subject: Re: bug#46256: [feature/native-comp] AOT eln files ignored if run from build tree

From: Eli Zaretskii <[email-masked]>
Date: Sun, 07 Mar 2021 21:15:45 +0200

> From: Andrea Corallo <[email-masked]>
> Cc: [email-masked], [email-masked]
> Date: Sun, 07 Mar 2021 18:53:50 +0000
> 
> > (I must say that the way the async compilations are run makes it hard
> > to track down fatal errors, because I don't even have an easy way of
> > knowing which .el file was being compiled when the crash happened.
> > Any enhancements of the logging and the diagnostic messages to help in
> > these matters will be very welcome.  E.g., how about introducing an
> > intermediate log level that would just show the currently compiled .el
> > file's name?)
> 
> Setting `comp-async-jobs-number' to 1 and looking into the
> *Async-native-compile-log* what we are looking for in this case?

Will try that next time.  But meanwhile, I got the same problem while
rebuilding after your comp.c change.  This time I clearly saw that
cc-mode.el is being compiled:

  Dumping under the name emacs.pdmp
  Dumping fingerprint: 3869e2b5d74557015002c58022bce8f2e19ba06f1636f4182d7837703d6
  22982
  Dump complete
  Byte counts: header=100 hot=7960440 discardable=158256 cold=4873352
  Reloc counts: hot=501593 discardable=5154
  Adding name emacs-28.0.50.22.exe
  Adding name emacs-28.0.50.22.pdmp
  cp -f emacs.pdmp bootstrap-emacs.pdmp
  make[1]: Leaving directory `/d/gnu/git/emacs/native-comp/src'
  make -C lisp all
  make[1]: Entering directory `/d/gnu/git/emacs/native-comp/lisp'
  make -C ../leim all EMACS="../src/emacs.exe"
  make -C ../admin/grammars all EMACS="../../src/emacs.exe"
  make[2]: Entering directory `/d/gnu/git/emacs/native-comp/admin/grammars'
  make[2]: Nothing to be done for `all'.
  make[2]: Leaving directory `/d/gnu/git/emacs/native-comp/admin/grammars'
  make[2]: Entering directory `/d/gnu/git/emacs/native-comp/leim'
  make[2]: Nothing to be done for `all'.
  make[2]: Leaving directory `/d/gnu/git/emacs/native-comp/leim'
  make[2]: Entering directory `/d/gnu/git/emacs/native-comp/lisp'
  make[2]: Nothing to be done for `compile-targets'.
  make[2]: Leaving directory `/d/gnu/git/emacs/native-comp/lisp'
  make[2]: Entering directory `/d/gnu/git/emacs/native-comp/lisp'
  make[2]: Nothing to be done for `compile-targets'.
  make[2]: Leaving directory `/d/gnu/git/emacs/native-comp/lisp'
  make[2]: Entering directory `/d/gnu/git/emacs/native-comp/lisp'
    ELC      progmodes/cc-mode.elc

  comp.h:70: Emacs fatal error: assertion failed: NATIVE_COMP_UNITP (a)

Attaching a debugger produces the backtrace shown below.  I will leave
this process captured in the debugger, in case you want me to look at
some variables and report their values.

  Thread 1 received signal SIGTRAP, Trace/breakpoint trap.
  [Switching to Thread 5500.0x114c]
  0x7c90120f in ntdll!DbgBreakPoint () from C:\WINDOWS\system32\ntdll.dll
  (gdb) bt
  #0  0x7c90120f in ntdll!DbgBreakPoint () from C:\WINDOWS\system32\ntdll.dll
  #1  0x0135a63b in emacs_abort () at w32fns.c:10914
  #2  0x0115c637 in terminate_due_to_signal (sig=22, backtrace_limit=2147483647)
      at emacs.c:417
  #3  0x0121c026 in die (msg=0x1782af2 <targets+1266> "NATIVE_COMP_UNITP (a)",
      file=0x1782aeb <targets+1259> "comp.h", line=70) at alloc.c:7452
  #4  0x012cf582 in XNATIVE_COMP_UNIT (a=XIL(0x6f04860091b9000)) at comp.h:70
  #5  0x012df324 in load_comp_unit (comp_u=0x6f33918, loading_dump=false,
      late_load=false) at comp.c:4821
  #6  0x012e0c55 in Fnative_elisp_load (filename=XIL(0x80000000092db190),
      late_load=XIL(0)) at comp.c:5122
  #7  0x012ab823 in Fload (file=XIL(0x800000000929e140), noerror=XIL(0),
      nomessage=XIL(0x30), nosuffix=XIL(0), must_suffix=XIL(0)) at lread.c:1548
  #8  0x0125dea0 in eval_sub (form=XIL(0xc000000006f72cb0)) at eval.c:2498
  #9  0x01255e60 in Fprogn (body=XIL(0xc000000006f72d30)) at eval.c:471
  #10 0x01255b71 in Fif (args=XIL(0xc000000006f733c0)) at eval.c:427
  #11 0x0125d89b in eval_sub (form=XIL(0xc000000006f73380)) at eval.c:2437
  #12 0x01255e60 in Fprogn (body=XIL(0)) at eval.c:471
  #13 0x01258b68 in Flet (args=XIL(0xc000000006f73370)) at eval.c:1057
  #14 0x0125d89b in eval_sub (form=XIL(0xc000000006f73280)) at eval.c:2437
  #15 0x01255e60 in Fprogn (body=XIL(0xc000000006f72d70)) at eval.c:471
  #16 0x0125d89b in eval_sub (form=XIL(0xc000000006f73170)) at eval.c:2437
  #17 0x01255b0d in Fif (args=XIL(0xc000000006f73160)) at eval.c:426
  #18 0x0125d89b in eval_sub (form=XIL(0xc000000006f730c0)) at eval.c:2437
  #19 0x01255e60 in Fprogn (body=XIL(0)) at eval.c:471
  #20 0x0126184b in funcall_lambda (fun=XIL(0xc000000006f72e20), nargs=1,
      arg_vector=0x82bd40) at eval.c:3286
  #21 0x01260eb0 in apply_lambda (fun=XIL(0xc000000006f72e20),
      args=XIL(0xc000000006dce870), count=74) at eval.c:3158
  #22 0x0125e5d7 in eval_sub (form=XIL(0xc000000006dce860)) at eval.c:2561
  #23 0x0125d117 in Feval (form=XIL(0xc000000006dce860), lexical=XIL(0))
      at eval.c:2313
  #24 0x7058ea18 in F627974652d636f6d70696c652d6576616c_byte_compile_eval_0 ()
     from d:\usr\eli\.emacs.d\eln-cache\28.0.50-19fa14f1\bytecomp-12882072-bfe84587.eln
  #25 0x01260731 in funcall_subr (subr=0x6781548, numargs=1, args=0x82c1c0)
      at eval.c:3084
  #26 0x012601a5 in Ffuncall (nargs=2, args=0x82c1b8) at eval.c:3009
  #27 0x012cbaa4 in exec_byte_code (bytestr=XIL(0x8000000006978310),
      vector=XIL(0xa000000006f338b0), maxdepth=make_fixnum(6),
      args_template=make_fixnum(257), nargs=1, args=0x82c788) at bytecode.c:632
  #28 0x01260cea in fetch_and_exec_byte_code (fun=XIL(0xa000000006f338e8),
      syms_left=make_fixnum(257), nargs=1, args=0x82c780) at eval.c:3133
  #29 0x01261267 in funcall_lambda (fun=XIL(0xa000000006f338e8), nargs=1,
      arg_vector=0x82c780) at eval.c:3214
  #30 0x01260215 in Ffuncall (nargs=2, args=0x82c778) at eval.c:3013
  #31 0x7058a138 in F627974652d636f6d70696c652d726563757273652d746f706c6576656c_byte_compile_recurse_toplevel_0 ()
     from d:\usr\eli\.emacs.d\eln-cache\28.0.50-19fa14f1\bytecomp-12882072-bfe84587.eln
  #32 0x01260760 in funcall_subr (subr=0x676d838, numargs=2, args=0x82c980)
      at eval.c:3086
  #33 0x012601a5 in Ffuncall (nargs=3, args=0x82c978) at eval.c:3009
  #34 0x012cbaa4 in exec_byte_code (bytestr=XIL(0x8000000006978320),
      vector=XIL(0xa000000006bad3f8), maxdepth=make_fixnum(7),
      args_template=make_fixnum(128), nargs=1, args=0x82cfb8) at bytecode.c:632
  #35 0x01260cea in fetch_and_exec_byte_code (fun=XIL(0xa000000006bad430),
      syms_left=make_fixnum(128), nargs=1, args=0x82cfb8) at eval.c:3133
  #36 0x01261267 in funcall_lambda (fun=XIL(0xa000000006bad430), nargs=1,
      arg_vector=0x82cfb8) at eval.c:3214
  #37 0x01260215 in Ffuncall (nargs=2, args=0x82cfb0) at eval.c:3013
  #38 0x0125e79e in Fapply (nargs=2, args=0x82cfb0) at eval.c:2596
  #39 0x0125f441 in apply1 (fn=XIL(0xa000000006bad430),
      arg=XIL(0xc000000006dc7930)) at eval.c:2855
  #40 0x0125904c in Fmacroexpand (form=XIL(0xc000000006dc7920),
      environment=XIL(0xc000000006f6de10)) at eval.c:1142
  #41 0x01260760 in funcall_subr (subr=0x172f780 <Smacroexpand>, numargs=2,
      args=0x82d270) at eval.c:3086
  #42 0x012601a5 in Ffuncall (nargs=3, args=0x82d268) at eval.c:3009
  #43 0x06a53c20 in F6d6163726f6578702d6d6163726f657870616e64_macroexp_macroexpand_0 ()
     from d:\gnu\git\emacs\native-comp\native-lisp\28.0.50-19fa14f1\macroexp-2c3e1495-db4ee70f.eln
  #44 0x01260760 in funcall_subr (subr=0x5f12cb4, numargs=2, args=0x82d4b0)
      at eval.c:3086
  #45 0x012601a5 in Ffuncall (nargs=3, args=0x82d4a8) at eval.c:3009
  #46 0x7058a0c5 in F627974652d636f6d70696c652d726563757273652d746f706c6576656c_byte_compile_recurse_toplevel_0 ()
     from d:\usr\eli\.emacs.d\eln-cache\28.0.50-19fa14f1\bytecomp-12882072-bfe84587.eln
  #47 0x01260760 in funcall_subr (subr=0x676d838, numargs=2, args=0x82d698)
      at eval.c:3086
  #48 0x012601a5 in Ffuncall (nargs=3, args=0x82d690) at eval.c:3009
  #49 0x012cbaa4 in exec_byte_code (bytestr=XIL(0x8000000006970bc0),
      vector=XIL(0xa000000006f1ab58), maxdepth=make_fixnum(4),
      args_template=make_fixnum(257), nargs=1, args=0x82dc40) at bytecode.c:632
  #50 0x01260cea in fetch_and_exec_byte_code (fun=XIL(0xa000000006f33880),
      syms_left=make_fixnum(257), nargs=1, args=0x82dc38) at eval.c:3133
  #51 0x01261267 in funcall_lambda (fun=XIL(0xa000000006f33880), nargs=1,
      arg_vector=0x82dc38) at eval.c:3214
  #52 0x01260215 in Ffuncall (nargs=2, args=0x82dc30) at eval.c:3013
  #53 0x0125f4b8 in call1 (fn=XIL(0xa000000006f33880),
      arg1=XIL(0xc000000006dc7920)) at eval.c:2869
  #54 0x01274ff2 in mapcar1 (leni=2, vals=0x82dd20, fn=XIL(0xa000000006f33880),
      seq=XIL(0xc000000006dc78e0)) at fns.c:2742
  #55 0x0127566b in Fmapcar (function=XIL(0xa000000006f33880),
      sequence=XIL(0xc000000006dc78e0)) at fns.c:2798
  #56 0x7058a1a6 in F627974652d636f6d70696c652d726563757273652d746f706c6576656c_byte_compile_recurse_toplevel_0 ()
     from d:\usr\eli\.emacs.d\eln-cache\28.0.50-19fa14f1\bytecomp-12882072-bfe84587.eln
  #57 0x01260760 in funcall_subr (subr=0x676d838, numargs=2, args=0x82dfd0)
      at eval.c:3086
  #58 0x012601a5 in Ffuncall (nargs=3, args=0x82dfc8) at eval.c:3009
  #59 0x7059c5f3 in F627974652d636f6d70696c652d746f706c6576656c2d66696c652d666f726d_byte_compile_toplevel_file_form_0 ()
     from d:\usr\eli\.emacs.d\eln-cache\28.0.50-19fa14f1\bytecomp-12882072-bfe84587.eln
  #60 0x01260731 in funcall_subr (subr=0x6783f18, numargs=1, args=0x82e1e8)
      at eval.c:3084
  #61 0x012601a5 in Ffuncall (nargs=2, args=0x82e1e0) at eval.c:3009
  #62 0x7059999c in F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_43 ()
     from d:\usr\eli\.emacs.d\eln-cache\28.0.50-19fa14f1\bytecomp-12882072-bfe84587.eln
  #63 0x01260731 in funcall_subr (subr=0x686e450, numargs=1, args=0x82e418)
      at eval.c:3084
  #64 0x012601a5 in Ffuncall (nargs=2, args=0x82e410) at eval.c:3009
  #65 0x7059a9f1 in F627974652d636f6d70696c652d66726f6d2d627566666572_byte_compile_from_buffer_0 ()
     from d:\usr\eli\.emacs.d\eln-cache\28.0.50-19fa14f1\bytecomp-12882072-bfe84587.eln
  #66 0x01260731 in funcall_subr (subr=0x6783d58, numargs=1, args=0x82e6b8)
      at eval.c:3084
  #67 0x012601a5 in Ffuncall (nargs=2, args=0x82e6b0) at eval.c:3009
  #68 0x70597650 in F627974652d636f6d70696c652d66696c65_byte_compile_file_0 ()
     from d:\usr\eli\.emacs.d\eln-cache\28.0.50-19fa14f1\bytecomp-12882072-bfe84587.eln
  #69 0x01260760 in funcall_subr (subr=0x6783cd8, numargs=1, args=0x82e8d0)
      at eval.c:3086
  #70 0x012601a5 in Ffuncall (nargs=2, args=0x82e8c8) at eval.c:3009
  #71 0x705bb19f in F62617463682d627974652d636f6d70696c652d66696c65_batch_byte_compile_file_0 ()
     from d:\usr\eli\.emacs.d\eln-cache\28.0.50-19fa14f1\bytecomp-12882072-bfe84587.eln
  #72 0x01260731 in funcall_subr (subr=0x68d04b8, numargs=1, args=0x82eb08)
      at eval.c:3084
  #73 0x012601a5 in Ffuncall (nargs=2, args=0x82eb00) at eval.c:3009
  #74 0x705bac80 in F62617463682d627974652d636f6d70696c65_batch_byte_compile_0
      ()
     from d:\usr\eli\.emacs.d\eln-cache\28.0.50-19fa14f1\bytecomp-12882072-bfe84587.eln
  #75 0x01260731 in funcall_subr (subr=0x68d0478, numargs=0, args=0x82ed68)
      at eval.c:3084
  #76 0x012601a5 in Ffuncall (nargs=1, args=0x82ed60) at eval.c:3009
  #77 0x6ec8a3c8 in F62617463682d627974652d6e61746976652d636f6d70696c652d666f722d626f6f747374726170_batch_byte_native_compile_for_bootstrap_0 ()
     from d:\gnu\git\emacs\native-comp\native-lisp\28.0.50-19fa14f1\comp-7672a6ed-f22bd338.eln
  #78 0x01260715 in funcall_subr (subr=0x6dabb48, numargs=0, args=0x82eff8)
      at eval.c:3082
  #79 0x012601a5 in Ffuncall (nargs=1, args=0x82eff0) at eval.c:3009
  #80 0x6cb55791 in F636f6d6d616e642d6c696e652d31_command_line_1_0 ()
     from d:\gnu\git\emacs\native-comp\native-lisp\28.0.50-19fa14f1\startup-bbc6ea72-9be7c541.eln
  #81 0x01260731 in funcall_subr (subr=0x5db726c, numargs=1, args=0x82f3e8)
      at eval.c:3084
  #82 0x012601a5 in Ffuncall (nargs=2, args=0x82f3e0) at eval.c:3009
  #83 0x6cb4b0a9 in F636f6d6d616e642d6c696e65_command_line_0 ()
     from d:\gnu\git\emacs\native-comp\native-lisp\28.0.50-19fa14f1\startup-bbc6ea72-9be7c541.eln
  #84 0x01260715 in funcall_subr (subr=0x5dc92bc, numargs=0, args=0x82f638)
      at eval.c:3082
  #85 0x012601a5 in Ffuncall (nargs=1, args=0x82f630) at eval.c:3009
  #86 0x6cb45d8b in F6e6f726d616c2d746f702d6c6576656c_normal_top_level_0 ()
     from d:\gnu\git\emacs\native-comp\native-lisp\28.0.50-19fa14f1\startup-bbc6ea72-9be7c541.eln
  #87 0x0125dc63 in eval_sub (form=XIL(0xc000000005db0d7c)) at eval.c:2481
  #88 0x0125d117 in Feval (form=XIL(0xc000000005db0d7c), lexical=XIL(0))
      at eval.c:2313
  #89 0x01164353 in top_level_2 () at keyboard.c:1103
  #90 0x0125a135 in internal_condition_case (bfun=0x1164320 <top_level_2>,
      handlers=XIL(0x90), hfun=0x1163ad1 <cmd_error>) at eval.c:1448
  #91 0x011643cd in top_level_1 (ignore=XIL(0)) at keyboard.c:1111
  #92 0x01259218 in internal_catch (tag=XIL(0xedf0),
      func=0x1164359 <top_level_1>, arg=XIL(0)) at eval.c:1198
  #93 0x01164225 in command_loop () at keyboard.c:1072
  #94 0x01163561 in recursive_edit_1 () at keyboard.c:720
  #95 0x011637cf in Frecursive_edit () at keyboard.c:789
  #96 0x0115ee6e in main (argc=11, argv=0xa4ea88) at emacs.c:2095

  Lisp Backtrace:
  "load" (0x82b378)
  "if" (0x82b5a8)
  "let" (0x82b838)
  "progn" (0x82b9e8)
  "if" (0x82bb98)
  "cc-bytecomp-load" (0x82bd40)
  "byte-compile-eval" (0x82c1c0)
  0x6f338e8 PVEC_COMPILED
  "byte-compile-recurse-toplevel" (0x82c980)
  0x6bad430 PVEC_COMPILED
  "macroexpand" (0x82d270)
  "macroexp-macroexpand" (0x82d4b0)
  "byte-compile-recurse-toplevel" (0x82d698)
  0x6f33880 PVEC_COMPILED
  "byte-compile-recurse-toplevel" (0x82dfd0)
  "byte-compile-toplevel-file-form" (0x82e1e8)
  0x686e450 PVEC_SUBR
  "byte-compile-from-buffer" (0x82e6b8)
  "byte-compile-file" (0x82e8d0)
  "batch-byte-compile-file" (0x82eb08)
  "batch-byte-compile" (0x82ed68)
  "batch-byte-native-compile-for-bootstrap" (0x82eff8)
  "command-line-1" (0x82f3e8)
  "command-line" (0x82f638)
  "normal-top-level" (0x82f728)