NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

toolchain/58360: MKREPRO: -g breaks reproducibility



>Number:         58360
>Category:       toolchain
>Synopsis:       MKREPRO: -g breaks reproducibility
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jun 22 23:25:01 +0000 2024
>Originator:     Harold Gutch
>Release:        current as of 20240615
>Organization:
>Environment:
Linux ubuntu 6.8.0-35-generic #35-Ubuntu SMP PREEMPT_DYNAMIC Mon May 20 15:51:52 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
>Description:
A few binaries in the tree are compiled with -g, and these are not reproducible.
>How-To-Repeat:
./build.sh -u -U -O ${CURDIR}/out -T ${CURDIR}/tools -m amd64 -V MKREPRO=yes -V MKREPRO_TIMESTAMP=1711614813 -j 16 tools
./build.sh -u -U -O ${CURDIR}/out -T ${CURDIR}/tools -m amd64 -V MKREPRO=yes -V MKREPRO_TIMESTAMP=1711614813 -j 16 release
./build.sh -u -U -O ${CURDIR}/ouT -T ${CURDIR}/tools -m amd64 -V MKREPRO=yes -V MKREPRO_TIMESTAMP=1711614813 -j 16 release

(the timestamp is a leftover from a previous run and should not matter as long as it is consistent)

unpacking sets and comparing between the two builds yields:
$ diff -u ?/etc/mtree/set.base  | grep -v '^ '
--- 1/etc/mtree/set.base        2024-03-28 09:33:33.000000000 +0100
+++ 2/etc/mtree/set.base        2024-03-28 09:33:33.000000000 +0100
@@ -387,8 +387,8 @@
-./sbin/blocklistctl type=file uname=root gname=wheel mode=0555 size=81200 sha256=c17465fce4b788fc5f87269463b79b8a544c3dd329304febd87b9c5b812f520e
-./sbin/blocklistd type=file uname=root gname=wheel mode=0555 size=95064 sha256=342c21c3dacb4eb629830e00180da9514f785daeddf4a88f789e54f1f56dd864
+./sbin/blocklistctl type=file uname=root gname=wheel mode=0555 size=81200 sha256=d65d7bea3b6ef99977f74d0946d10a9d2e7b0c2b0632fc196cefa42964a84191
+./sbin/blocklistd type=file uname=root gname=wheel mode=0555 size=95064 sha256=ef77e30c7ee32bc6ca7e1b147f5b81b44f209abf1dd10ff5aa17ded5710add71
@@ -743,7 +743,7 @@
-./usr/bin/netpgpverify type=file uname=root gname=wheel mode=0555 size=425224 sha256=86952f31b60677782f1373f2381065320902f5cca2d93cde6d461f8916c4d6d5
+./usr/bin/netpgpverify type=file uname=root gname=wheel mode=0555 size=425224 sha256=3f9c6b8db290acea467b65ebc0ceb9f53b32c007758993be38ea90a422d50576

Over the entire build the following files differ:

./sbin/blocklistctl
./sbin/blocklistd
./usr/bin/netpgpverify
./usr/bin/ctfconvert
./usr/bin/ctfdump
./usr/bin/ctfmerge
./usr/tests/lib/libc/string/t_bm
./usr/tests/lib/libc/string/t_memchr
./usr/tests/lib/libc/string/t_memcpy
./usr/tests/lib/libc/string/t_memmem
./usr/tests/lib/libc/string/t_memset
./usr/tests/lib/libc/string/t_popcount
./usr/tests/lib/libc/string/t_strcat
./usr/tests/lib/libc/string/t_strchr
./usr/tests/lib/libc/string/t_strchrnul
./usr/tests/lib/libc/string/t_strcmp
./usr/tests/lib/libc/string/t_strcoll
./usr/tests/lib/libc/string/t_strcpy
./usr/tests/lib/libc/string/t_strcspn
./usr/tests/lib/libc/string/t_strerror
./usr/tests/lib/libc/string/t_stresep
./usr/tests/lib/libc/string/t_strlen
./usr/tests/lib/libc/string/t_strpbrk
./usr/tests/lib/libc/string/t_strrchr
./usr/tests/lib/libc/string/t_strspn
./usr/tests/lib/libc/string/t_swab

All of these are compiled with -g and removing that from the respective Makefiles makes the userland reproducible.

Here is part of the diff of "readelf -w" output for blocklistctl:
$ diff -u ?/sbin/blocklistctl.readelf
--- 1/sbin/blocklistctl.readelf       2024-06-23 00:51:52.608251368 +0200
+++ 2/sbin/blocklistctl.readelf       2024-06-23 00:51:52.622251155 +0200
@@ -938,19 +938,19 @@
    Abbrev Offset: 0x0
    Pointer Size:  8
  <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
-    <c>   DW_AT_producer    : (indirect string, offset: 0x11c): GNU C99 10.5.0 -fno-canonical-system-headers -mtune=nocona -march=x86-64 -g -std=gnu99 -fPIE -fdebug-regex-map=/usr/src/(.*)/obj$=/usr/obj/\1 -fdebug-regex-map=/usr/src/(.*)/obj/(.*)=/usr/obj/\1/\2 -fd
ebug-regex-map=/usr/src/(.*)/obj\..*=/usr/obj/\1 -fdebug-regex-map=/usr/src/(.*)/obj\..*/(.*)=/usr/obj/\1/\2
+    <c>   DW_AT_producer    : (indirect string, offset: 0xe6): GNU C99 10.5.0 -fno-canonical-system-headers -mtune=nocona -march=x86-64 -g -std=gnu99 -fPIE -fdebug-regex-map=/usr/src/(.*)/obj$=/usr/obj/\1 -fdebug-regex-map=/usr/src/(.*)/obj/(.*)=/usr/obj/\1/\2 -fde
bug-regex-map=/usr/src/(.*)/obj\..*=/usr/obj/\1 -fdebug-regex-map=/usr/src/(.*)/obj\..*/(.*)=/usr/obj/\1/\2
     <10>   DW_AT_language    : 12      (ANSI C99)
     <11>   DW_AT_name        : (indirect string, offset: 0x2fe): /usr/src/external/bsd/blocklist/bin/blocklistctl.c
-    <15>   DW_AT_comp_dir    : (indirect string, offset: 0xbe): /home/h/netbsd/current/out/external/bsd/blocklist/bin
+    <15>   DW_AT_comp_dir    : (indirect string, offset: 0x23e): /home/h/netbsd/current/ouT/external/bsd/blocklist/bin
     <19>   DW_AT_low_pc      : 0x26c0
     <21>   DW_AT_high_pc     : 0x4a9
     <29>   DW_AT_stmt_list   : 0x0
  <1><2d>: Abbrev Number: 2 (DW_TAG_base_type)
     <2e>   DW_AT_byte_size   : 1
     <2f>   DW_AT_encoding    : 6       (signed char)
-    <30>   DW_AT_name        : (indirect string, offset: 0x254): signed char
+    <30>   DW_AT_name        : (indirect string, offset: 0x21e): signed char
  <1><34>: Abbrev Number: 3 (DW_TAG_typedef)
-    <35>   DW_AT_name        : (indirect string, offset: 0x112): __uint8_t
+    <35>   DW_AT_name        : (indirect string, offset: 0xdc): __uint8_t
     <39>   DW_AT_decl_file   : 2
     <3a>   DW_AT_decl_line   : 46
     <3b>   DW_AT_decl_column : 27

There are many additional DW_AT_name differences that only differ by offset, and the difference seems to be 54 (decimal) for every single one (I only checked a few manually).

Here is part of the difference of the .debug_str section:

   0x00000090 45006c6f 6e67206c 6f6e6720 696e7400 E.long long int.
   0x000000a0 696e7465 726e616c 005f5f73 735f616c internal.__ss_al
-  0x000000b0 69676e00 5f5f696e 7436345f 74002f68 ign.__int64_t./h
-  0x000000c0 6f6d652f 682f6e65 74627364 2f637572 ome/h/netbsd/cur
-  0x000000d0 72656e74 2f6f7574 2f657874 65726e61 rent/out/externa
-  0x000000e0 6c2f6273 642f626c 6f636b6c 6973742f l/bsd/blocklist/
+  0x000000b0 69676e00 5f5f696e 7436345f 74005f5f ign.__int64_t.__
+  0x000000c0 64620073 735f6c65 6e006e6f 68656164 db.ss_len.nohead
+  0x000000d0 6572005f 626c6b73 697a6500 5f5f7569 er._blksize.__ui
+  0x000000e0 6e74385f 7400474e 55204339 39203130 nt8_t.GNU C99 10

(the first build embeds the output directory earlier in this table than the second build, and many symbols thus end up at locations with an offset difference of 54, as mentioned above). 
>Fix:
Well, building without -g... but otherwise...



Home | Main Index | Thread Index | Old Index