Subject: bug#63365: AW: bug#63365: 30.0.50; GCC 13.1 breaks building Emacs with native-compilation

From: Cyril Arnould <[email-masked]>
Date: Thu, 29 Jun 2023 09:16:42 +0000

> before getting into the diff of the binary given we can use objdump (I
> understand it only now sorry) I suggest we compare function sizes with
> objdump -t.

I'm not sure I follow, so let me be more explicit: The attached archive
contains the thread.o files from both runs, renamed to
'thread-foptimize-sibling-calls.o' and
'thread-fno-optimize-sibling-calls.o', respectively. This is mostly in
case someone wants to generate their own dumps.

Next, there's two text files for each that were generated using 'objdump
-d -S' as Eli suggested; 'foptimize-sibling-calls.txt' and
'fno-optimize-sibling-calls.txt'. There's also a diff of the two in
'diff.txt', generated with 'diff -ubBw'.

I noticed that in the diff, quite a lot of differences simply come down
to addresses, so I edited the objdumps of both files by hand by
replacing the addresses with ****. Those files are
'fno-optimize-sibling-calls-addr.txt' and
'foptimize-sibling-calls-addr.txt'. This greatly reduced their diff,
which is provided in 'diff-addr.txt'.

Now, as for objdump -t: I've attached the dumps and diff in this mail.

> Also I'm assuming we are 100% sure the culprint is thread.o, given the
> bug looks not very reproducible I'd repeat the test a couple of times to
> be super sure we have identified the culprint.

I did run it several times, I found it by doing a binary search over the
.c files in the src folder (i.e. I compiled half the .c files with the
optimization and half of them without it, then repeated with the
succeeding half). I can't recall a single run where the build succeeded
when thread.c was compiled with -foptimize-sibling-calls. Conversely,
the build so far never failed when thread.c was compiled with
-fno-optimize-sibling-calls.

--- foptimize-sibling-calls-dumpt.txt	2023-06-29 10:49:09 +0000
+++ fno-optimize-sibling-calls-dumpt.txt	2023-06-29 11:08:25 +0000
@@ -1,5 +1,5 @@
 
-thread-foptimize-sibling-calls.o:     file format pe-x86-64
+thread-fno-optimize-sibling-calls.o:     file format pe-x86-64
 
 SYMBOL TABLE:
 [  0](sec -2)(fl 0x00)(ty    0)(scl 103) (nx 1) 0x0000000000000000 thread.c
@@ -28,37 +28,37 @@
 [ 23](sec  1)(fl 0x00)(ty   20)(scl   3) (nx 0) 0x0000000000000700 post_acquire_global_lock
 [ 24](sec  1)(fl 0x00)(ty   20)(scl   3) (nx 0) 0x00000000000007b0 mutex_lock_callback
 [ 25](sec  1)(fl 0x00)(ty   20)(scl   3) (nx 0) 0x00000000000007f0 thread_join_callback
-[ 26](sec  1)(fl 0x00)(ty   20)(scl   3) (nx 0) 0x0000000000000870 mutex_unlock_callback
-[ 27](sec  1)(fl 0x00)(ty   20)(scl   3) (nx 0) 0x00000000000008c0 condition_wait_callback
-[ 28](sec  1)(fl 0x00)(ty   20)(scl   3) (nx 0) 0x0000000000000960 thread_signal_callback
-[ 29](sec  1)(fl 0x00)(ty   20)(scl   3) (nx 0) 0x0000000000000990 condition_notify_callback
-[ 30](sec  1)(fl 0x00)(ty   20)(scl   3) (nx 0) 0x0000000000000a10 really_call_select
-[ 31](sec  1)(fl 0x00)(ty   20)(scl   3) (nx 0) 0x0000000000000ac0 yield_callback
-[ 32](sec  1)(fl 0x00)(ty   20)(scl   3) (nx 0) 0x0000000000000b00 run_thread
-[ 33](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000000c80 Fcondition_name
-[ 34](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000000cd0 Fcondition_mutex
-[ 35](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000000d20 Fmutex_name
-[ 36](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000000d70 Fmutex_unlock
-[ 37](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000000e50 Fcondition_wait
-[ 38](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000000f50 Fthread_name
-[ 39](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000000fa0 Fthread_blocker
-[ 40](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000000ff0 Fmutex_lock
-[ 41](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001110 Fthread_live_p
-[ 42](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001160 Fthread_join
-[ 43](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001280 Fmake_condition_variable
-[ 44](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001320 Fmake_mutex
-[ 45](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001390 maybe_reacquire_global_lock
-[ 46](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x00000000000013f0 finalize_one_mutex
-[ 47](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001400 finalize_one_condvar
-[ 48](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001410 thread_select
-[ 49](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x00000000000014f0 mark_threads
-[ 50](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x00000000000015a0 unmark_main_thread
-[ 51](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x00000000000015b0 finalize_one_thread
-[ 52](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001630 thread_check_current_buffer
-[ 53](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001680 main_thread_p
-[ 54](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001690 in_current_thread
-[ 55](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x00000000000016d0 init_threads
-[ 56](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001730 syms_of_threads
+[ 26](sec  1)(fl 0x00)(ty   20)(scl   3) (nx 0) 0x0000000000000880 mutex_unlock_callback
+[ 27](sec  1)(fl 0x00)(ty   20)(scl   3) (nx 0) 0x00000000000008d0 condition_wait_callback
+[ 28](sec  1)(fl 0x00)(ty   20)(scl   3) (nx 0) 0x0000000000000970 thread_signal_callback
+[ 29](sec  1)(fl 0x00)(ty   20)(scl   3) (nx 0) 0x00000000000009a0 condition_notify_callback
+[ 30](sec  1)(fl 0x00)(ty   20)(scl   3) (nx 0) 0x0000000000000a20 really_call_select
+[ 31](sec  1)(fl 0x00)(ty   20)(scl   3) (nx 0) 0x0000000000000ad0 yield_callback
+[ 32](sec  1)(fl 0x00)(ty   20)(scl   3) (nx 0) 0x0000000000000b10 run_thread
+[ 33](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000000c90 Fcondition_name
+[ 34](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000000ce0 Fcondition_mutex
+[ 35](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000000d30 Fmutex_name
+[ 36](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000000d80 Fmutex_unlock
+[ 37](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000000e60 Fcondition_wait
+[ 38](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000000f60 Fthread_name
+[ 39](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000000fb0 Fthread_blocker
+[ 40](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001000 Fmutex_lock
+[ 41](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001120 Fthread_live_p
+[ 42](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001170 Fthread_join
+[ 43](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001290 Fmake_condition_variable
+[ 44](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001330 Fmake_mutex
+[ 45](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x00000000000013a0 maybe_reacquire_global_lock
+[ 46](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001400 finalize_one_mutex
+[ 47](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001420 finalize_one_condvar
+[ 48](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001440 thread_select
+[ 49](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001520 mark_threads
+[ 50](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x00000000000015d0 unmark_main_thread
+[ 51](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x00000000000015e0 finalize_one_thread
+[ 52](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001660 thread_check_current_buffer
+[ 53](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x00000000000016b0 main_thread_p
+[ 54](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x00000000000016c0 in_current_thread
+[ 55](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x00000000000016f0 init_threads
+[ 56](sec  1)(fl 0x00)(ty   20)(scl   2) (nx 0) 0x0000000000001750 syms_of_threads
 [ 57](sec  7)(fl 0x00)(ty    0)(scl   3) (nx 0) 0x0000000000000360 Sthread_yield
 [ 58](sec  7)(fl 0x00)(ty    0)(scl   3) (nx 0) 0x0000000000000300 Smake_thread
 [ 59](sec  7)(fl 0x00)(ty    0)(scl   3) (nx 0) 0x00000000000002a0 Scurrent_thread
@@ -80,13 +80,13 @@
 [ 75](sec  7)(fl 0x00)(ty    0)(scl   3) (nx 0) 0x0000000000000000 Sthread_last_error
 [ 76](sec  6)(fl 0x00)(ty    0)(scl   3) (nx 0) 0x00000000000000c0 o_fwd.0
 [ 77](sec  1)(fl 0x00)(ty    0)(scl   3) (nx 1) 0x0000000000000000 .text
-AUX scnlen 0x1877 nreloc 229 nlnno 0
+AUX scnlen 0x1897 nreloc 229 nlnno 0
 [ 79](sec  2)(fl 0x00)(ty    0)(scl   3) (nx 1) 0x0000000000000000 .data
 AUX scnlen 0x280 nreloc 2 nlnno 0
 [ 81](sec  3)(fl 0x00)(ty    0)(scl   3) (nx 1) 0x0000000000000000 .bss
 AUX scnlen 0x48 nreloc 0 nlnno 0
 [ 83](sec  4)(fl 0x00)(ty    0)(scl   3) (nx 1) 0x0000000000000000 .xdata
-AUX scnlen 0x3ac nreloc 0 nlnno 0
+AUX scnlen 0x3b4 nreloc 0 nlnno 0
 [ 85](sec  5)(fl 0x00)(ty    0)(scl   3) (nx 1) 0x0000000000000000 .pdata
 AUX scnlen 0x228 nreloc 138 nlnno 0
 [ 87](sec  6)(fl 0x00)(ty    0)(scl   3) (nx 1) 0x0000000000000000 .rdata
@@ -94,25 +94,25 @@
 [ 89](sec  7)(fl 0x00)(ty    0)(scl   3) (nx 1) 0x0000000000000000 .subrs
 AUX scnlen 0x718 nreloc 38 nlnno 0
 [ 91](sec  8)(fl 0x00)(ty    0)(scl   3) (nx 1) 0x0000000000000000 .debug_info
-AUX scnlen 0xf4fd nreloc 1639 nlnno 0
+AUX scnlen 0xf57c nreloc 1647 nlnno 0
 [ 93](sec  9)(fl 0x00)(ty    0)(scl   3) (nx 1) 0x0000000000000000 .debug_abbrev
-AUX scnlen 0x9a3 nreloc 0 nlnno 0
+AUX scnlen 0x95e nreloc 0 nlnno 0
 [ 95](sec 10)(fl 0x00)(ty    0)(scl   3) (nx 1) 0x0000000000000000 .debug_loc
-AUX scnlen 0x75b7 nreloc 22 nlnno 0
+AUX scnlen 0x753d nreloc 22 nlnno 0
 [ 97](sec 11)(fl 0x00)(ty    0)(scl   3) (nx 1) 0x0000000000000000 .debug_aranges
 AUX scnlen 0x30 nreloc 2 nlnno 0
 [ 99](sec 12)(fl 0x00)(ty    0)(scl   3) (nx 1) 0x0000000000000000 .debug_ranges
-AUX scnlen 0xe70 nreloc 0 nlnno 0
+AUX scnlen 0xdc0 nreloc 0 nlnno 0
 [101](sec 13)(fl 0x00)(ty    0)(scl   3) (nx 1) 0x0000000000000000 .debug_macro
 AUX scnlen 0xffa1e nreloc 1 nlnno 0
 [103](sec 14)(fl 0x00)(ty    0)(scl   3) (nx 1) 0x0000000000000000 .debug_line
-AUX scnlen 0x2f50 nreloc 13 nlnno 0
+AUX scnlen 0x2ea1 nreloc 7 nlnno 0
 [105](sec 15)(fl 0x00)(ty    0)(scl   3) (nx 1) 0x0000000000000000 .debug_str
 AUX scnlen 0xe5 nreloc 0 nlnno 0
 [107](sec 16)(fl 0x00)(ty    0)(scl   3) (nx 1) 0x0000000000000000 .rdata$zzz
 AUX scnlen 0x2b nreloc 0 nlnno 0
 [109](sec 19)(fl 0x00)(ty    0)(scl   3) (nx 1) 0x0000000000000000 .debug_frame
-AUX scnlen 0xb18 nreloc 92 nlnno 0
+AUX scnlen 0xb10 nreloc 92 nlnno 0
 [111](sec  2)(fl 0x00)(ty    0)(scl   2) (nx 0) 0x0000000000000008 current_thread
 [112](sec 18)(fl 0x00)(ty    0)(scl   2) (nx 0) 0x0000000000000000 .refptr.initialized
 [113](sec 17)(fl 0x00)(ty    0)(scl   2) (nx 0) 0x0000000000000000 .refptr.globals