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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 47D191382C5 for ; Mon, 24 May 2021 22:09:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 90EF7E01B5; Mon, 24 May 2021 22:09:07 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 648ECE01B5 for ; Mon, 24 May 2021 22:09:07 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 14CE2335D06 for ; Mon, 24 May 2021 22:09:06 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 985CD597 for ; Mon, 24 May 2021 22:09:04 +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: <1621894135.ca58a4b159282f564f046e035a17f7ce0bd30f01.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/numpy/, dev-python/numpy/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-python/numpy/files/numpy-1.20.2-fix-popcnt-detection.patch dev-python/numpy/numpy-1.20.2-r1.ebuild dev-python/numpy/numpy-1.20.2.ebuild dev-python/numpy/numpy-1.20.3.ebuild X-VCS-Directories: dev-python/numpy/ dev-python/numpy/files/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: ca58a4b159282f564f046e035a17f7ce0bd30f01 X-VCS-Branch: master Date: Mon, 24 May 2021 22:09:04 +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: b6cc783a-ada3-4bc1-a879-8bc39b934267 X-Archives-Hash: b12baca5e1e9687728726ff4353e8767 commit: ca58a4b159282f564f046e035a17f7ce0bd30f01 Author: Sam James gentoo org> AuthorDate: Mon May 24 22:08:17 2021 +0000 Commit: Sam James gentoo org> CommitDate: Mon May 24 22:08:55 2021 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ca58a4b1 dev-python/numpy: add popcnt patch Closes: https://bugs.gentoo.org/788184 Signed-off-by: Sam James gentoo.org> .../files/numpy-1.20.2-fix-popcnt-detection.patch | 103 +++++++++++++++++++++ ...{numpy-1.20.2.ebuild => numpy-1.20.2-r1.ebuild} | 1 + dev-python/numpy/numpy-1.20.3.ebuild | 1 + 3 files changed, 105 insertions(+) diff --git a/dev-python/numpy/files/numpy-1.20.2-fix-popcnt-detection.patch b/dev-python/numpy/files/numpy-1.20.2-fix-popcnt-detection.patch new file mode 100644 index 00000000000..85f4bb11b76 --- /dev/null +++ b/dev-python/numpy/files/numpy-1.20.2-fix-popcnt-detection.patch @@ -0,0 +1,103 @@ +https://github.com/numpy/numpy/pull/19074 +https://bugs.gentoo.org/788184 + +From 8dc768964b5578a8aa9db1ef2c55134a00731e10 Mon Sep 17 00:00:00 2001 +From: Carl Michal +Date: Sat, 22 May 2021 20:43:10 -0700 +Subject: [PATCH 1/2] Fix compile-time test of POPCNT + +The compile-time test of POPCNT, cpu_popcnt.c produced code that would +execute without error even if the machine didn't support the popcnt +instruction. This patch attempts to use popcnt on random numbers so the +compiler can't substitute the answer at compile time. +--- + numpy/distutils/checks/cpu_popcnt.c | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/numpy/distutils/checks/cpu_popcnt.c b/numpy/distutils/checks/cpu_popcnt.c +index e6a80fb40be4..f6c785dd2a97 100644 +--- a/numpy/distutils/checks/cpu_popcnt.c ++++ b/numpy/distutils/checks/cpu_popcnt.c +@@ -4,20 +4,26 @@ + #include + #endif + ++#include ++ + int main(void) + { + long long a = 0; + int b; ++ ++ a = random(); ++ b = random(); ++ + #ifdef _MSC_VER + #ifdef _M_X64 +- a = _mm_popcnt_u64(1); ++ a = _mm_popcnt_u64(a); + #endif +- b = _mm_popcnt_u32(1); ++ b = _mm_popcnt_u32(b); + #else + #ifdef __x86_64__ +- a = __builtin_popcountll(1); ++ a = __builtin_popcountll(a); + #endif +- b = __builtin_popcount(1); ++ b = __builtin_popcount(b); + #endif + return (int)a + b; + } + +From 52d5fe1ede45083d0783c3e2bbaee5c44df9d553 Mon Sep 17 00:00:00 2001 +From: Carl Michal +Date: Sun, 23 May 2021 08:24:52 -0700 +Subject: [PATCH 2/2] Change fix of cpu_popcnt.c to use + _mm_popcnt_u64/_mm_popcnt_u32 on GCC + +_builtin_popcount is always available, so the compile-time check always +succeeds. +--- + numpy/distutils/checks/cpu_popcnt.c | 26 ++++++++------------------ + 1 file changed, 8 insertions(+), 18 deletions(-) + +diff --git a/numpy/distutils/checks/cpu_popcnt.c b/numpy/distutils/checks/cpu_popcnt.c +index f6c785dd2a97..540c98dab05d 100644 +--- a/numpy/distutils/checks/cpu_popcnt.c ++++ b/numpy/distutils/checks/cpu_popcnt.c +@@ -4,26 +4,16 @@ + #include + #endif + +-#include +- +-int main(void) ++int main(int argc, char **argv) + { +- long long a = 0; +- int b; +- +- a = random(); +- b = random(); +- +-#ifdef _MSC_VER +- #ifdef _M_X64 ++ // To make sure popcnt instructions are generated ++ // and been tested against the assembler ++ unsigned long long a = *((unsigned long long*)argv[argc-1]); ++ unsigned int b = *((unsigned int*)argv[argc-2]); ++ ++#if defined(_M_X64) || defined(__x86_64__) + a = _mm_popcnt_u64(a); +- #endif +- b = _mm_popcnt_u32(b); +-#else +- #ifdef __x86_64__ +- a = __builtin_popcountll(a); +- #endif +- b = __builtin_popcount(b); + #endif ++ b = _mm_popcnt_u32(b); + return (int)a + b; + } diff --git a/dev-python/numpy/numpy-1.20.2.ebuild b/dev-python/numpy/numpy-1.20.2-r1.ebuild similarity index 98% rename from dev-python/numpy/numpy-1.20.2.ebuild rename to dev-python/numpy/numpy-1.20.2-r1.ebuild index 234a0932bb9..2e16936ea19 100644 --- a/dev-python/numpy/numpy-1.20.2.ebuild +++ b/dev-python/numpy/numpy-1.20.2-r1.ebuild @@ -48,6 +48,7 @@ BDEPEND=" PATCHES=( "${FILESDIR}"/numpy-1.20.1-no-hardcode-blasv2.patch "${FILESDIR}"/numpy-1.20.2-fix-ccompiler-tests.patch + "${FILESDIR}"/numpy-1.20.2-fix-popcnt-detection.patch ) distutils_enable_tests pytest diff --git a/dev-python/numpy/numpy-1.20.3.ebuild b/dev-python/numpy/numpy-1.20.3.ebuild index 5b772a58a6f..6604eb23a4e 100644 --- a/dev-python/numpy/numpy-1.20.3.ebuild +++ b/dev-python/numpy/numpy-1.20.3.ebuild @@ -46,6 +46,7 @@ BDEPEND=" PATCHES=( "${FILESDIR}"/numpy-1.20.1-no-hardcode-blasv2.patch "${FILESDIR}"/numpy-1.20.2-fix-ccompiler-tests.patch + "${FILESDIR}"/numpy-1.20.2-fix-popcnt-detection.patch "${FILESDIR}"/numpy-1.20.3-float-hashing-py310.patch )