mbox series

[v6,00/14] Allow glibc to be built with _FORTIFY_SOURCE

Message ID 20230705143822.275049-1-fberat@redhat.com
Headers show
Series Allow glibc to be built with _FORTIFY_SOURCE | expand

Message

Frederic Berat July 5, 2023, 2:38 p.m. UTC
Hello,

This patch series introduces a new "--enable-fortify-source" option to glibc
build. This option may either be set to a value between 1 and 3, or left empty
to let configure select the highest value available for the build system.

The first patch adds the new configure option, the second excludes the routines
that can't be built with the option enabled.

The next patches are fixing test and compilation errors that arose with
fortification enabled.

I couldn't test the patch series in all configuration possible on all arches
possible but I ran the following:

 - build-many-glibcs was executed on x86_64, for all arches/variants. This was
   mainly done to ensure that installed headers were not broken (as some
   patches are modifying system headers)
 - The new "enable-fortify-source" variant for BMG got executed on x86_64
 - make check and benchtests were executed on x86_64, i686, ppc64le, aarch64,
   s390x, with and without fortification enabled.

Fred.

Changes since v1:
 - The patch that introduced the new config option has been split in 2.
   There is now one patch that allows glibc to be built with fortification and
   one that adds a new configure option to enable it.
   The patch adding the configure option has been moved to the end of the
   series.
 - A new variant has been added to x86_64 bmg to test enable-fortify-source.
 - NEWS and INSTALL have been updated.
 - Patch series has been re-based
 - Error message has been fixed in newly introduced headers
 - Include directive has been fixed in newly introduced include/* headers

Changes since v2:
 - Test for bug269 modifies the stack in a way that may trigger an abort on
   longjump when fortification is enabled. Thus, disable fortification for this
   test.
 - Added 2 patches to perform the same changes on stdio.h that was done for
   unistd.h and wchar.h. Declarations that were in stdio2.h are moved into
   existing stdio-decl.h, and __REDIRECT is rplaced by __REDIRECT_FORTIFY for
   fgets_unlocked_alias.
 - Title for some patches were modified without content change.

Changes since v3:
 - Patch 02 (Exclude routines from fortification): Add $(no-fortify-source) to
   CFLAGS-tst-sprintf-ub.c
 - Patch 06 (asprintf_chk: Ensure compatibility for both s390x and ppc64le) is
   squashed in patch 05 (stdio: Ensure *_chk routines have their hidden builtin
   definition available). Hence, reviewed-by on patch 05 is dropped.
 - Patch 05 now details why s390x couldn't build if ldbl_* macros are used with
   __asprintf_chk
 - Patch 08 (wchar: Avoid PLT entries with _FORTIFY_SOURCE): unexpected left
   over is removed.
 - Patch 10 (unistd: Avoid PLT entries with _FORTIFY_SOURCE):
   libc_hidden_builtin_{def,proto} replaced with libc_hidden_{def,proto}
 - Patch 11 (misc/bits/select2.h: Clearly separate declaration from
   definitions): libc_hidden_builtin_{def,proto} replaced with
   libc_hidden_{def,proto}
 - Patch 16 (Add --enable-fortify-source option): if "--enable-fortify-source"
   is NOT set (i.e. assume "--disable-fortify-source"), forcibly undefine
   _FORTIFY_SOURCE (instead of letting it pass-through). This is the default
   and matches old behavior.

Changes since v4:
 - Patch 15 (Add --enable-fortify-source option): squashed back in patch 01
   (Allow glibc to be built with _FORTIFY_SOURCE)
 - Patch 01: Rephrasing Makeconfig, NEWS, INSTALL and configure help.

Changes since v5:
 - "GLIBC" changed to "The GNU C Library" in NEWS.
 - Sorry for the flood.

---
Frédéric Bérat (14):
  Allow glibc to be built with _FORTIFY_SOURCE
  Exclude routines from fortification
  sysdeps: Ensure ieee128*_chk routines to be properly named
  string: Ensure *_chk routines have their hidden builtin definition
    available
  stdio: Ensure *_chk routines have their hidden builtin definition
    available
  misc/sys/cdefs.h: Create FORTIFY redirects for internal calls
  wchar: Avoid PLT entries with _FORTIFY_SOURCE
  posix/bits/unistd.h: Clearly separate declaration from definitions
  unistd: Avoid PLT entries with _FORTIFY_SOURCE
  misc/bits/select2.h: Clearly separate declaration from definitions
  misc/bits/syslog.h: Clearly separate declaration from definition
  libio/bits/stdio2.h: Clearly separate declaration from definitions
  libio/bits/stdio2-decl.h: Avoid PLT entries with _FORTIFY_SOURCE
  sysdeps/ieee754/ldbl-128ibm-compat: Fix warn unused result

 INSTALL                                       |   8 +
 Makeconfig                                    |  35 +++-
 NEWS                                          |   6 +
 config.make.in                                |   3 +-
 configure                                     |  83 ++++++--
 configure.ac                                  |  60 ++++--
 debug/Makefile                                |  12 +-
 debug/asprintf_chk.c                          |  18 +-
 debug/fdelt_chk.c                             |   1 +
 debug/fgets_u_chk.c                           |   1 +
 debug/fprintf_chk.c                           |   1 +
 debug/getdomainname_chk.c                     |   1 +
 debug/memcpy_chk.c                            |   1 +
 debug/memmove_chk.c                           |   1 +
 debug/mempcpy_chk.c                           |   1 +
 debug/memset_chk.c                            |   1 +
 debug/read_chk.c                              |   1 +
 debug/sprintf_chk.c                           |   1 +
 debug/stpcpy_chk.c                            |   1 +
 debug/wcrtomb_chk.c                           |   1 +
 debug/wmemset_chk.c                           |   1 +
 elf/rtld-Rules                                |   2 +-
 include/bits/select-decl.h                    |   1 +
 include/bits/syslog-decl.h                    |   1 +
 include/bits/unistd-decl.h                    |   1 +
 include/stdio.h                               |  13 +-
 include/string.h                              |   7 +
 include/sys/cdefs.h                           |  14 ++
 include/sys/select.h                          |   4 +
 include/sys/syslog.h                          |   4 +
 include/unistd.h                              |   5 +
 include/wchar.h                               |  15 ++
 io/Makefile                                   |  16 ++
 libio/Makefile                                |  23 +-
 libio/bits/stdio2-decl.h                      |  49 +++++
 libio/bits/stdio2.h                           |  48 -----
 login/Makefile                                |   6 +
 login/getlogin_r_chk.c                        |   1 +
 manual/install.texi                           |   8 +
 misc/Makefile                                 |   9 +
 misc/bits/select-decl.h                       |  31 +++
 misc/bits/select2.h                           |   6 +-
 misc/bits/syslog-decl.h                       |  35 ++++
 misc/bits/syslog.h                            |  10 +-
 misc/sys/cdefs.h                              |   8 +
 misc/syslog.c                                 |   4 +-
 posix/Makefile                                |  12 ++
 posix/bits/unistd-decl.h                      | 198 ++++++++++++++++++
 posix/bits/unistd.h                           | 154 +-------------
 rt/Makefile                                   |   5 +
 scripts/build-many-glibcs.py                  |   4 +-
 setjmp/Makefile                               |   9 +
 socket/Makefile                               |   6 +
 stdio-common/Makefile                         |  15 +-
 stdlib/Makefile                               |   7 +
 string/Makefile                               |  17 ++
 sysdeps/i386/i586/memcpy.S                    |   1 +
 sysdeps/i386/i586/memset.S                    |   1 +
 sysdeps/i386/i686/memcpy.S                    |   1 +
 sysdeps/i386/i686/memmove.S                   |   1 +
 sysdeps/i386/i686/mempcpy.S                   |   1 +
 sysdeps/i386/i686/memset.S                    |   1 +
 sysdeps/i386/i686/multiarch/memcpy_chk.c      |   4 +
 sysdeps/i386/i686/multiarch/memmove_chk.c     |   4 +
 sysdeps/i386/i686/multiarch/mempcpy_chk.c     |   4 +
 sysdeps/i386/i686/multiarch/memset_chk.c      |   5 +-
 sysdeps/i386/memcpy_chk.S                     |   1 +
 sysdeps/i386/memmove_chk.S                    |   1 +
 sysdeps/i386/mempcpy_chk.S                    |   1 +
 sysdeps/i386/memset_chk.S                     |   1 +
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  81 +++++--
 .../ldbl-128ibm-compat/ieee128-asprintf_chk.c |   5 +-
 .../ldbl-128ibm-compat/ieee128-dprintf_chk.c  |   4 +-
 .../ldbl-128ibm-compat/ieee128-fprintf_chk.c  |   5 +-
 .../ldbl-128ibm-compat/ieee128-fwprintf_chk.c |   4 +-
 .../ldbl-128ibm-compat/ieee128-printf_chk.c   |   4 +-
 .../ldbl-128ibm-compat/ieee128-snprintf_chk.c |   4 +-
 .../ldbl-128ibm-compat/ieee128-sprintf_chk.c  |   5 +-
 .../ldbl-128ibm-compat/ieee128-swprintf_chk.c |   4 +-
 .../ldbl-128ibm-compat/ieee128-syslog.c       |   9 +-
 .../ieee128-vasprintf_chk.c                   |   4 +-
 .../ldbl-128ibm-compat/ieee128-vdprintf_chk.c |   4 +-
 .../ldbl-128ibm-compat/ieee128-vfprintf_chk.c |   4 +-
 .../ieee128-vfwprintf_chk.c                   |   4 +-
 .../ldbl-128ibm-compat/ieee128-vprintf_chk.c  |   4 +-
 .../ieee128-vsnprintf_chk.c                   |   4 +-
 .../ldbl-128ibm-compat/ieee128-vsprintf_chk.c |   5 +-
 .../ieee128-vswprintf_chk.c                   |   4 +-
 .../ldbl-128ibm-compat/ieee128-vwprintf_chk.c |   4 +-
 .../ldbl-128ibm-compat/ieee128-wprintf_chk.c  |   4 +-
 .../test-printf-ldbl-compat.c                 |  10 +-
 .../test-scanf-ldbl-compat-template.c         |  21 +-
 sysdeps/ieee754/ldbl-opt/Makefile             |  29 +++
 sysdeps/pthread/Makefile                      |   4 +
 sysdeps/unix/sysv/linux/Makefile              |   3 +
 sysdeps/x86_64/memcpy_chk.S                   |   1 +
 sysdeps/x86_64/memmove_chk.S                  |   1 +
 sysdeps/x86_64/mempcpy_chk.S                  |   1 +
 sysdeps/x86_64/memset_chk.S                   |   1 +
 sysdeps/x86_64/multiarch/memcpy_chk.c         |   4 +
 sysdeps/x86_64/multiarch/memmove_chk.c        |   4 +
 sysdeps/x86_64/multiarch/mempcpy_chk.c        |   4 +
 sysdeps/x86_64/multiarch/memset_chk.c         |   4 +
 sysdeps/x86_64/multiarch/wmemset_chk.c        |   4 +
 wcsmbs/Makefile                               |  23 +-
 wcsmbs/bits/wchar2-decl.h                     |   4 +-
 106 files changed, 955 insertions(+), 342 deletions(-)
 create mode 100644 include/bits/select-decl.h
 create mode 100644 include/bits/syslog-decl.h
 create mode 100644 include/bits/unistd-decl.h
 create mode 100644 misc/bits/select-decl.h
 create mode 100644 misc/bits/syslog-decl.h
 create mode 100644 posix/bits/unistd-decl.h

Comments

Andreas Schwab July 6, 2023, 1:15 p.m. UTC | #1
https://build.opensuse.org/package/live_build_log/home:Andreas_Schwab:glibc/glibc/f/i586

gcc   -shared -static-libgcc -Wl,-O1  -Wl,-z,defs -Wl,-dynamic-linker=/lib/ld-linux.so.2 -Wl,-z,pack-relative-relocs  -B/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/csu/  -Wl,--version-script=/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc.map -Wl,-soname=libc.so.6 -Wl,-z,relro -Wl,-z,now -nostdlib -nostartfiles -e __libc_main -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/math -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/elf -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/dlfcn -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nss -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nis -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/rt -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/resolv -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/mathvec -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/support -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nptl -Wl,-rpath-link=/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/math:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/elf:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/dlfcn:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nss:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nis:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/rt:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/resolv:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/mathvec:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/support:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nptl -o /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc.so /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/csu/abi-note.o /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc_pic.os.clean /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/elf/interp.os /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/elf/ld.so -lgcc /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/elf/sofini.os
/usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc_pic.os.clean: in function `__GI_memmove':
/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/libio/../string/bits/string_fortified.h:36: undefined reference to `__GI___memmove_chk'
/usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc_pic.os.clean: in function `__GI_memmove':
/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/string/../string/bits/string_fortified.h:36: undefined reference to `__GI___memmove_chk'
/usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/string/../string/bits/string_fortified.h:36: undefined reference to `__GI___memmove_chk'
/usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc_pic.os.clean: in function `__GI_memmove':
/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/io/../string/bits/string_fortified.h:36: undefined reference to `__GI___memmove_chk'
/usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/io/../string/bits/string_fortified.h:36: undefined reference to `__GI___memmove_chk'
/usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc_pic.os.clean:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/io/../string/bits/string_fortified.h:36: more undefined references to `__GI___memmove_chk' follow
collect2: error: ld returned 1 exit status
make[2]: *** [../Makerules:647: /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc.so] Error 1
make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/elf'
make[1]: *** [Makefile:484: elf/subdir_lib] Error 2
make: *** [Makefile:9: all] Error 2
Andreas Schwab July 6, 2023, 1:38 p.m. UTC | #2
https://build.opensuse.org/package/live_build_log/home:Andreas_Schwab:glibc/glibc/s/s390x

gcc ../sysdeps/s390/memmove-c.c -c -std=gnu11 -fgnu89-inline  -O2 -Wall -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fstack-protector-strong -fno-common -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wstrict-prototypes -Wold-style-definition -fmath-errno  -mlong-double-128  -fPIE     -ftls-model=initial-exec     -I../include -I/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/string  -I/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base  -I../sysdeps/unix/sysv/linux/s390/s390-64  -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/unix/sysv/linux/s390/fpu  -I../sysdeps/s390/fpu  -I../sysdeps/unix/sysv/linux/s390  -I../sysdeps/s390/nptl  -I../sysdeps/ieee754/ldbl-64-128  -I../sysdeps/ieee754/ldbl-opt  -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  -I../sysdeps/posix  -I../sysdeps/s390/s390-64  -I../sysdeps/wordsize-64  -I../sysdeps/s390/multiarch  -I../sysdeps/s390  -I../sysdeps/ieee754/ldbl-128  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I.  -D_LIBC_REENTRANT -include /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC     -DTOP_NAMESPACE=glibc -o /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/string/memmove-c.o -MD -MP -MF /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/string/memmove-c.o.dt -MT /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/string/memmove-c.o
In file included from ../sysdeps/s390/memmove-c.c:36:
../string/memmove.c:44:1: error: optimization attribute on 'memmove' follows definition but the attribute doesn't match [-Werror=attributes]
   44 | {
      | ^
In file included from ../include/sys/cdefs.h:10,
                 from ../include/features.h:503,
                 from ../posix/sys/types.h:25,
                 from ../include/sys/types.h:1,
                 from ../include/string.h:6,
                 from ../string/memmove.c:20:
../string/bits/string_fortified.h:34:8: note: previous definition of 'memmove' with type 'void *(void *, const void *, size_t)' {aka 'void *(void *, const void *, long unsigned int)'}
   34 | __NTH (memmove (void *__dest, const void *__src, size_t __len))
      |        ^~~~~~~
../misc/sys/cdefs.h:81:62: note: in definition of macro '__NTH'
   81 | #  define __NTH(fct)    __attribute__ ((__nothrow__ __LEAF)) fct
      |                                                              ^~~
cc1: all warnings being treated as errors
Frederic Berat July 6, 2023, 1:41 p.m. UTC | #3
On Thu, Jul 6, 2023 at 3:15 PM Andreas Schwab <schwab@suse.de> wrote:

>
> https://build.opensuse.org/package/live_build_log/home:Andreas_Schwab:glibc/glibc/f/i586
>
> gcc   -shared -static-libgcc -Wl,-O1  -Wl,-z,defs
> -Wl,-dynamic-linker=/lib/ld-linux.so.2 -Wl,-z,pack-relative-relocs
> -B/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/csu/
> -Wl,--version-script=/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc.map
> -Wl,-soname=libc.so.6 -Wl,-z,relro -Wl,-z,now -nostdlib -nostartfiles -e
> __libc_main
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/math
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/elf
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/dlfcn
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nss
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nis
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/rt
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/resolv
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/mathvec
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/support
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nptl
> -Wl,-rpath-link=/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/math:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/elf:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/dlfcn:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nss:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nis:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/rt:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/resolv:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/mathvec:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/support:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nptl
> -o
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc.so
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/csu/abi-note.o
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc_pic.os.clean
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/elf/interp.os
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/elf/ld.so
> -lgcc
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/elf/sofini.os
> /usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld:
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc_pic.os.clean:
> in function `__GI_memmove':
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/libio/../string/bits/string_fortified.h:36:
> undefined reference to `__GI___memmove_chk'
> /usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld:
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc_pic.os.clean:
> in function `__GI_memmove':
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/string/../string/bits/string_fortified.h:36:
> undefined reference to `__GI___memmove_chk'
> /usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld:
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/string/../string/bits/string_fortified.h:36:
> undefined reference to `__GI___memmove_chk'
> /usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld:
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc_pic.os.clean:
> in function `__GI_memmove':
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/io/../string/bits/string_fortified.h:36:
> undefined reference to `__GI___memmove_chk'
> /usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld:
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/io/../string/bits/string_fortified.h:36:
> undefined reference to `__GI___memmove_chk'
> /usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld:
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc_pic.os.clean:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/io/../string/bits/string_fortified.h:36:
> more undefined references to `__GI___memmove_chk' follow
> collect2: error: ld returned 1 exit status
> make[2]: *** [../Makerules:647:
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc.so]
> Error 1
> make[2]: Leaving directory
> '/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/elf'
> make[1]: *** [Makefile:484: elf/subdir_lib] Error 2
> make: *** [Makefile:9: all] Error 2
>
>
Hello,

Please open a ticket if not already done.

A reproduction scenario/environment would be nice to have too.


> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
>
>
Andreas Schwab July 6, 2023, 1:46 p.m. UTC | #4
On Jul 06 2023, Frederic Berat wrote:

> A reproduction scenario/environment would be nice to have too.

See the log.
Frederic Berat July 10, 2023, 5:56 a.m. UTC | #5
On Thu, Jul 6, 2023 at 3:38 PM Andreas Schwab <schwab@suse.de> wrote:

>
> https://build.opensuse.org/package/live_build_log/home:Andreas_Schwab:glibc/glibc/s/s390x
>
> gcc ../sysdeps/s390/memmove-c.c -c -std=gnu11 -fgnu89-inline  -O2 -Wall
> -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection
> -Werror=return-type -g -Wall -Wwrite-strings -Wundef -Werror
> -fmerge-all-constants -frounding-math -fstack-protector-strong -fno-common
> -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wstrict-prototypes
> -Wold-style-definition -fmath-errno  -mlong-double-128  -fPIE
>  -ftls-model=initial-exec     -I../include
> -I/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/string
> -I/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base
> -I../sysdeps/unix/sysv/linux/s390/s390-64
> -I../sysdeps/unix/sysv/linux/wordsize-64
> -I../sysdeps/unix/sysv/linux/s390/fpu  -I../sysdeps/s390/fpu
> -I../sysdeps/unix/sysv/linux/s390  -I../sysdeps/s390/nptl
> -I../sysdeps/ieee754/ldbl-64-128  -I../sysdeps/ieee754/ldbl-opt
> -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
> -I../sysdeps/posix  -I../sysdeps/s390/s390-64  -I../sysdeps/wordsize-64
> -I../sysdeps/s390/multiarch  -I../sysdeps/s390
> -I../sysdeps/ieee754/ldbl-128  -I../sysdeps/ieee754/dbl-64
> -I../sysdeps/ieee754/flt-32  -I../sysdeps/ieee754  -I../sysdeps/generic
> -I.. -I../libio -I.  -D_LIBC_REENTRANT -include
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc-modules.h
> -DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC
>  -DTOP_NAMESPACE=glibc -o
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/string/memmove-c.o
> -MD -MP -MF
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/string/memmove-c.o.dt
> -MT
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/string/memmove-c.o
> In file included from ../sysdeps/s390/memmove-c.c:36:
> ../string/memmove.c:44:1: error: optimization attribute on 'memmove'
> follows definition but the attribute doesn't match [-Werror=attributes]
>    44 | {
>       | ^
> In file included from ../include/sys/cdefs.h:10,
>                  from ../include/features.h:503,
>                  from ../posix/sys/types.h:25,
>                  from ../include/sys/types.h:1,
>                  from ../include/string.h:6,
>                  from ../string/memmove.c:20:
> ../string/bits/string_fortified.h:34:8: note: previous definition of
> 'memmove' with type 'void *(void *, const void *, size_t)' {aka 'void
> *(void *, const void *, long unsigned int)'}
>    34 | __NTH (memmove (void *__dest, const void *__src, size_t __len))
>       |        ^~~~~~~
> ../misc/sys/cdefs.h:81:62: note: in definition of macro '__NTH'
>    81 | #  define __NTH(fct)    __attribute__ ((__nothrow__ __LEAF)) fct
>       |                                                              ^~~
> cc1: all warnings being treated as errors
>
> Hello,

Please review
https://patchwork.sourceware.org/project/glibc/patch/20230707145425.535014-1-fberat@redhat.com/
Frederic Berat July 10, 2023, 5:57 a.m. UTC | #6
On Thu, Jul 6, 2023 at 3:15 PM Andreas Schwab <schwab@suse.de> wrote:

>
> https://build.opensuse.org/package/live_build_log/home:Andreas_Schwab:glibc/glibc/f/i586
>
> gcc   -shared -static-libgcc -Wl,-O1  -Wl,-z,defs
> -Wl,-dynamic-linker=/lib/ld-linux.so.2 -Wl,-z,pack-relative-relocs
> -B/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/csu/
> -Wl,--version-script=/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc.map
> -Wl,-soname=libc.so.6 -Wl,-z,relro -Wl,-z,now -nostdlib -nostartfiles -e
> __libc_main
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/math
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/elf
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/dlfcn
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nss
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nis
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/rt
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/resolv
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/mathvec
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/support
> -L/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nptl
> -Wl,-rpath-link=/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/math:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/elf:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/dlfcn:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nss:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nis:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/rt:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/resolv:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/mathvec:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/support:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/nptl
> -o
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc.so
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/csu/abi-note.o
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc_pic.os.clean
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/elf/interp.os
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/elf/ld.so
> -lgcc
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/elf/sofini.os
> /usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld:
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc_pic.os.clean:
> in function `__GI_memmove':
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/libio/../string/bits/string_fortified.h:36:
> undefined reference to `__GI___memmove_chk'
> /usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld:
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc_pic.os.clean:
> in function `__GI_memmove':
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/string/../string/bits/string_fortified.h:36:
> undefined reference to `__GI___memmove_chk'
> /usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld:
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/string/../string/bits/string_fortified.h:36:
> undefined reference to `__GI___memmove_chk'
> /usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld:
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc_pic.os.clean:
> in function `__GI_memmove':
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/io/../string/bits/string_fortified.h:36:
> undefined reference to `__GI___memmove_chk'
> /usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld:
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/io/../string/bits/string_fortified.h:36:
> undefined reference to `__GI___memmove_chk'
> /usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld:
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc_pic.os.clean:/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/io/../string/bits/string_fortified.h:36:
> more undefined references to `__GI___memmove_chk' follow
> collect2: error: ld returned 1 exit status
> make[2]: *** [../Makerules:647:
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/cc-base/libc.so]
> Error 1
> make[2]: Leaving directory
> '/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.594.g5324d25842/elf'
> make[1]: *** [Makefile:484: elf/subdir_lib] Error 2
> make: *** [Makefile:9: all] Error 2
>
> Hello,

Please review
https://patchwork.sourceware.org/project/glibc/patch/20230706172047.528695-1-fberat@redhat.com/

> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
>
>
Andreas Schwab July 11, 2023, 8:44 a.m. UTC | #7
https://build.opensuse.org/package/live_build_log/home:Andreas_Schwab:glibc/glibc:i686/f/i586

make[2]: Entering directory '/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/support'
gcc -o /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/support/test-run-command -nostdlib -nostartfiles -static -static-pie -Wl,-z,pack-relative-relocs    /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/csu/rcrt1.o /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/csu/crti.o `gcc  --print-file-name=crtbeginS.o` /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/support/test-run-command.o /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/elf/static-stubs.o /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/support/libsupport_nonshared.a -Wl,-z,now -Wl,--start-group /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/libc.a -lgcc  -Wl,--end-group `gcc  --print-file-name=crtendS.o` /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/csu/crtn.o
/usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/libc.a(memset_chk-nonshared.o): unsupported non-PIC call to IFUNC `memset'
/usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [../Rules:290: /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/support/test-run-command] Error 1
make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/support'
Frederic Berat July 12, 2023, 1:35 p.m. UTC | #8
On Tue, Jul 11, 2023 at 10:44 AM Andreas Schwab <schwab@suse.de> wrote:

>
> https://build.opensuse.org/package/live_build_log/home:Andreas_Schwab:glibc/glibc:i686/f/i586
>
> make[2]: Entering directory
> '/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/support'
> gcc -o
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/support/test-run-command
> -nostdlib -nostartfiles -static -static-pie -Wl,-z,pack-relative-relocs
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/csu/rcrt1.o
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/csu/crti.o
> `gcc  --print-file-name=crtbeginS.o`
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/support/test-run-command.o
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/elf/static-stubs.o
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/support/libsupport_nonshared.a
> -Wl,-z,now -Wl,--start-group
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/libc.a
> -lgcc  -Wl,--end-group `gcc  --print-file-name=crtendS.o`
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/csu/crtn.o
> /usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld:
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/libc.a(memset_chk-nonshared.o):
> unsupported non-PIC call to IFUNC `memset'
> /usr/lib/gcc/i586-suse-linux/13/../../../../i586-suse-linux/bin/ld: failed
> to set dynamic section sizes: bad value
> collect2: error: ld returned 1 exit status
> make[2]: *** [../Rules:290:
> /home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/cc-base/support/test-run-command]
> Error 1
> make[2]: Leaving directory
> '/home/abuild/rpmbuild/BUILD/glibc-2.37.9000.604.g7f079fdc16/support'
>
>
This one will take a bit more time to analyze,  I finally succeeded to
reproduce it at least and I'm trying to figure out what's going on.
Andreas Schwab July 12, 2023, 1:38 p.m. UTC | #9
This is fixed by commit ca230f5833.
Frederic Berat July 12, 2023, 1:42 p.m. UTC | #10
On Wed, Jul 12, 2023 at 3:38 PM Andreas Schwab <schwab@suse.de> wrote:

> This is fixed by commit ca230f5833.
>
> Great thanks !

> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
>
>