Summary: | dev-libs/gmp[asm]: broken on s390 ("libgmp.so: undefined reference to `sdiv_qrnnd'") | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Sam James <sam> |
Component: | Current packages | Assignee: | Gentoo Toolchain Maintainers <toolchain> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | s390 |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | s390 | ||
OS: | Linux | ||
URL: | https://gmplib.org/list-archives/gmp-bugs/2016-December/004039.html | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: |
mpfr's config.log
mpfr build.log gmp-6.2.0-r1 build.log build.log (with tests failing) |
Description
Sam James
2020-12-23 02:49:57 UTC
Created attachment 679281 [details] mpfr build.log vapier actually had this problem a few years ago: https://gmplib.org/list-archives/gmp-bugs/2016-December/004039.html On installation of either gmp version in tree: * Messages for package dev-libs/gmp-6.2.0-r1: * QA Notice: Package triggers severe warnings which indicate that it * may exhibit random runtime failures. * udiv_w_sdiv.c:57:4: warning: implicit declaration of function �sdiv_qrnnd�; did you mean �udiv_qrnnd�? [-Wimplicit-function-declaration] * Please do not file a Gentoo bug and instead report the above QA * issues directly to the upstream developers of this software. * Homepage: https://gmplib.org/ >>> Auto-cleaning packages... So, the error makes complete sense. It should really be failing hard at build time. Created attachment 679284 [details]
gmp-6.2.0-r1 build.log
Does gmp pass tests while having this deficiency? Created attachment 679317 [details] build.log (with tests failing) (In reply to Sergei Trofimovich from comment #4) > Does gmp pass tests while having this deficiency? No, see newly attached log. I was confused by initially reading the bug as a breakage that happens when you rebuild gmp with USE=asm then USE=-asm. But you just get invalid gmp on each build, is that correct? I wonder if -march=native causes wrong CPU arch flavour to be detected. Otherwise we mask USE flips for a long while: commit 32849ef2e24987dc6d53d3159c3febe8d3ed2852 Author: Mike Frysinger <vapier@gentoo.org> Date: Fri Dec 9 13:45:58 2016 -0500 profiles: s390: force gmp[asm] for now to fix ABI breakage diff --git a/profiles/arch/s390/package.use.force b/profiles/arch/s390/package.use.force index 5db5bc85195..46dcb506821 100644 --- a/profiles/arch/s390/package.use.force +++ b/profiles/arch/s390/package.use.force @@ -5,3 +5,8 @@ # Mike Frysinger <vapier@gentoo.org> (16 Mar 2015) # Needs dev-lang/luajit tested #499974 dev-libs/efl oldlua + +# Mike Frysinger <vapier@gentoo.org> (09 Dec 2016) +# The ABI changes when the flag is disabled. Force it for now. +# https://gmplib.org/list-archives/gmp-bugs/2016-December/004039.html +dev-libs/gmp asm Tried on lgentoo3.s390.dev.gentoo.org and it's indeed a -march=native. Reproduced on: $ LANG=C PORTAGE_TMPDIR=${HOME}/tmp LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu" CFLAGS="-O2 -pipe -march=native -fdiagnostics-show-option -frecord-gcc-switches" CXXFLAGS="-O2 -pipe -march=native" ebuild /var/db/repos/gentoo/dev-libs/gmp/gmp-6.2.1.ebuild clean test -march=native on that machine expands to -march=arch13 -mesa -mhard-dfp -mhtm -mzarch $ arch=arch13; for t in param target; do cmd="gcc -Q -O2 -march=$arch --help=$t"; diff -U0 <(LANG=C $cmd) <(LANG=C $cmd -march=native); done --- /dev/fd/61 2021-03-01 18:47:38.000000000 -0500 +++ /dev/fd/60 2021-03-01 18:47:38.000000000 -0500 @@ -9 +9 @@ - -mesa [enabled] + -mesa [disabled] @@ -16 +16 @@ - -mhard-dfp [disabled] + -mhard-dfp [enabled] @@ -19 +19 @@ - -mhtm [disabled] + -mhtm [enabled] @@ -44 +44 @@ - -mzarch [disabled] + -mzarch [enabled] Of all the above CFLAGS="-O2 -mzarch" seems to be enough to trigger use of undefined symbol. On C level -mzarch provides 2 extra macros: $ diff -U0 <(s390-unknown-linux-gnu-gcc -dM -E - </dev/null) <(s390-unknown-linux-gnu-gcc -dM -E - </dev/null -mzarch) --- /dev/fd/63 2021-03-01 23:58:13.631079627 +0000 +++ /dev/fd/62 2021-03-01 23:58:13.631079627 +0000 @@ -52,0 +53 @@ +#define __zarch__ 1 @@ -321,0 +323 @@ +#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1 Only __zarch__ looks relevant for gmp. sdiv_qrnnd() is a macro defined in longlong.h but only for some cases: #if (defined (__i370__) || defined (__s390__) || defined (__mvs__)) && W_TYPE_SIZE == 32 #if defined (__zarch__) || defined (HAVE_HOST_CPU_s390_zarch) #define add_ssaaaa(... #define sub_ddmmss( #if __GMP_GNUC_PREREQ (4,5) #define umul_ppmm( #else #if 0 #define umul_ppmm(... #else #define umul_ppmm(... #endif /* if 0 */ #endif #if 0 #define udiv_qrnnd(... #else #define udiv_qrnnd(... #endif /* if 0 */ #else /* if __zarch__ */ #define smul_ppmm(... #define sdiv_qrnnd(... #endif /* if __zarch__ */ Note: sdiv_qrnnd() is not defined for __zarch__ case relying on availability of 64-bit arithmetics. Only udiv_w_sdiv.c uses the sdiv_qrnnd() and is included only for non-z targets in configure.ac: # IBM System/390 and z/Architecture S390_PATTERN | S390X_PATTERN) if test "$enable_assembly" = "yes" ; then extra_functions="udiv_w_sdiv" fi case $host_cpu in s390) ;; z900 | z900esa) AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_s390_$cpu) AC_DEFINE(HAVE_HOST_CPU_s390_zarch) extra_functions="" ;; z990 | z990esa) AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_s390_$cpu) AC_DEFINE(HAVE_HOST_CPU_s390_zarch) extra_functions="" ;; z9 | z9esa) AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_s390_$cpu) AC_DEFINE(HAVE_HOST_CPU_s390_zarch) extra_functions="" ;; z10 | z10esa) AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_s390_$cpu) AC_DEFINE(HAVE_HOST_CPU_s390_zarch) extra_functions="" ;; z196 | z196esa) AC_DEFINE_UNQUOTED(HAVE_HOST_CPU_s390_$cpu) AC_DEFINE(HAVE_HOST_CPU_s390_zarch) extra_functions="" ;; esac case $host in S390X_PATTERN) extra_functions="" ;; esac This creates a mismatch between __zarch__ definition and ./configure assumption. The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e9697a383036e80b9d79a038d8b0e879f71db67c commit e9697a383036e80b9d79a038d8b0e879f71db67c Author: Sergei Trofimovich <slyfox@gentoo.org> AuthorDate: 2021-03-02 00:29:48 +0000 Commit: Sergei Trofimovich <slyfox@gentoo.org> CommitDate: 2021-03-02 00:33:33 +0000 dev-libs/gmp: fix s390 symbol leak on -mzarch Reported-by: Sam James Bug: https://bugs.gentoo.org/761310 Package-Manager: Portage-3.0.16, Repoman-3.0.2 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> dev-libs/gmp/files/gmp-6.2.1-no-zarch.patch | 20 ++++++ dev-libs/gmp/gmp-6.2.1-r1.ebuild | 108 ++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+) |