[PATCH v2] S390: Always enable static PIE if build with lld.
Stefan Liebler
stli@linux.ibm.com
Wed Feb 21 14:56:10 GMT 2024
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
--
2.43.0
More information about the Libc-alpha
mailing list