glibc-2.36 fails to build with Os, but builds without error with O2. Built using: echo "rootsbindir=/usr/sbin" > configparms CC="gcc -mtune=generic -Os -pipe" ../configure --prefix=/usr --disable-werror --enable-kernel=5.4.3 --enable-stack-protector=strong --with-headers=/usr/include libc_cv_slibdir=/lib --enable-obsolete-rpc --libexecdir=/usr/lib/glibc find . -name config.make -type f -exec sed -i 's/-g -O2//g' {} \; find . -name config.status -type f -exec sed -i 's/-g -O2//g' {} \; find ../ -name Makeconfig -type f -exec sed -i 's/-g -O2//g' {} \; make /usr/lib/gcc/x86_64-tc-linux-gnu/12.2.0/../../../../x86_64-tc-linux-gnu/bin/ld: /sources/glibc-2.36/build/elf/librtld.os: in function `_dl_start_profile': (.text+0x9587): undefined reference to `strcpy' /usr/lib/gcc/x86_64-tc-linux-gnu/12.2.0/../../../../x86_64-tc-linux-gnu/bin/ld: /sources/glibc-2.36/build/elf/librtld.os: in function `_dl_load_cache_lookup': (.text+0xe5fd): undefined reference to `strcpy' collect2: error: ld returned 1 exit status make[2]: *** [Makefile:1346: /sources/glibc-2.36/build/elf/ld.so] Error 1
This is a duplicate of: https://sourceware.org/bugzilla/show_bug.cgi?id=29576 and was fixed by: commit 9dc4e29f630c6ef8299120b275e503321dc0c8c7 Author: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> Date: Wed Sep 21 10:51:08 2022 -0300 x86: Fix -Os build (BZ #29576) Maybe we should backport the fix?
If I understand correctly, backporting the commit https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=9dc4e29f630c6ef8299120b275e503321dc0c8c7 means deleting sysdeps/x86_64/multiarch/rtld-strcpy.S ..but the error remains the same with or without this file.
(In reply to john.frankish from comment #2) > If I understand correctly, backporting the commit > https://sourceware.org/git/?p=glibc.git;a=commitdiff; > h=9dc4e29f630c6ef8299120b275e503321dc0c8c7 means deleting > sysdeps/x86_64/multiarch/rtld-strcpy.S > > ..but the error remains the same with or without this file. Do you have the following commit: commit 302bc33bc53c787da6e74162a7092e9c0fb964a8 Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Mon Aug 8 11:26:22 2022 +0800 elf: Replace `strcpy` call with `memcpy` [BZ #29454]
Thanks - that appears to have solved the problem of compiling for i486 with -Os. Note that the glibc-2.36 tarball already contains the file added by commit 9dc4e29f630c6ef8299120b275e503321dc0c8c7 I'll check building for x86_64 with -Os in a day or two.
I back(In reply to john.frankish from comment #5) > Thanks - that appears to have solved the problem of compiling for i486 with > -Os. > > Note that the glibc-2.36 tarball already contains the file added by commit > 9dc4e29f630c6ef8299120b275e503321dc0c8c7 > > I'll check building for x86_64 with -Os in a day or two. I just backported the required patch to build glibc with -Os for x86 on 2.36 and I also send some fixes for upstream to build for -Os/-O1 on all targets [1]. [1] https://patchwork.sourceware.org/project/glibc/list/?series=15572
Mark as duplicated. *** This bug has been marked as a duplicate of bug 29576 ***
glibc-2.36 fails to build with -Os for x86_64 with commit 302bc33bc53c787da6e74162a7092e9c0fb964a8 glibc-2.36 builds with -O2 for x86_64 and it builds with -Os for x86 (i486) gcc -mtune=generic -Os -pipe -nostdlib -nostartfiles -shared -o /usr/src/glibc-2.36/build/elf/ld.so.new \ -Wl,-z,relro -Wl,-z,defs \ -Wl,-z,pack-relative-relocs \ /usr/src/glibc-2.36/build/elf/librtld.os -Wl,--version-script=/usr/src/glibc-2.36/build/ld.map \ -Wl,-soname=ld-linux-x86-64.so.2 /usr/local/bin/ld: /usr/src/glibc-2.36/build/elf/librtld.os: in function `_dl_start_profile': (.text+0x9643): undefined reference to `strcpy' collect2: error: ld returned 1 exit status
(In reply to john.frankish from comment #8) > glibc-2.36 fails to build with -Os for x86_64 with commit > 302bc33bc53c787da6e74162a7092e9c0fb964a8 > > glibc-2.36 builds with -O2 for x86_64 and it builds with -Os for x86 (i486) > > gcc -mtune=generic -Os -pipe -nostdlib -nostartfiles -shared -o > /usr/src/glibc-2.36/build/elf/ld.so.new \ > -Wl,-z,relro -Wl,-z,defs \ > -Wl,-z,pack-relative-relocs \ > /usr/src/glibc-2.36/build/elf/librtld.os > -Wl,--version-script=/usr/src/glibc-2.36/build/ld.map \ > -Wl,-soname=ld-linux-x86-64.so.2 > /usr/local/bin/ld: /usr/src/glibc-2.36/build/elf/librtld.os: in function > `_dl_start_profile': > (.text+0x9643): undefined reference to `strcpy' > collect2: error: ld returned 1 exit status Does it still happen with 2.36 branch [1]? [1] https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/release/2.36/master
If you're referring to commit 4f4d7a13edfd2fdc57c9d76e1fd6d017fb47550c this patch is already present in glibc-2.36.tar.xz If you're referring to the entire branch [1], please excuse my ignorance, but how do I clone branch [1] from glibc git?
(In reply to john.frankish from comment #10) > If you're referring to commit 4f4d7a13edfd2fdc57c9d76e1fd6d017fb47550c this > patch is already present in glibc-2.36.tar.xz > > If you're referring to the entire branch [1], please excuse my ignorance, > but how do I clone branch [1] from glibc git? I mean the git branch for 2.36, since glibc usually does not release minor versions for the source packages release. And the process is described in the 'get started' pane [1]: $ git clone https://sourceware.org/git/glibc.git $ cd glibc $ git checkout release/2.36/master You can also accomplish the same with one command: $ git clone -b release/2.36/master https://sourceware.org/git/glibc.git [1] https://www.gnu.org/software/libc/started.html
Thanks - I confirm that both x86 (i486) and x86_64 build with -Os