From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 2883E3858D33 for ; Wed, 16 Aug 2023 15:30:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2883E3858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37GFOVVi007978; Wed, 16 Aug 2023 15:30:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : subject : to : references : cc : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pp1; bh=T11efuFM400SMnw38sxLzA9xUACGRivWWbwkzx/RysY=; b=HejWM90Ct9WQnEUkYPddlWBS62lWbusRywoWs28IXgma6Ho4O7hHv60nEDAXvSe+PU+L z5ABQDUr+mOl+kMkATHhZhRUgl5fSoXn7Wx4sqfpAquM+DKOcRT59k2PzCZKX1r2O7SB rIsHXFhVcJKu7z3PTga9cdY9TGsYf1CLCgDnwALxQIp4ySWHcta8vSxWamDB08PQqzX2 IhKIwKfx/4OM6QHNUsnAxXMw5pAnd7LSRpXS6FBoJuk2X4LLVzkgZnyIngOg81wXaHIW regBOicwAPWv4xOiXcfTNSjsq1IAJVcCOXFWa8hs7yIm8b5a3iuHINBZlYnu+IXQX624 tQ== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sh12u8579-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Aug 2023 15:30:01 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 37GFKCA7007871; Wed, 16 Aug 2023 15:30:00 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3senwkdrv1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Aug 2023 15:30:00 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 37GFTwbN62521750 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Aug 2023 15:29:58 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3D4DF20043; Wed, 16 Aug 2023 15:29:58 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EDAAC20040; Wed, 16 Aug 2023 15:29:57 +0000 (GMT) Received: from [9.179.23.22] (unknown [9.179.23.22]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 16 Aug 2023 15:29:57 +0000 (GMT) Message-ID: <6fcb41c9-0412-d07d-6154-e3dc05ef49e1@linux.ibm.com> Date: Wed, 16 Aug 2023 17:29:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v2] s390x: Fix static PIE condition for toolchain bootstrapping. Content-Language: en-US To: GNU C Library References: <20230814122224.2993204-1-stli@linux.ibm.com> Cc: Andreas Schwab From: Stefan Liebler In-Reply-To: <20230814122224.2993204-1-stli@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: LktGAwYfMmu4HyVWqwkYaAblDLopu46L X-Proofpoint-GUID: LktGAwYfMmu4HyVWqwkYaAblDLopu46L Content-Transfer-Encoding: 7bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-16_15,2023-08-15_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 mlxscore=0 priorityscore=1501 spamscore=0 adultscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 bulkscore=0 impostorscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308160130 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP,URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: @Andreas Schwab: As requested by you, in v2 I've use test ... || test ... instead of -o. If there is no other objection, I'll commit this patch later this week. On 14.08.23 14:22, Stefan Liebler wrote: > The static PIE configure check uses link tests. When bootstrapping > a cross-toolchain, the link tests fail due to missing crt-files / > libc.so. As we explicitely want to test an issue in binutils (ld), > we now also explicitely check for known linker versions. > > See also commit 368b7c614b102122b86af3953daea2b30230d0a8 > S390: Use compile-only instead of also link-tests in configure. > --- > sysdeps/s390/s390-64/configure | 110 ++++++++++++++++++++++++++++-- > sysdeps/s390/s390-64/configure.ac | 40 +++++++++-- > 2 files changed, 138 insertions(+), 12 deletions(-) > > diff --git a/sysdeps/s390/s390-64/configure b/sysdeps/s390/s390-64/configure > index 2784f158ea..824ae9c129 100644 > --- a/sysdeps/s390/s390-64/configure > +++ b/sysdeps/s390/s390-64/configure > @@ -1,13 +1,107 @@ > # This file is generated from configure.ac by Autoconf. DO NOT EDIT! > # Local configure fragment for sysdeps/s390/s390-64. > > +# Bypass result of runtime configure check for known linker versions as > +# e.g. crt-files or libc.so might not be available in bootstrapping > +# environments. > +case $($LD --version) in > + "GNU gold"*) > + # As of 2023-08-07, gold does not support static PIE due to > + # Bug 22221 - add --no-dynamic-linker option > + # https://sourceware.org/bugzilla/show_bug.cgi?id=22221 > + libc_cv_s390x_staticpie_req_version=no > + ;; > + "LLD"*) > + # As of 2023-08-07, there is no lld which supports s390x. > + libc_cv_s390x_staticpie_req_version=no > + ;; > + *) > + # The required binutils patches are available with bintuils 2.39 > + libc_cv_s390x_staticpie_req_version=yes > + # Skip AC_CHECK_PROGS and just use the result from main configure.ac. > + libc_cv_s390x_staticpie_req_LD=$LD > + for ac_prog in $LD > +do > + # Extract the first word of "$ac_prog", so it can be a program name with args. > +set dummy $ac_prog; ac_word=$2 > +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 > +printf %s "checking for $ac_word... " >&6; } > +if test ${ac_cv_prog_libc_cv_s390x_staticpie_req_LD+y} > +then : > + printf %s "(cached) " >&6 > +else $as_nop > + if test -n "$libc_cv_s390x_staticpie_req_LD"; then > + ac_cv_prog_libc_cv_s390x_staticpie_req_LD="$libc_cv_s390x_staticpie_req_LD" # Let the user override the test. > +else > +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR > +for as_dir in $PATH > +do > + IFS=$as_save_IFS > + case $as_dir in #((( > + '') as_dir=./ ;; > + */) ;; > + *) as_dir=$as_dir/ ;; > + esac > + for ac_exec_ext in '' $ac_executable_extensions; do > + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then > + ac_cv_prog_libc_cv_s390x_staticpie_req_LD="$ac_prog" > + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 > + break 2 > + fi > +done > + done > +IFS=$as_save_IFS > + > +fi > +fi > +libc_cv_s390x_staticpie_req_LD=$ac_cv_prog_libc_cv_s390x_staticpie_req_LD > +if test -n "$libc_cv_s390x_staticpie_req_LD"; then > + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_s390x_staticpie_req_LD" >&5 > +printf "%s\n" "$libc_cv_s390x_staticpie_req_LD" >&6; } > +else > + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 > +printf "%s\n" "no" >&6; } > +fi > + > + > + test -n "$libc_cv_s390x_staticpie_req_LD" && break > +done > + > +if test -z "$libc_cv_s390x_staticpie_req_LD"; then > + ac_verc_fail=yes > +else > + # Found it, now check the version. > + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking version of $libc_cv_s390x_staticpie_req_LD" >&5 > +printf %s "checking version of $libc_cv_s390x_staticpie_req_LD... " >&6; } > + ac_prog_version=`$libc_cv_s390x_staticpie_req_LD --version 2>&1 | sed -n 's/^.*GNU ld.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'` > + case $ac_prog_version in > + '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; > + 2.1[0-9][0-9]*|2.39*|2.[4-9][0-9]*|[3-9].*|[1-9][0-9]*) > + ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; > + *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; > + > + esac > + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_prog_version" >&5 > +printf "%s\n" "$ac_prog_version" >&6; } > +fi > +if test $ac_verc_fail = yes; then > + libc_cv_s390x_staticpie_req_version=no > +fi > + > + ;; > +esac > +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for s390-specific static PIE requirements (version check)" >&5 > +printf %s "checking for s390-specific static PIE requirements (version check)... " >&6; } > +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_s390x_staticpie_req_version" >&5 > +printf "%s\n" "$libc_cv_s390x_staticpie_req_version" >&6; } > + > # Minimal checking for static PIE support in ld. > # Compare to ld testcase/bugzilla: > # /ld/testsuite/ld-elf/pr22263-1.rd > -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for s390-specific static PIE requirements" >&5 > -printf %s "checking for s390-specific static PIE requirements... " >&6; } > +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for s390-specific static PIE requirements (runtime check)" >&5 > +printf %s "checking for s390-specific static PIE requirements (runtime check)... " >&6; } > if { as_var=\ > -libc_cv_s390x_staticpie_req; eval test \${$as_var+y}; } > +libc_cv_s390x_staticpie_req_runtime; eval test \${$as_var+y}; } > then : > printf %s "(cached) " >&6 > else $as_nop > @@ -32,7 +126,7 @@ main () > return 0; > } > EOF > - libc_cv_s390x_staticpie_req=no > + libc_cv_s390x_staticpie_req_runtime=no > if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -fPIE -c conftest1.c -o conftest1.o' > { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 > (eval $ac_try) 2>&5 > @@ -58,15 +152,17 @@ EOF > printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 > test $ac_status = 0; }; } > then > - libc_cv_s390x_staticpie_req=yes > + libc_cv_s390x_staticpie_req_runtime=yes > fi > rm -rf conftest.* > fi > eval ac_res=\$\ > -libc_cv_s390x_staticpie_req > +libc_cv_s390x_staticpie_req_runtime > { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 > printf "%s\n" "$ac_res" >&6; } > -if test $libc_cv_s390x_staticpie_req = yes; then > + > +if test $libc_cv_s390x_staticpie_req_runtime = yes \ > + || test $libc_cv_s390x_staticpie_req_version = yes; then > # Static PIE is supported only on 64bit. > # Ensure you also have those patches for: > # - binutils (ld) > diff --git a/sysdeps/s390/s390-64/configure.ac b/sysdeps/s390/s390-64/configure.ac > index d009f108b1..4657de0d37 100644 > --- a/sysdeps/s390/s390-64/configure.ac > +++ b/sysdeps/s390/s390-64/configure.ac > @@ -1,11 +1,39 @@ > GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. > # Local configure fragment for sysdeps/s390/s390-64. > > +# Bypass result of runtime configure check for known linker versions as > +# e.g. crt-files or libc.so might not be available in bootstrapping > +# environments. > +case $($LD --version) in > + "GNU gold"*) > + # As of 2023-08-07, gold does not support static PIE due to > + # Bug 22221 - add --no-dynamic-linker option > + # https://sourceware.org/bugzilla/show_bug.cgi?id=22221 > + libc_cv_s390x_staticpie_req_version=no > + ;; > + "LLD"*) > + # As of 2023-08-07, there is no lld which supports s390x. > + libc_cv_s390x_staticpie_req_version=no > + ;; > + *) > + # The required binutils patches are available with bintuils 2.39 > + libc_cv_s390x_staticpie_req_version=yes > + # Skip AC_CHECK_PROGS and just use the result from main configure.ac. > + libc_cv_s390x_staticpie_req_LD=$LD > + AC_CHECK_PROG_VER(libc_cv_s390x_staticpie_req_LD, $LD, --version, > + [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)], > + [2.1[0-9][0-9]*|2.39*|2.[4-9][0-9]*|[3-9].*|[1-9][0-9]*], > + libc_cv_s390x_staticpie_req_version=no) > + ;; > +esac > +AC_MSG_CHECKING([for s390-specific static PIE requirements (version check)]) > +AC_MSG_RESULT($libc_cv_s390x_staticpie_req_version) > + > # Minimal checking for static PIE support in ld. > # Compare to ld testcase/bugzilla: > # /ld/testsuite/ld-elf/pr22263-1.rd > -AC_CACHE_CHECK([for s390-specific static PIE requirements], \ > -[libc_cv_s390x_staticpie_req], [dnl > +AC_CACHE_CHECK([for s390-specific static PIE requirements (runtime check)], \ > +[libc_cv_s390x_staticpie_req_runtime], [dnl > cat > conftest1.c < __thread int * foo; > > @@ -27,16 +55,18 @@ main () > return 0; > } > EOF > - libc_cv_s390x_staticpie_req=no > + libc_cv_s390x_staticpie_req_runtime=no > if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -fPIE -c conftest1.c -o conftest1.o]) \ > && AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -fPIE -c conftest2.c -o conftest2.o]) \ > && AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -o conftest conftest1.o conftest2.o]) \ > && AC_TRY_COMMAND([! LC_ALL=C $READELF -Wr conftest | grep R_390_TLS_TPOFF]) > then > - libc_cv_s390x_staticpie_req=yes > + libc_cv_s390x_staticpie_req_runtime=yes > fi > rm -rf conftest.*]) > -if test $libc_cv_s390x_staticpie_req = yes; then > + > +if test $libc_cv_s390x_staticpie_req_runtime = yes \ > + || test $libc_cv_s390x_staticpie_req_version = yes; then > # Static PIE is supported only on 64bit. > # Ensure you also have those patches for: > # - binutils (ld)