Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

powerpc64*: use --with-long-double-format=ieee #170215

Merged
merged 13 commits into from Apr 16, 2023
Merged
20 changes: 16 additions & 4 deletions pkgs/development/compilers/gcc/common/platform-flags.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{ lib, targetPlatform }:

let
p = targetPlatform.gcc or {}
gcc = targetPlatform.gcc or {};
p = gcc
// targetPlatform.parsed.abi;
in lib.concatLists [
(lib.optional (!targetPlatform.isx86_64 && p ? arch) "--with-arch=${p.arch}") # --with-arch= is unknown flag on x86_64
Expand All @@ -10,7 +11,18 @@ in lib.concatLists [
(lib.optional (p ? fpu) "--with-fpu=${p.fpu}")
(lib.optional (p ? float) "--with-float=${p.float}")
(lib.optional (p ? mode) "--with-mode=${p.mode}")
(lib.optional
(let tp = targetPlatform; in tp.isPower && tp.libc == "glibc" && tp.is64bit)
"--with-long-double-128")
(lib.optionals targetPlatform.isPower64
# musl explicitly rejects 128-bit long double on
# powerpc64; see musl/arch/powerpc64/bits/float.h
(lib.optionals
(!targetPlatform.isMusl
&& (targetPlatform.isLittleEndian ||
# "... --with-long-double-format is only supported if the default cpu is power7 or newer"
# https://github.com/NixOS/nixpkgs/pull/170215#issuecomment-1202164709
(lib.lists.elem
(lib.strings.substring 0 6 (p.cpu or ""))
[ "power7" "power8" "power9" "power1"/*0, 11, etc*/ ]))) [
"--with-long-double-128"
"--with-long-double-format=${gcc.long-double-format or "ieee"}"
]))
]
12 changes: 11 additions & 1 deletion pkgs/development/libraries/gettext/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{ stdenv, lib, fetchurl, fetchpatch, libiconv, xz, bash }:
{ stdenv, lib, fetchurl, fetchpatch, libiconv, xz, bash
, gnulib
}:

# Note: this package is used for bootstrapping fetchurl, and thus
# cannot use fetchpatch! All mutable patches (generated by GitHub or
Expand Down Expand Up @@ -45,6 +47,14 @@ stdenv.mkDerivation rec {
'' + lib.optionalString stdenv.hostPlatform.isCygwin ''
sed -i -e "s/\(cldr_plurals_LDADD = \)/\\1..\/gnulib-lib\/libxml_rpl.la /" gettext-tools/src/Makefile.in
sed -i -e "s/\(libgettextsrc_la_LDFLAGS = \)/\\1..\/gnulib-lib\/libxml_rpl.la /" gettext-tools/src/Makefile.in
'' +
# This change to gettext's vendored copy of gnulib is already
# merged upstream; we can drop this patch on the next version
# bump. It must be applied twice because gettext vendors gnulib
# not once, but twice!
''
patch -p2 -d gettext-tools/gnulib-lib/ < ${gnulib.passthru.longdouble-redirect-patch}
patch -p2 -d gettext-tools/libgrep/ < ${gnulib.passthru.longdouble-redirect-patch}
'';

strictDeps = true;
Expand Down
7 changes: 7 additions & 0 deletions pkgs/development/libraries/glibc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ in
# Same for musl: https://github.com/NixOS/nixpkgs/issues/78805
"-Wno-error=missing-attributes"
])
(lib.optionals (stdenv.hostPlatform.isPower64) [
# Do not complain about the Processor Specific ABI (i.e. the
# choice to use IEEE-standard `long double`). We pass this
# flag in order to mute a `-Werror=psabi` passed by glibc;
# hopefully future glibc releases will not pass that flag.
"-Wno-error=psabi"
])
]);
};

Expand Down
1 change: 0 additions & 1 deletion pkgs/development/libraries/goffice/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ stdenv.mkDerivation rec {
buildInputs = [ libxslt librsvg ];

enableParallelBuilding = true;
doCheck = !stdenv.hostPlatform.isPower64;

passthru = {
updateScript = gnome.updateScript {
Expand Down
10 changes: 7 additions & 3 deletions pkgs/development/libraries/mpfr/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ stdenv.mkDerivation rec {
# mpfr.h requires gmp.h
propagatedBuildInputs = [ gmp ];

configureFlags =
lib.optional stdenv.hostPlatform.isSunOS "--disable-thread-safe" ++
lib.optional stdenv.hostPlatform.is64bit "--with-pic";
configureFlags = lib.optional stdenv.hostPlatform.isSunOS "--disable-thread-safe"
++ lib.optional stdenv.hostPlatform.is64bit "--with-pic"
++ lib.optional stdenv.hostPlatform.isPower64 [
# Without this, the `tget_set_d128` test experiences a link
# error due to missing `__dpd_trunctdkf`.
"--disable-decimal-float"
];

doCheck = true; # not cross;

Expand Down
11 changes: 11 additions & 0 deletions pkgs/development/tools/gnulib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ stdenv.mkDerivation {
# do not change headers to not update all vendored build files
dontFixup = true;

passthru = {
# This patch is used by multiple other packages (currently:
# gnused, gettext) which contain vendored copies of gnulib.
# Without it, compilation will fail with error messages about
# "__LDBL_REDIR1_DECL" or similar on platforms with longdouble
# redirects (currently powerpc64). Once all of those other
# packages make a release with a newer gnulib we can drop this
# patch.
Mic92 marked this conversation as resolved.
Show resolved Hide resolved
longdouble-redirect-patch = ./gnulib-longdouble-redirect.patch;
};

meta = with lib; {
description = "Central location for code to be shared among GNU packages";
homepage = "https://www.gnu.org/software/gnulib/";
Expand Down
72 changes: 72 additions & 0 deletions pkgs/development/tools/gnulib/gnulib-longdouble-redirect.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

Below is the subset of gnulib commit
776af40e09b476a41073131a90022572f448c189 which deals with long double
redirects. The rest of that commit has been removed.

diff --git a/lib/cdefs.h b/lib/cdefs.h
index fd72b7b..4383e70 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -483,7 +493,37 @@
# include <bits/long-double.h>
#endif

-#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
+#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
+# ifdef __REDIRECT
+
+/* Alias name defined automatically. */
+# define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
+# define __LDBL_REDIR_DECL(name) \
+ extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
+
+/* Alias name defined automatically, with leading underscores. */
+# define __LDBL_REDIR2_DECL(name) \
+ extern __typeof (__##name) __##name \
+ __asm (__ASMNAME ("__" #name "ieee128"));
+
+/* Alias name defined manually. */
+# define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
+# define __LDBL_REDIR1_DECL(name, alias) \
+ extern __typeof (name) name __asm (__ASMNAME (#alias));
+
+# define __LDBL_REDIR1_NTH(name, proto, alias) \
+ __REDIRECT_NTH (name, proto, alias)
+# define __REDIRECT_NTH_LDBL(name, proto, alias) \
+ __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
+
+/* Unused. */
+# define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
+# define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
+
+# else
+_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
+# endif
+#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
# define __LDBL_COMPAT 1
# ifdef __REDIRECT
# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
@@ -492,6 +532,8 @@
# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
# define __LDBL_REDIR_NTH(name, proto) \
__LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
+# define __LDBL_REDIR2_DECL(name) \
+ extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
# define __LDBL_REDIR1_DECL(name, alias) \
extern __typeof (name) name __asm (__ASMNAME (#alias));
# define __LDBL_REDIR_DECL(name) \
@@ -502,11 +544,13 @@
__LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
# endif
#endif
-#if !defined __LDBL_COMPAT || !defined __REDIRECT
+#if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \
+ || !defined __REDIRECT
# define __LDBL_REDIR1(name, proto, alias) name proto
# define __LDBL_REDIR(name, proto) name proto
# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
+# define __LDBL_REDIR2_DECL(name)
# define __LDBL_REDIR_DECL(name)
# ifdef __REDIRECT
# define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
9 changes: 9 additions & 0 deletions pkgs/development/tools/misc/texinfo/common.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ version, sha256, patches ? [] }:

{ lib, stdenv, buildPackages, fetchurl, perl, xz, libintl, bash
, gnulib

# we are a dependency of gcc, this simplifies bootstraping
, interactive ? false, ncurses, procps
Expand Down Expand Up @@ -30,6 +31,12 @@ stdenv.mkDerivation {

postPatch = ''
patchShebangs tp/maintain
''
# This patch is needed for IEEE-standard long doubles on
# powerpc64; it does not apply cleanly to texinfo 5.x or
# earlier. It is merged upstream in texinfo 6.8.
+ lib.optionalString (with lib.strings; versionAtLeast version "6.0" && versionOlder version "6.8") ''
patch -p1 -d gnulib < ${gnulib.passthru.longdouble-redirect-patch}
'';

# ncurses is required to build `makedoc'
Expand Down Expand Up @@ -82,6 +89,8 @@ stdenv.mkDerivation {
license = licenses.gpl3Plus;
platforms = platforms.all;
maintainers = with maintainers; [ vrthra oxij ];
# see comment above in patches section
broken = stdenv.hostPlatform.isPower64 && lib.strings.versionOlder version "6.0";

longDescription = ''
Texinfo is the official documentation format of the GNU project.
Expand Down