From patchwork Wed Feb 21 14:56:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1902125 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=EzIzaMeM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TfzrY0TG1z20RF for ; Thu, 22 Feb 2024 01:57:01 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0D78E3858C53 for ; Wed, 21 Feb 2024 14:56:59 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 852B13858D34 for ; Wed, 21 Feb 2024 14:56:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 852B13858D34 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 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 852B13858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708527402; cv=none; b=LhZ5nKR/2CyD1Ur1a65cGzabfSDrEnjTkKubnOyU42Eqyxy8QwjbV/tn+ajjN+XpU8VIEWOvEJMp08byhvBmsbKx2COcq3ecUZwkih8+9R7gff66NuhTprblmbxZVjHv8BQftUvrERV8UTatwYuGNcppvDsSfat4F1iKn7Ade28= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708527402; c=relaxed/simple; bh=Q95e4gvG15NOfy2p9vBX1T1/6f9sP+6kVBPLdigETsM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Tj85MbZvpfG7a8IJVClXZeGLtNwBWafzYaIdm/w1w/1W5UvLzI4qvRD18g2bIq2l8VN3lwMvfzfzjIkVvhYwfj7m3mIbKuinE/ICmawDQWZphxK6X05SQK7i7LKVYgTSjErBk0Dty22sMFyhakAFVArHBivw+nfgvbrCrDOk8nw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41LEmHes008896; Wed, 21 Feb 2024 14:56:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : mime-version; s=pp1; bh=J6AGNpZLpimsAZZATgVxKSblW8ZrnelR0H/E31Mwqvo=; b=EzIzaMeMPB8jOPcAhnH/vtmY+gBL8utWYLCT81IjHiD78+HuIYP87YSNvHjLXe0/7bB0 3RXaM1VFaI9LdgJFg23gvRTAm7KSaDG7ASWAlLZ2ZcUmfOqOyJ1FoN++GE0Xl9zKh96C mOwOEN74k7Cq7Ti/8olKAJ4vJZpHUKviFof+wTnZ1WZE7UZJzQMAOHVj5mbdd7YRijcy ENwUb8Vaaj541FEc0Pw/ZrznqeRWU8HZXn7d0aBdVxqWRYjXkA08+MAMYTwl8BUu/LlR Ym2DSZYLIiX0POepGlcLoOT+KlXpN71FKYTD+GA18tI+ajXtaYDbbCeWQsYINpFa8PwX Vg== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wdk8rgb24-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 21 Feb 2024 14:56:39 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 41LDpnKZ031118; Wed, 21 Feb 2024 14:56:38 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wb9bkyb21-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 21 Feb 2024 14:56:38 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41LEuW8J14746174 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Feb 2024 14:56:34 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A4F252004F; Wed, 21 Feb 2024 14:56:32 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 84DB82005A; Wed, 21 Feb 2024 14:56:32 +0000 (GMT) Received: from t3560005.lnxne.boe (unknown [9.152.108.100]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 21 Feb 2024 14:56:32 +0000 (GMT) From: Stefan Liebler To: libc-alpha@sourceware.org Cc: adhemerval.zanella@linaro.org, Stefan Liebler Subject: [PATCH v2] S390: Always enable static PIE if build with lld. Date: Wed, 21 Feb 2024 15:56:10 +0100 Message-ID: <20240221145610.962170-1-stli@linux.ibm.com> X-Mailer: git-send-email 2.43.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: vloJ-p_Nnh4VbPoMO4IpaSD1mv3vBykS X-Proofpoint-ORIG-GUID: vloJ-p_Nnh4VbPoMO4IpaSD1mv3vBykS X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-21_01,2024-02-21_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 priorityscore=1501 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 mlxlogscore=990 bulkscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402210116 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org LLVM ld.lld now also supports s390x and avoids unnecessary TPOFF relocations for position independent executables. Both recent commits were also cherry-picked to LLVM 18. This patch just enables static PIE if build with supported lld. --- sysdeps/s390/s390-64/configure | 80 ++++++++++++++++++++++++++++++- sysdeps/s390/s390-64/configure.ac | 16 ++++++- 2 files changed, 92 insertions(+), 4 deletions(-) diff --git a/sysdeps/s390/s390-64/configure b/sysdeps/s390/s390-64/configure index 824ae9c129..d79a25ecf7 100644 --- a/sysdeps/s390/s390-64/configure +++ b/sysdeps/s390/s390-64/configure @@ -12,8 +12,84 @@ case $($LD --version) in 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 lld patches are available with LLVM 18: + # - [lld] Add target support for SystemZ (s390x) #75643 + # https://github.com/llvm/llvm-project/pull/75643 + # 2024-02-13: https://github.com/llvm/llvm-project/commit/fe3406e349884e4ef61480dd0607f1e237102c74 + # - [lld/ELF] Avoid unnecessary TPOFF relocations in GOT for -pie #81739 + # https://github.com/llvm/llvm-project/pull/81739 + # 2024-02-14: https://github.com/llvm/llvm-project/commit/6f907733e65d24edad65f763fb14402464bd578b + 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/^.*LLD.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'` + case $ac_prog_version in + '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; + 1[8-9].*|[2-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 + ;; *) # The required binutils patches are available with bintuils 2.39 diff --git a/sysdeps/s390/s390-64/configure.ac b/sysdeps/s390/s390-64/configure.ac index 4657de0d37..0c1b276086 100644 --- a/sysdeps/s390/s390-64/configure.ac +++ b/sysdeps/s390/s390-64/configure.ac @@ -12,8 +12,20 @@ case $($LD --version) in 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 lld patches are available with LLVM 18: + # - [lld] Add target support for SystemZ (s390x) #75643 + # https://github.com/llvm/llvm-project/pull/75643 + # 2024-02-13: https://github.com/llvm/llvm-project/commit/fe3406e349884e4ef61480dd0607f1e237102c74 + # - [lld/ELF] Avoid unnecessary TPOFF relocations in GOT for -pie #81739 + # https://github.com/llvm/llvm-project/pull/81739 + # 2024-02-14: https://github.com/llvm/llvm-project/commit/6f907733e65d24edad65f763fb14402464bd578b + 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, + [LLD.* \([0-9][0-9]*\.[0-9.]*\)], + [1[8-9].*|[2-9][0-9].*], + libc_cv_s390x_staticpie_req_version=no) ;; *) # The required binutils patches are available with bintuils 2.39