Bug 29979 - Some -Wmaybe-uninitialized are needed on x86_32 without -Os
Summary: Some -Wmaybe-uninitialized are needed on x86_32 without -Os
Status: UNCONFIRMED
Alias: None
Product: glibc
Classification: Unclassified
Component: build (show other bugs)
Version: 2.36
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-09 20:19 UTC by Mikhail Novosyolov
Modified: 2023-01-12 18:38 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Novosyolov 2023-01-09 20:19:01 UTC
I had to make the following patch to build glibc 2.36 (release/2.36/master, 4f4d7a13edfd2fdc57c9d76e1fd6d017fb47550c) on x86_32 (i686). Other arches (x86_64, aarch64, riscv64) did not require this change).

--- a/locale/weight.h
+++ b/locale/weight.h
@@ -144,7 +144,7 @@
 		     is impossible for the same reason as described
 		     above.  */
 		  DIAG_PUSH_NEEDS_COMMENT;
-		  DIAG_IGNORE_Os_NEEDS_COMMENT (7, "-Wmaybe-uninitialized");
+		  DIAG_IGNORE_NEEDS_COMMENT (7, "-Wmaybe-uninitialized");
 		  offset += usrc[cnt] - cp[cnt];
 		  DIAG_POP_NEEDS_COMMENT;
 		}

--- a/locale/weightwc.h
+++ b/locale/weightwc.h
@@ -102,7 +102,7 @@
 	     might be used uninitialized.  This is impossible for the
 	     same reason as described above.  */
 	  DIAG_PUSH_NEEDS_COMMENT;
-	  DIAG_IGNORE_Os_NEEDS_COMMENT (7, "-Wmaybe-uninitialized");
+	  DIAG_IGNORE_NEEDS_COMMENT (7, "-Wmaybe-uninitialized");
 	  for (cnt = 0; cnt < nhere - 1 && cnt < len; ++cnt)
 	    if (cp[cnt] != usrc[cnt])
 	      break;

--- a/string/strcoll_l.c
+++ b/string/strcoll_l.c
@@ -180,7 +180,7 @@
 	 ensures that seq->save_idx was saved to first and contains a
 	 valid value.  */
       DIAG_PUSH_NEEDS_COMMENT;
-      DIAG_IGNORE_Os_NEEDS_COMMENT (5, "-Wmaybe-uninitialized");
+      DIAG_IGNORE_NEEDS_COMMENT (5, "-Wmaybe-uninitialized");
       len = weights[idx++];
       DIAG_POP_NEEDS_COMMENT;
       /* Skip over indices of previous levels.  */

Comments near patched code write about -Os, but I was building without -Os

Full command line and error (errors were similar for other patched cases):

DEBUG: gcc -fuse-ld=bfd  -fomit-frame-pointer strcoll_l.c -c -std=gnu11 -fgnu89-inline  -funwind-tables -fasynchronous-unwind-tables -O3 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -march=i686 -mtune=generic -msse -mfpmath=sse -fasynchronous-unwind-tables -mstackrealign -march=i686 -msse -mfpmath=sse -mtune=generic -Wp,-D_GLIBCXX_ASSERTIONS -DNDEBUG=1 -fstack-clash-protection -O3 -gdwarf-4 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -fstack-protector-strong --param=ssp-buffer-size=4 -march=i686 -mtune=generic -msse -mfpmath=sse -fasynchronous-unwind-tables -mstackrealign -O3 -Wno-error=stringop-overflow -fno-strict-aliasing -Wformat -fno-lto -mno-tls-direct-seg-refs -Wno-error -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fstack-protector-strong -fno-common -Wstrict-prototypes -Wold-style-definition -fmath-errno   -fomit-frame-pointer -fomit-frame-pointer -fpie   -ftls-model=initial-exec   -U_FORTIFY_SOURCE   -I../include -I/builddir/build/BUILD/glibc-4f4d7a13edfd2fdc57c9d76e1fd6d017fb47550c/build-i686-linux/string  -I/builddir/build/BUILD/glibc-4f4d7a13edfd2fdc57c9d76e1fd6d017fb47550c/build-i686-linux  -I../sysdeps/unix/sysv/linux/i386/i686  -I../sysdeps/i386/i686/nptl  -I../sysdeps/unix/sysv/linux/i386  -I../sysdeps/unix/sysv/linux/x86/include -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl  -I../sysdeps/i386/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/i386  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/i386/i686/fpu/multiarch  -I../sysdeps/i386/i686/fpu  -I../sysdeps/i386/i686/multiarch  -I../sysdeps/i386/i686  -I../sysdeps/i386/fpu  -I../sysdeps/x86/fpu  -I../sysdeps/i386  -I../sysdeps/x86/include -I../sysdeps/x86  -I../sysdeps/wordsize-32  -I../sysdeps/ieee754/float128  -I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/i686-rosa-linux-gnu/11.2.0/include -isystem /usr/include -D_LIBC_REENTRANT -include /builddir/build/BUILD/glibc-4f4d7a13edfd2fdc57c9d76e1fd6d017fb47550c/build-i686-linux/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC     -DTOP_NAMESPACE=glibc -o /builddir/build/BUILD/glibc-4f4d7a13edfd2fdc57c9d76e1fd6d017fb47550c/build-i686-linux/string/strcoll_l.o -MD -MP -MF /builddir/build/BUILD/glibc-4f4d7a13edfd2fdc57c9d76e1fd6d017fb47550c/build-i686-linux/string/strcoll_l.o.dt -MT /builddir/build/BUILD/glibc-4f4d7a13edfd2fdc57c9d76e1fd6d017fb47550c/build-i686-linux/string/strcoll_l.o
DEBUG: In file included from strcoll_l.c:42:
DEBUG: strcoll_l.c: In function '__strcoll_l':
DEBUG: ../locale/weight.h:148:33: error: 'seq2.back_us' may be used uninitialized in this function [-Werror=maybe-uninitialized]
DEBUG:   148 |                   offset += usrc[cnt] - cp[cnt];
DEBUG:       |                             ~~~~^~~~~
Comment 1 Adhemerval Zanella 2023-01-12 13:31:21 UTC
Right, which gcc version did you use it? I am checking with GCC 11 and I have not see any issue so far.
Comment 2 Mikhail Novosyolov 2023-01-12 18:38:42 UTC
(In reply to Adhemerval Zanella from comment #1)
> Right, which gcc version did you use it? I am checking with GCC 11 and I
> have not see any issue so far.

It is gcc 11:

$ gcc --version
gcc (GCC) 11.2.0 20210728 (ROSA)

I have provided full gcc cmdline with flags above, do not have any ideas else where the difference can be...

If it will help, here is a chroot in which this problem can be reproduced:

https://mirror.rosalinux.ru/rosa/rosa2021.1/iso/ROSA.FRESH.12/rootfs/rootfs-std-rosa2021.1_x86_64_2022-11-02.tar.xz

Or an installable livecd: https://mirror.rosalinux.ru/rosa/rosa2021.1/iso/ROSA.FRESH.12/server/

To reproduce the problem, run:

sudo mkdir chroot
cd chroot
sudo tar -xf /path/to/rootfs-std-rosa2021.1_x86_64_2022-11-02.tar.xz
sudo systemd-nspawn -D . (or sudo chroot .)
# if running in VM, not chroot/container, start from here
dnf install basesystem-build /usr/bin/mbd git-core abf
git clone https://abf.io/import/glibc.git -b rosa2023.1
cd glibc
mbd glibc.spec
dnf install *.rpm (install build dependencies of glibc)

Comment out the patch described above:
-Patch10:	glibc-fix-ix86-build.patch
+#Patch10:	glibc-fix-ix86-build.patch

Run the build:
abf rpmbuild (just press enter when it asks questions about config)

gcc sources are here:
https://abf.io/import/gcc/tree/rosa2021.1

glibc with that problem:
https://abf.io/import/glibc/tree/rosa2023.1