From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id F14E1158094 for ; Sat, 25 Jun 2022 21:40:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 576FAE08DD; Sat, 25 Jun 2022 21:40:07 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 1D213E08EB for ; Sat, 25 Jun 2022 21:40:07 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0DCF23410D2 for ; Sat, 25 Jun 2022 21:40:06 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 57624501 for ; Sat, 25 Jun 2022 21:40:03 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1656193168.02aa6328a720c86d0157c4582f7e5bac72ae9296.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/glibc/ X-VCS-Repository: repo/gentoo X-VCS-Files: sys-libs/glibc/glibc-2.35-r7.ebuild sys-libs/glibc/glibc-9999.ebuild sys-libs/glibc/metadata.xml X-VCS-Directories: sys-libs/glibc/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 02aa6328a720c86d0157c4582f7e5bac72ae9296 X-VCS-Branch: master Date: Sat, 25 Jun 2022 21:40:03 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 088ea341-e829-4c82-92c5-4ffe840d0993 X-Archives-Hash: f4b69a2e0474e281d71ef0979faa4cd5 commit: 02aa6328a720c86d0157c4582f7e5bac72ae9296 Author: James Le Cuirot gentoo org> AuthorDate: Sat Jun 11 21:11:12 2022 +0000 Commit: Sam James gentoo org> CommitDate: Sat Jun 25 21:39:28 2022 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=02aa6328 sys-libs/glibc: Add stack-realign flag for compat with old 32-bit x86 binaries Older 32-bit x86 binaries aligned the stack to 4 bytes, whereas modern binaries align to 16 bytes. These older binaries sometimes segfault when newer libraries use SSE instructions. This is becoming increasingly common. Applying the -mstackrealign flag to the 32-bit build works around the issue but at a performance cost. Other popular distributions always apply this. [sam: There's no good choices here. As Ionen pointed out (I'd missed any reports of this), this ends up getting worse with GCC 12's default-on vectorisation at -O2. Let's make it optional for now for 32-bit/x86 (irrelevant for other arches, it's specific to x86 ABI). ncurses is going to need similar treatment. If we end up having to do this for far more packages, we may revisit and e.g. just append-flags in ebuilds for right ABI and tell users to set -mno-stackrealign, or similar. Another option would be to set this globally by default (again, this is only ever for x86), but it'd possibly be a big performance hit (and bad enough doing it in glibc, but it's unavoidable). The only saving grace here is that there aren't _that_ many libraries with such longevity & ABI stability from back then that older applications are using.] Bug: https://bugs.gentoo.org/616402 Bug: https://github.com/taviso/123elf/issues/12 Signed-off-by: James Le Cuirot gentoo.org> Closes: https://github.com/gentoo/gentoo/pull/25858 Signed-off-by: Sam James gentoo.org> sys-libs/glibc/glibc-2.35-r7.ebuild | 31 ++++++++++++++++++------------- sys-libs/glibc/glibc-9999.ebuild | 31 ++++++++++++++++++------------- sys-libs/glibc/metadata.xml | 1 + 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/sys-libs/glibc/glibc-2.35-r7.ebuild b/sys-libs/glibc/glibc-2.35-r7.ebuild index a9b4a0d16717..3e8358532526 100644 --- a/sys-libs/glibc/glibc-2.35-r7.ebuild +++ b/sys-libs/glibc/glibc-2.35-r7.ebuild @@ -44,7 +44,7 @@ SRC_URI+=" https://gitweb.gentoo.org/proj/locale-gen.git/snapshot/locale-gen-${L SRC_URI+=" multilib-bootstrap? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )" SRC_URI+=" systemd? ( https://gitweb.gentoo.org/proj/toolchain/glibc-systemd.git/snapshot/glibc-systemd-${GLIBC_SYSTEMD_VER}.tar.gz )" -IUSE="audit caps cet +clone3 compile-locales +crypt custom-cflags doc experimental-loong gd headers-only +multiarch multilib multilib-bootstrap nscd profile selinux +ssp +static-libs suid systemd systemtap test vanilla" +IUSE="audit caps cet +clone3 compile-locales +crypt custom-cflags doc experimental-loong gd headers-only +multiarch multilib multilib-bootstrap nscd profile selinux +ssp stack-realign +static-libs suid systemd systemtap test vanilla" # Minimum kernel version that glibc requires MIN_KERN_VER="3.2.0" @@ -305,22 +305,27 @@ setup_target_flags() { export CFLAGS="-march=${t} ${CFLAGS}" einfo "Auto adding -march=${t} to CFLAGS #185404" fi + # For compatibility with older binaries at slight performance cost. + use stack-realign && export CFLAGS+=" -mstackrealign" ;; amd64) # -march needed for #185404 #199334 # TODO: See cross-compile issues listed above for x86. - [[ ${ABI} == x86 ]] && - if ! do_compile_test "${CFLAGS_x86}" 'void f(int i, void *p) {if (__sync_fetch_and_add(&i, 1)) f(i, p);}\nint main(){return 0;}\n'; then - local t=${CTARGET_OPT:-${CTARGET}} - t=${t%%-*} - # Normally the target is x86_64-xxx, so turn that into the -march that - # gcc actually accepts. #528708 - [[ ${t} == "x86_64" ]] && t="x86-64" - filter-flags '-march=*' - # ugly, ugly, ugly. ugly. - CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}") - export CFLAGS_x86="${CFLAGS_x86} -march=${t}" - einfo "Auto adding -march=${t} to CFLAGS_x86 #185404 (ABI=${ABI})" + if [[ ${ABI} == x86 ]]; then + if ! do_compile_test "${CFLAGS_x86}" 'void f(int i, void *p) {if (__sync_fetch_and_add(&i, 1)) f(i, p);}\nint main(){return 0;}\n'; then + local t=${CTARGET_OPT:-${CTARGET}} + t=${t%%-*} + # Normally the target is x86_64-xxx, so turn that into the -march that + # gcc actually accepts. #528708 + [[ ${t} == "x86_64" ]] && t="x86-64" + filter-flags '-march=*' + # ugly, ugly, ugly. ugly. + CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}") + export CFLAGS_x86="${CFLAGS_x86} -march=${t}" + einfo "Auto adding -march=${t} to CFLAGS_x86 #185404 (ABI=${ABI})" + fi + # For compatibility with older binaries at slight performance cost. + use stack-realign && export CFLAGS_x86+=" -mstackrealign" fi ;; mips) diff --git a/sys-libs/glibc/glibc-9999.ebuild b/sys-libs/glibc/glibc-9999.ebuild index 2a030e2f9928..b35b2febd192 100644 --- a/sys-libs/glibc/glibc-9999.ebuild +++ b/sys-libs/glibc/glibc-9999.ebuild @@ -44,7 +44,7 @@ SRC_URI+=" https://gitweb.gentoo.org/proj/locale-gen.git/snapshot/locale-gen-${L SRC_URI+=" multilib-bootstrap? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )" SRC_URI+=" systemd? ( https://gitweb.gentoo.org/proj/toolchain/glibc-systemd.git/snapshot/glibc-systemd-${GLIBC_SYSTEMD_VER}.tar.gz )" -IUSE="audit caps cet compile-locales +crypt custom-cflags doc gd headers-only +multiarch multilib multilib-bootstrap nscd profile selinux +ssp +static-libs suid systemd systemtap test vanilla" +IUSE="audit caps cet compile-locales +crypt custom-cflags doc gd headers-only +multiarch multilib multilib-bootstrap nscd profile selinux +ssp stack-realign +static-libs suid systemd systemtap test vanilla" # Minimum kernel version that glibc requires MIN_KERN_VER="3.2.0" @@ -305,22 +305,27 @@ setup_target_flags() { export CFLAGS="-march=${t} ${CFLAGS}" einfo "Auto adding -march=${t} to CFLAGS #185404" fi + # For compatibility with older binaries at slight performance cost. + use stack-realign && export CFLAGS+=" -mstackrealign" ;; amd64) # -march needed for #185404 #199334 # TODO: See cross-compile issues listed above for x86. - [[ ${ABI} == x86 ]] && - if ! do_compile_test "${CFLAGS_x86}" 'void f(int i, void *p) {if (__sync_fetch_and_add(&i, 1)) f(i, p);}\nint main(){return 0;}\n'; then - local t=${CTARGET_OPT:-${CTARGET}} - t=${t%%-*} - # Normally the target is x86_64-xxx, so turn that into the -march that - # gcc actually accepts. #528708 - [[ ${t} == "x86_64" ]] && t="x86-64" - filter-flags '-march=*' - # ugly, ugly, ugly. ugly. - CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}") - export CFLAGS_x86="${CFLAGS_x86} -march=${t}" - einfo "Auto adding -march=${t} to CFLAGS_x86 #185404 (ABI=${ABI})" + if [[ ${ABI} == x86 ]]; then + if ! do_compile_test "${CFLAGS_x86}" 'void f(int i, void *p) {if (__sync_fetch_and_add(&i, 1)) f(i, p);}\nint main(){return 0;}\n'; then + local t=${CTARGET_OPT:-${CTARGET}} + t=${t%%-*} + # Normally the target is x86_64-xxx, so turn that into the -march that + # gcc actually accepts. #528708 + [[ ${t} == "x86_64" ]] && t="x86-64" + filter-flags '-march=*' + # ugly, ugly, ugly. ugly. + CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}") + export CFLAGS_x86="${CFLAGS_x86} -march=${t}" + einfo "Auto adding -march=${t} to CFLAGS_x86 #185404 (ABI=${ABI})" + fi + # For compatibility with older binaries at slight performance cost. + use stack-realign && export CFLAGS_x86+=" -mstackrealign" fi ;; mips) diff --git a/sys-libs/glibc/metadata.xml b/sys-libs/glibc/metadata.xml index e00a008ac5c3..bcaf604fa542 100644 --- a/sys-libs/glibc/metadata.xml +++ b/sys-libs/glibc/metadata.xml @@ -17,6 +17,7 @@ Provide prebuilt libgcc.a and crt files if missing. Only needed for ABI switch. Build, and enable support for, the Name Service Cache Daemon protect stack of glibc internals + Realign the stack in the 32-bit build for compatibility with older binaries at slight performance cost Enable static PIE support (runtime files for -static-pie gcc option). Make internal pt_chown helper setuid -- not needed if using Linux and have /dev/pts mounted with gid=5 enable systemtap static probe points