From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 882DD158009 for ; Mon, 26 Jun 2023 13:14:51 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 88EAEE0928; Mon, 26 Jun 2023 13:14:50 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 72404E0928 for ; Mon, 26 Jun 2023 13:14:50 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 4055A340DD9 for ; Mon, 26 Jun 2023 13:14:49 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 9ABD1AC6 for ; Mon, 26 Jun 2023 13:14:47 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1687785258.6e1f8eac3fc440fe8fe3de5d6f408e1a209df777.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/numpy/files/, dev-python/numpy/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-python/numpy/files/numpy-1.25.0-fix-long-double-check.patch dev-python/numpy/numpy-1.25.0.ebuild X-VCS-Directories: dev-python/numpy/ dev-python/numpy/files/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 6e1f8eac3fc440fe8fe3de5d6f408e1a209df777 X-VCS-Branch: master Date: Mon, 26 Jun 2023 13:14:47 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 2f697d6b-f636-40c5-b2e4-d4dd824ffa46 X-Archives-Hash: 9909cd908f5d971de91231c940f5a29d commit: 6e1f8eac3fc440fe8fe3de5d6f408e1a209df777 Author: Sam James gentoo org> AuthorDate: Mon Jun 26 13:11:27 2023 +0000 Commit: Sam James gentoo org> CommitDate: Mon Jun 26 13:14:18 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6e1f8eac dev-python/numpy: backport long double check fix Many thanks to matoro for this. Closes: https://bugs.gentoo.org/908738 Signed-off-by: Sam James gentoo.org> .../files/numpy-1.25.0-fix-long-double-check.patch | 151 +++++++++++++++++++++ dev-python/numpy/numpy-1.25.0.ebuild | 1 + 2 files changed, 152 insertions(+) diff --git a/dev-python/numpy/files/numpy-1.25.0-fix-long-double-check.patch b/dev-python/numpy/files/numpy-1.25.0-fix-long-double-check.patch new file mode 100644 index 000000000000..4f3ef21c93b3 --- /dev/null +++ b/dev-python/numpy/files/numpy-1.25.0-fix-long-double-check.patch @@ -0,0 +1,151 @@ +https://github.com/numpy/numpy/commit/de0b2d5c6dee9303c4a055e7591978ed5a06e403 + +From de0b2d5c6dee9303c4a055e7591978ed5a06e403 Mon Sep 17 00:00:00 2001 +From: matoro +Date: Sun, 18 Jun 2023 19:39:06 -0400 +Subject: [PATCH] BLD: Port long double identification to C for meson + +This ports the old Python code for identifying the long double +representation to C, so that it can be easily invoked by meson. The +original implementation is at https://github.com/numpy/numpy/blob/eead09a3d02c09374942cdc787c0b5e4fe9e7472/numpy/core/setup_common.py#L264-L434 + +The C portion of the code has been tested and confirmed to work on +systems with the following formats, either natively or via an +alternative ABI: INTEL_EXTENDED_16_BYTES_LE, IEEE_QUAD_BE, +IEEE_QUAD_LE, IBM_DOUBLE_DOUBLE_BE, IBM_DOUBLE_DOUBLE_LE, +IEEE_DOUBLE_BE, INTEL_EXTENDED_12_BYTES_LE. + +The original meson port includes an error condition with the comment +"This should not be possible, 12 bits of "content" should still result +in sizeof() being 16." As far as I can tell this is incorrect, as +compiling on an x86_64 system with 32-bit ABI (gcc -m32) does indeed +have sizeof(long double)==12. This is reflected in the C code. + +Closes gh-23972, closes +https://github.com/mesonbuild/meson/issues/11068. +--- + numpy/core/meson.build | 110 ++++++++++++++++++++++++++++++++--------- + 1 file changed, 87 insertions(+), 23 deletions(-) + +diff --git a/numpy/core/meson.build b/numpy/core/meson.build +index 3427de408f1..92b393e4bc1 100644 +--- a/numpy/core/meson.build ++++ b/numpy/core/meson.build +@@ -361,29 +361,93 @@ foreach intrin: optional_intrinsics + endif + endforeach + +-# long double representation detection (see setup_common.py) +-# TODO: this is still incomplete, and different from how it's done in the +-# numpy.distutils based build, see https://github.com/mesonbuild/meson/issues/11068 +-longdouble_size = cc.sizeof('long double') +-if longdouble_size == 8 +- if host_machine.endian() == 'little' +- longdouble_format = 'IEEE_DOUBLE_LE' +- else +- longdouble_format = 'IEEE_DOUBLE_BE' +- endif +-elif longdouble_size == 12 +- error('This should not be possible, 12 bits of "content" should still result in sizeof() being 16. Please report this error!' +- ) +-elif longdouble_size == 16 +- if host_machine.endian() == 'little' +- # FIXME: this varies, there's multiple formats here! Not yet implemented. +- # TBD how we deal with the mess of old long double formats. +- longdouble_format = 'INTEL_EXTENDED_16_BYTES_LE' +- else +- error('No idea what this is ....') +- endif +-else +- error('Unknown long double size: ' + londouble_size) ++# This is a port of the old python code for identifying the long double ++# representation to C. The old Python code is in this range: ++# https://github.com/numpy/numpy/blob/eead09a3d02c09374942cdc787c0b5e4fe9e7472/numpy/core/setup_common.py#L264-L434 ++# This port is in service of solving gh-23972 ++# as well as https://github.com/mesonbuild/meson/issues/11068 ++longdouble_format = meson.get_compiler('c').run( ++''' ++#include ++#include ++ ++#define repcmp(z) (memcmp((const char *)&foo.x, z, sizeof(foo.x)) == 0) ++ ++const struct { ++ char before[16]; ++ long double x; ++ char after[8]; ++} foo = {{'\0'}, -123456789.0, {'\0'}}; ++ ++int main(void) { ++ switch (sizeof(foo.x)) { ++ case 8: { ++ if (repcmp( ++ ((const char[]){0000, 0000, 0000, 0124, 0064, 0157, 0235, 0301}))) { ++ fprintf(stdout, "IEEE_DOUBLE_LE"); ++ return 0; ++ } ++ if (repcmp( ++ ((const char[]){0301, 0235, 0157, 0064, 0124, 0000, 0000, 0000}))) { ++ fprintf(stdout, "IEEE_DOUBLE_BE"); ++ return 0; ++ } ++ fprintf(stdout, "UNKNOWN"); ++ return 1; ++ } ++ case 12: { ++ if (repcmp(((const char[]){0000, 0000, 0000, 0000, 0240, 0242, 0171, 0353, ++ 0031, 0300, 0000, 0000}))) { ++ fprintf(stdout, "INTEL_EXTENDED_12_BYTES_LE"); ++ return 0; ++ } ++ if (repcmp(((const char[]){0300, 0031, 0000, 0000, 0353, 0171, 0242, 0240, ++ 0000, 0000, 0000, 0000}))) { ++ fprintf(stdout, "MOTOROLA_EXTENDED_12_BYTES_BE"); ++ return 0; ++ } ++ fprintf(stdout, "UNKNOWN"); ++ return 1; ++ } ++ case 16: { ++ if (repcmp( ++ ((const char[]){0000, 0000, 0000, 0000, 0240, 0242, 0171, 0353, ++ 0031, 0300, 0000, 0000, 0000, 0000, 0000, 0000}))) { ++ fprintf(stdout, "INTEL_EXTENDED_16_BYTES_LE"); ++ return 0; ++ } ++ if (repcmp( ++ ((const char[]){0300, 0031, 0326, 0363, 0105, 0100, 0000, 0000, ++ 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000}))) { ++ fprintf(stdout, "IEEE_QUAD_BE"); ++ return 0; ++ } ++ if (repcmp( ++ ((const char[]){0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, ++ 0000, 0000, 0100, 0105, 0363, 0326, 0031, 0300}))) { ++ fprintf(stdout, "IEEE_QUAD_LE"); ++ return 0; ++ } ++ if (repcmp( ++ ((const char[]){0000, 0000, 0000, 0124, 0064, 0157, 0235, 0301, ++ 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000}))) { ++ fprintf(stdout, "IBM_DOUBLE_DOUBLE_LE"); ++ return 0; ++ } ++ if (repcmp( ++ ((const char[]){0301, 0235, 0157, 0064, 0124, 0000, 0000, 0000, ++ 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000}))) { ++ fprintf(stdout, "IBM_DOUBLE_DOUBLE_BE"); ++ return 0; ++ } ++ fprintf(stdout, "UNKNOWN"); ++ return 1; ++ } ++ } ++} ++''').stdout() ++if longdouble_format == 'UNKNOWN' or longdouble_format == 'UNDEFINED' ++ error('Unknown long double format of size: ' + cc.sizeof('long double').to_string()) + endif + cdata.set10('HAVE_LDOUBLE_' + longdouble_format, true) + + diff --git a/dev-python/numpy/numpy-1.25.0.ebuild b/dev-python/numpy/numpy-1.25.0.ebuild index fc0a38bcd8ac..46dd443d0758 100644 --- a/dev-python/numpy/numpy-1.25.0.ebuild +++ b/dev-python/numpy/numpy-1.25.0.ebuild @@ -53,6 +53,7 @@ BDEPEND=" PATCHES=( "${FILESDIR}"/${PN}-1.25.0_rc1-meson-pyproject.toml.patch "${FILESDIR}"/${PN}-1.25.0-skip-python3.12-irrelevant-tests.patch + "${FILESDIR}"/${PN}-1.25.0-fix-long-double-check.patch ) distutils_enable_tests pytest