public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] S390: Always enable static PIE if build with lld.
@ 2024-02-19 15:49 Stefan Liebler
  2024-02-20 14:49 ` Adhemerval Zanella Netto
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Liebler @ 2024-02-19 15:49 UTC (permalink / raw)
  To: libc-alpha; +Cc: Stefan Liebler

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 lld.
---
 sysdeps/s390/s390-64/configure    | 10 ++++++++--
 sysdeps/s390/s390-64/configure.ac | 10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/sysdeps/s390/s390-64/configure b/sysdeps/s390/s390-64/configure
index 824ae9c129..c26785f32f 100644
--- a/sysdeps/s390/s390-64/configure
+++ b/sysdeps/s390/s390-64/configure
@@ -12,8 +12,14 @@ 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
     ;;
   *)
     # 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..2b5bffc107 100644
--- a/sysdeps/s390/s390-64/configure.ac
+++ b/sysdeps/s390/s390-64/configure.ac
@@ -12,8 +12,14 @@ 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
     ;;
   *)
     # The required binutils patches are available with bintuils 2.39
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] S390: Always enable static PIE if build with lld.
  2024-02-19 15:49 [PATCH] S390: Always enable static PIE if build with lld Stefan Liebler
@ 2024-02-20 14:49 ` Adhemerval Zanella Netto
  2024-02-21  7:51   ` Stefan Liebler
  0 siblings, 1 reply; 4+ messages in thread
From: Adhemerval Zanella Netto @ 2024-02-20 14:49 UTC (permalink / raw)
  To: Stefan Liebler, libc-alpha



On 19/02/24 12:49, Stefan Liebler wrote:
> 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.

What about old lld that does not have the cherry-picked commits? Should
we follow other practice and check this with a proper test instead?

> 
> This patch just enables static PIE if build with lld.
> ---
>  sysdeps/s390/s390-64/configure    | 10 ++++++++--
>  sysdeps/s390/s390-64/configure.ac | 10 ++++++++--
>  2 files changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/sysdeps/s390/s390-64/configure b/sysdeps/s390/s390-64/configure
> index 824ae9c129..c26785f32f 100644
> --- a/sysdeps/s390/s390-64/configure
> +++ b/sysdeps/s390/s390-64/configure
> @@ -12,8 +12,14 @@ 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
>      ;;
>    *)
>      # 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..2b5bffc107 100644
> --- a/sysdeps/s390/s390-64/configure.ac
> +++ b/sysdeps/s390/s390-64/configure.ac
> @@ -12,8 +12,14 @@ 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
>      ;;
>    *)
>      # The required binutils patches are available with bintuils 2.39

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] S390: Always enable static PIE if build with lld.
  2024-02-20 14:49 ` Adhemerval Zanella Netto
@ 2024-02-21  7:51   ` Stefan Liebler
  2024-02-21 15:05     ` Stefan Liebler
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Liebler @ 2024-02-21  7:51 UTC (permalink / raw)
  To: Adhemerval Zanella Netto, libc-alpha

On 20.02.24 15:49, Adhemerval Zanella Netto wrote:
> 
> 
> On 19/02/24 12:49, Stefan Liebler wrote:
>> 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.
> 
> What about old lld that does not have the cherry-picked commits? Should
> we follow other practice and check this with a proper test instead?
In case of s390x, older lld also do not support s390x at all and the
common link-configure tests will fail.

If you fear that somebody might backport the s390-lld-support patch
without the TPOFF patch, e.g. ldconfig is linked as static PIE and will
fail at startup.

But yes, I can just add a version check to lld 18 as known minimum
version. Then if somebody has backported the support to a previous
version, the PIE configure check will detect if both patches were
backported.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] S390: Always enable static PIE if build with lld.
  2024-02-21  7:51   ` Stefan Liebler
@ 2024-02-21 15:05     ` Stefan Liebler
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Liebler @ 2024-02-21 15:05 UTC (permalink / raw)
  To: libc-alpha

On 21.02.24 08:51, Stefan Liebler wrote:
> On 20.02.24 15:49, Adhemerval Zanella Netto wrote:
>>
>>
>> On 19/02/24 12:49, Stefan Liebler wrote:
>>> 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.
>>
>> What about old lld that does not have the cherry-picked commits? Should
>> we follow other practice and check this with a proper test instead?
> In case of s390x, older lld also do not support s390x at all and the
> common link-configure tests will fail.
> 
> If you fear that somebody might backport the s390-lld-support patch
> without the TPOFF patch, e.g. ldconfig is linked as static PIE and will
> fail at startup.
> 
> But yes, I can just add a version check to lld 18 as known minimum
> version. Then if somebody has backported the support to a previous
> version, the PIE configure check will detect if both patches were
> backported.
I've just posted v2 with an additional version check:
https://sourceware.org/pipermail/libc-alpha/2024-February/154896.html

One further hint:
If somebody bootstraps the toolchain from scratch, then there are no
crt-files and the linking configure-tests always fail. Thus static PIE
would not be enabled. Therefore there is the additional version check
which checks for known lld version which allows static PIE.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-21 15:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-19 15:49 [PATCH] S390: Always enable static PIE if build with lld Stefan Liebler
2024-02-20 14:49 ` Adhemerval Zanella Netto
2024-02-21  7:51   ` Stefan Liebler
2024-02-21 15:05     ` Stefan Liebler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).