all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Gerd Möllmann" <gerd.moellmann@gmail.com>
To: Helmut Eller <eller.helmut@gmail.com>
Cc: Andrea Corallo <acorallo@gnu.org>,
	 Emacs Devel <emacs-devel@gnu.org>, Eli Zaretskii <eliz@gnu.org>
Subject: Re: MPS: Please check if scratch/igc builds with native compilation
Date: Fri, 24 May 2024 15:01:31 +0200	[thread overview]
Message-ID: <m2le3zcqj8.fsf@pro2.fritz.box> (raw)
In-Reply-To: <m2sey752h5.fsf@pro2.fritz.box> ("Gerd Möllmann"'s message of "Fri, 24 May 2024 05:10:46 +0200")

[-- Attachment #1: Type: text/plain, Size: 1891 bytes --]

Gerd Möllmann <gerd.moellmann@gmail.com> writes:

> Helmut Eller <eller.helmut@gmail.com> writes:
>
>> On Thu, May 23 2024, Gerd Möllmann wrote:
>>
>>> Thanks, but it didn't help, I'm afraid.
>>
>> There's some checking code in comp.c.  Maybe you could add  this
>>
>>   void
>>   check_all_comp_units (void)
>>   {
>>     igc_collect ();
>>     struct Lisp_Hash_Table *h = XHASH_TABLE (Vcomp_loaded_comp_units_h);
>>     DOHASH (h, k, cu)
>>       {
>>         eassert (NATIVE_COMP_UNITP (cu));
>>         fprintf (stderr, "key: %s\n", SSDATA (k));
>>         check_comp_unit_relocs (XNATIVE_COMP_UNIT (cu));
>>       }
>>   }
>>   
>> and call it from the debugger.  If this check passes then I think the
>> relocs are in pretty good shape.
>
> Thanks for helping me!
>
> Since I'm not sure if relocs are the culprit this time around, I'll also
> add the roots for a dylib very early, so that there is no "reasonable"
> doubt they exist. I'll use this fact:
>
>   .../igc/native-lisp/30_0_50-5cce80dd % nm -g -s __DATA __common radix-tree-669a468d-316fbcdc.eln   
>   00000000000050e0 S _comp_unit
>   00000000000050e8 S _current_thread_reloc
>   00000000000050f0 S _d_reloc
>   0000000000005220 S _d_reloc_eph
>   00000000000053d8 S _d_reloc_imp
>   0000000000005438 S _f_symbols_with_pos_enabled_reloc
>   0000000000005440 S _freloc_link_table
>   0000000000005448 S _pure_reloc
>
> IOW, I can compute the sizes of the reloc arrays from symbol addresses.
> (On macOS, the format is Mach-O, the segment/section names are probably
> different in ELF).
>
> Let's see. But I need to collect enough energy for doing this first ;-).

Given the choice of either ironing or trying what I described above, I
evaded ironing. Diff at the end. Effect none. Which lets me update my
beliefs so that relocs are unlikely to be the cause this time.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: roots --]
[-- Type: text/x-patch, Size: 3890 bytes --]

Unstaged
modified   lisp/emacs-lisp/comp.el
@@ -68,7 +68,7 @@ native-comp-speed
   :safe #'integerp
   :version "28.1")
 
-(defcustom native-comp-debug 0
+(defcustom native-comp-debug 2
   "Debug level for native compilation, a number between 0 and 3.
 This is intended for debugging the compiler itself.
   0 no debug output.
modified   src/comp.c
@@ -5322,6 +5322,32 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump,
   Lisp_Object comp_u_lisp_obj;
   XSETNATIVE_COMP_UNIT (comp_u_lisp_obj, comp_u);
 
+# ifdef HAVE_MPS
+  {
+    comp_u->comp_unit = dynlib_sym (handle, COMP_UNIT_SYM);
+    comp_u->data_relocs = dynlib_sym (handle, DATA_RELOC_SYM);
+    comp_u->data_imp_relocs = dynlib_sym (handle, DATA_RELOC_IMPURE_SYM);
+    comp_u->data_eph_relocs = dynlib_sym (handle, DATA_RELOC_EPHEMERAL_SYM);
+    Lisp_Object *f_symbols_with_pos_enabled_reloc
+      = dynlib_sym (handle, F_SYMBOLS_WITH_POS_ENABLED_RELOC_SYM);
+
+    comp_u->n_data_relocs = comp_u->data_eph_relocs - comp_u->data_relocs;
+    comp_u->n_data_eph_relocs = comp_u->data_imp_relocs - comp_u->data_eph_relocs;
+    comp_u->n_data_imp_relocs = f_symbols_with_pos_enabled_reloc - comp_u->data_imp_relocs;
+
+    comp_u->comp_unit_root = igc_root_create_n (comp_u->comp_unit, 1);
+    if (comp_u->n_data_relocs)
+      comp_u->data_relocs_root
+	= igc_root_create_n (comp_u->data_relocs, comp_u->n_data_relocs);
+    if (comp_u->n_data_eph_relocs)
+      comp_u->data_eph_relocs_root
+	= igc_root_create_n (comp_u->data_eph_relocs, comp_u->n_data_eph_relocs);
+    if (comp_u->n_data_imp_relocs)
+      comp_u->data_imp_relocs_root
+	= igc_root_create_n (comp_u->data_imp_relocs, comp_u->n_data_imp_relocs);
+  }
+#endif
+
   Lisp_Object *saved_cu = dynlib_sym (handle, COMP_UNIT_SYM);
   if (!saved_cu)
     xsignal1 (Qnative_lisp_file_inconsistent, comp_u->file);
@@ -5366,11 +5392,6 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump,
   /* Always set data_imp_relocs pointer in the compilation unit (in can be
      used in 'dump_do_dump_relocation').  */
   comp_u->data_imp_relocs = dynlib_sym (handle, DATA_RELOC_IMPURE_SYM);
-#ifdef HAVE_MPS
-  comp_u->data_relocs = dynlib_sym (handle, DATA_RELOC_SYM);
-  comp_u->comp_unit = dynlib_sym (handle, COMP_UNIT_SYM);
-  comp_u->comp_unit_root = igc_root_create_n (saved_cu, 1);
-#endif
 
   if (!comp_u->loaded_once)
     {
@@ -5418,19 +5439,14 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump,
 
       EMACS_INT d_vec_len = XFIXNUM (Flength (comp_u->data_vec));
 #ifdef HAVE_MPS
-      comp_u->n_data_relocs = d_vec_len;
-      if (d_vec_len > 0)
-	comp_u->data_relocs_root = igc_root_create_n (data_relocs, d_vec_len);
+      eassert (comp_u->n_data_relocs == d_vec_len);
 #endif
       for (EMACS_INT i = 0; i < d_vec_len; i++)
 	data_relocs[i] = AREF (comp_u->data_vec, i);
 
       d_vec_len = XFIXNUM (Flength (comp_u->data_impure_vec));
 #ifdef HAVE_MPS
-      comp_u->n_data_imp_relocs = d_vec_len;
-      if (d_vec_len > 0)
-	comp_u->data_imp_relocs_root
-	  = igc_root_create_n (data_imp_relocs, d_vec_len);
+      eassert (comp_u->n_data_imp_relocs == d_vec_len);
 #endif
       for (EMACS_INT i = 0; i < d_vec_len; i++)
 	data_imp_relocs[i] = AREF (comp_u->data_impure_vec, i);
@@ -5461,11 +5477,7 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump,
 # ifdef HAVE_MPS
 	  /* FIXME: If we want to get rid of these objects, stop tracing
 	     these references at some point.  */
-	  comp_u->data_eph_relocs = data_eph_relocs;
-	  comp_u->n_data_eph_relocs = d_vec_len;
-	  if (d_vec_len > 0)
-	    comp_u->data_eph_relocs_root
-	      = igc_root_create_n (data_eph_relocs, d_vec_len);
+	  eassert (comp_u->n_data_eph_relocs = d_vec_len);
 # endif
 	  for (EMACS_INT i = 0; i < d_vec_len; i++)
 	    data_eph_relocs[i] = AREF (data_ephemeral_vec, i);


  reply	other threads:[~2024-05-24 13:01 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21 14:00 MPS: Please check if scratch/igc builds with native compilation Gerd Möllmann
2024-05-21 16:57 ` Andrea Corallo
2024-05-21 17:02   ` Gerd Möllmann
2024-05-21 17:06   ` Gerd Möllmann
2024-05-21 17:57     ` Andrea Corallo
2024-05-21 18:09       ` Gerd Möllmann
2024-05-21 18:17         ` Andrea Corallo
2024-05-21 19:00           ` Gerd Möllmann
2024-05-21 19:05             ` Andrea Corallo
2024-05-21 19:08               ` Gerd Möllmann
2024-05-21 19:20                 ` Andrea Corallo
2024-05-21 19:21                 ` Eli Zaretskii
2024-05-21 19:23                   ` Gerd Möllmann
2024-05-21 18:35         ` Eli Zaretskii
2024-05-21 18:34       ` Helmut Eller
2024-05-21 18:46         ` Andrea Corallo
2024-05-21 19:10           ` Helmut Eller
2024-05-21 19:17             ` Andrea Corallo
2024-05-21 19:35               ` Andrea Corallo
2024-05-21 19:38                 ` Gerd Möllmann
2024-05-21 19:50                   ` Andrea Corallo
2024-05-21 19:22             ` Eli Zaretskii
2024-05-21 19:28               ` Andrea Corallo
2024-05-22  5:43     ` Helmut Eller
2024-05-22  6:07       ` Gerd Möllmann
2024-05-22  6:27         ` Gerd Möllmann
2024-05-22  6:34         ` Helmut Eller
2024-05-22  6:56           ` Gerd Möllmann
2024-05-22  7:59             ` Helmut Eller
2024-05-22  8:46               ` Gerd Möllmann
2024-05-22 18:03                 ` Gerd Möllmann
2024-05-23  6:12                   ` Gerd Möllmann
2024-05-23  6:38                     ` Helmut Eller
2024-05-23  6:58                       ` Gerd Möllmann
2024-05-23  6:40                     ` Helmut Eller
2024-05-23  6:58                       ` Gerd Möllmann
2024-05-23  7:12                         ` Helmut Eller
2024-05-23  7:35                           ` Gerd Möllmann
2024-05-23  7:38                           ` Andrea Corallo
2024-05-23  7:50                     ` Andrea Corallo
2024-05-23  7:52                       ` Gerd Möllmann
2024-05-23  7:57                         ` Gerd Möllmann
2024-05-23  8:12                         ` Helmut Eller
2024-05-23  8:18                           ` Gerd Möllmann
2024-05-23  8:42                             ` Andrea Corallo
2024-05-23  9:06                               ` Helmut Eller
2024-05-23  9:14                                 ` Gerd Möllmann
2024-05-23  9:39                                   ` Helmut Eller
2024-05-23 10:19                                     ` Gerd Möllmann
2024-05-23 10:35                                       ` Ihor Radchenko
2024-05-23 11:27                                         ` Gerd Möllmann
2024-05-23 12:15                                       ` Andrea Corallo
2024-05-23 14:46                                       ` Helmut Eller
2024-05-23 16:40                                         ` Gerd Möllmann
2024-05-23 18:26                                           ` Helmut Eller
2024-05-24  3:10                                             ` Gerd Möllmann
2024-05-24 13:01                                               ` Gerd Möllmann [this message]
2024-05-24 14:19                                                 ` Helmut Eller
2024-05-25  7:37                                                   ` Gerd Möllmann
2024-05-25 14:38                                                     ` Gerd Möllmann
2024-05-25 15:02                                                     ` Andrea Corallo
2024-05-25 15:07                                                       ` Gerd Möllmann
2024-05-25 15:26                                                         ` Andrea Corallo
2024-05-25 15:29                                                           ` Gerd Möllmann
2024-05-25 20:04                                                             ` Andrea Corallo
2024-05-25 15:11                                                       ` Eli Zaretskii
2024-05-26  7:39                                                         ` Gerd Möllmann
2024-05-23 12:09                                   ` Andrea Corallo
2024-05-23  8:30                     ` Ihor Radchenko
2024-05-22  8:18 ` Helmut Eller
2024-05-22  8:39   ` Gerd Möllmann
2024-06-03  5:35 ` Gerd Möllmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2le3zcqj8.fsf@pro2.fritz.box \
    --to=gerd.moellmann@gmail.com \
    --cc=acorallo@gnu.org \
    --cc=eliz@gnu.org \
    --cc=eller.helmut@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.