numpy: switch to upstream accepted patch

This commit is contained in:
Christoph Reiter
2021-11-10 07:02:51 +01:00
parent 68b22c4a02
commit ffa5129f38
4 changed files with 169 additions and 82 deletions

View File

@@ -1,42 +1,34 @@
diff --git a/numpy/distutils/mingw32ccompiler.py b/numpy/distutils/mingw32ccompiler.py
index 3358695..553f5b3 100644
--- a/numpy/distutils/mingw32ccompiler.py
+++ b/numpy/distutils/mingw32ccompiler.py
@@ -123,10 +123,12 @@ class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):
else:
# gcc-4 series releases do not support -mno-cygwin option
self.set_executables(
- compiler='gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall',
- compiler_so='gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes',
- linker_exe='gcc -g',
- linker_so='gcc -g -shared')
+ compiler='gcc -march=x86-64 -mtune=generic -DMS_WIN64'
+ ' -O2 -msse2 -Wall',
+ compiler_so='gcc -march=x86-64 -mtune=generic -DMS_WIN64'
+ ' -O2 -msse2 -Wall -Wstrict-prototypes',
+ linker_exe='gcc',
+ linker_so='gcc -shared -Wl,-gc-sections -Wl,-s')
--- numpy-1.21.2/numpy/distutils/mingw32ccompiler.py.orig 2021-11-10 06:32:17.306962300 +0100
+++ numpy-1.21.2/numpy/distutils/mingw32ccompiler.py 2021-11-10 06:34:08.568379600 +0100
@@ -86,17 +86,23 @@
# Py_ModuleInit4_64, etc... So we add it here
if get_build_architecture() == 'AMD64':
self.set_executables(
- compiler='gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall',
- compiler_so='gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall '
- '-Wstrict-prototypes',
- linker_exe='gcc -g',
- linker_so='gcc -g -shared')
+ compiler='gcc -march=x86-64 -mtune=generic -DMS_WIN64'
+ ' -O2 -msse2 -Wall',
+ compiler_so='gcc -march=x86-64 -mtune=generic -DMS_WIN64'
+ ' -O2 -msse2 -Wall -Wstrict-prototypes',
+ linker_exe='gcc',
+ linker_so='gcc -shared -Wl,-gc-sections -Wl,-s')
else:
if self.gcc_version <= "3.0.0":
self.set_executables(
@@ -145,10 +147,16 @@ class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):
linker_so='g++ -mno-cygwin -shared')
else:
# gcc-4 series releases do not support -mno-cygwin option
- self.set_executables(compiler='gcc -O2 -Wall',
- compiler_so='gcc -O2 -Wall -Wstrict-prototypes',
- linker_exe='g++ ',
- linker_so='g++ -shared')
+ self.set_executables(
+ compiler='gcc -O2 -march=core2 -mtune=generic'
+ ' -mfpmath=sse -msse2'
+ ' -mincoming-stack-boundary=2 -Wall',
+ compiler_so='gcc -O2 -march=core2 -mtune=generic'
+ ' -mfpmath=sse -msse2'
+ ' -mincoming-stack-boundary=2 -Wall'
+ ' -Wstrict-prototypes',
+ linker_exe='g++ ',
+ linker_so='g++ -shared -Wl,-gc-sections -Wl,-s')
self.set_executables(
- compiler='gcc -O2 -Wall',
- compiler_so='gcc -O2 -Wall -Wstrict-prototypes',
+ compiler='gcc -O2 -march=core2 -mtune=generic'
+ ' -mfpmath=sse -msse2'
+ ' -mincoming-stack-boundary=2 -Wall',
+ compiler_so='gcc -O2 -march=core2 -mtune=generic'
+ ' -mfpmath=sse -msse2'
+ ' -mincoming-stack-boundary=2 -Wall'
+ ' -Wstrict-prototypes',
linker_exe='g++ ',
- linker_so='g++ -shared')
+ linker_so='g++ -shared -Wl,-gc-sections -Wl,-s')
# added for python2.3 support
# we can't pass it through set_executables because pre 2.2 would fail
self.compiler_cxx = ['g++']

View File

@@ -1,36 +0,0 @@
From 28712799d934459b0d8a119e6a7a629def4016e1 Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Tue, 9 Nov 2021 09:44:55 +0100
Subject: [PATCH] BUG: fix gcc version detection fallback for Mingw32CCompiler
In case gcc_version is None it would try to parse the output, but
this code was never ported to Python 3, so it matches str with bytes
which raises a TypeError.
Fix by decoding the gcc output via the text option (available since py3.7)
Also fixes the reference to CalledProcessError
---
numpy/distutils/mingw32ccompiler.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/numpy/distutils/mingw32ccompiler.py b/numpy/distutils/mingw32ccompiler.py
index 82d296434..ac745fbaf 100644
--- a/numpy/distutils/mingw32ccompiler.py
+++ b/numpy/distutils/mingw32ccompiler.py
@@ -66,8 +66,10 @@ def __init__ (self,
# get_versions methods regex
if self.gcc_version is None:
try:
- out_string = subprocess.check_output(['gcc', '-dumpversion'])
- except (OSError, CalledProcessError):
+ out_string = subprocess.check_output(
+ ['gcc', '-dumpversion'],
+ text=True)
+ except (OSError, subprocess.CalledProcessError):
out_string = "" # ignore failures to match old behavior
result = re.search(r'(\d+\.\d+)', out_string)
if result:
--
2.33.0

View File

@@ -0,0 +1,130 @@
From 7e03a56194a9def4296ef502bb380d8cc4a2d061 Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Tue, 9 Nov 2021 19:18:52 +0100
Subject: [PATCH] DEP: remove code for supporting GCC <4 in Mingw32CCompiler
The last GCC 3.x release before 4.0 was 3.4 which was released 2004,
so 17 years ago.
Removes all code only used with those old toolchains.
---
numpy/distutils/mingw32ccompiler.py | 81 +++++------------------------
1 file changed, 12 insertions(+), 69 deletions(-)
diff --git a/numpy/distutils/mingw32ccompiler.py b/numpy/distutils/mingw32ccompiler.py
index 82d296434..fbe3655c9 100644
--- a/numpy/distutils/mingw32ccompiler.py
+++ b/numpy/distutils/mingw32ccompiler.py
@@ -24,7 +24,6 @@
# 3. Force windows to use g77
import distutils.cygwinccompiler
-from distutils.version import StrictVersion
from distutils.unixccompiler import UnixCCompiler
from distutils.msvccompiler import get_build_version as get_build_msvc_version
from distutils.errors import UnknownFileError
@@ -62,35 +61,6 @@ def __init__ (self,
distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, verbose,
dry_run, force)
- # we need to support 3.2 which doesn't match the standard
- # get_versions methods regex
- if self.gcc_version is None:
- try:
- out_string = subprocess.check_output(['gcc', '-dumpversion'])
- except (OSError, CalledProcessError):
- out_string = "" # ignore failures to match old behavior
- result = re.search(r'(\d+\.\d+)', out_string)
- if result:
- self.gcc_version = StrictVersion(result.group(1))
-
- # A real mingw32 doesn't need to specify a different entry point,
- # but cygwin 2.91.57 in no-cygwin-mode needs it.
- if self.gcc_version <= "2.91.57":
- entry_point = '--entry _DllMain@12'
- else:
- entry_point = ''
-
- if self.linker_dll == 'dllwrap':
- # Commented out '--driver-name g++' part that fixes weird
- # g++.exe: g++: No such file or directory
- # error (mingw 1.0 in Enthon24 tree, gcc-3.4.5).
- # If the --driver-name part is required for some environment
- # then make the inclusion of this part specific to that
- # environment.
- self.linker = 'dllwrap' # --driver-name g++'
- elif self.linker_dll == 'gcc':
- self.linker = 'g++'
-
# **changes: eric jones 4/11/01
# 1. Check for import library on Windows. Build if it doesn't exist.
@@ -113,42 +83,18 @@ def __init__ (self,
# kind of bad consequences, like using Py_ModuleInit4 instead of
# Py_ModuleInit4_64, etc... So we add it here
if get_build_architecture() == 'AMD64':
- if self.gcc_version < "4.0":
- self.set_executables(
- compiler='gcc -g -DDEBUG -DMS_WIN64 -mno-cygwin -O0 -Wall',
- compiler_so='gcc -g -DDEBUG -DMS_WIN64 -mno-cygwin -O0'
- ' -Wall -Wstrict-prototypes',
- linker_exe='gcc -g -mno-cygwin',
- linker_so='gcc -g -mno-cygwin -shared')
- else:
- # gcc-4 series releases do not support -mno-cygwin option
- self.set_executables(
- compiler='gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall',
- compiler_so='gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes',
- linker_exe='gcc -g',
- linker_so='gcc -g -shared')
+ self.set_executables(
+ compiler='gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall',
+ compiler_so='gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall '
+ '-Wstrict-prototypes',
+ linker_exe='gcc -g',
+ linker_so='gcc -g -shared')
else:
- if self.gcc_version <= "3.0.0":
- self.set_executables(
- compiler='gcc -mno-cygwin -O2 -w',
- compiler_so='gcc -mno-cygwin -mdll -O2 -w'
- ' -Wstrict-prototypes',
- linker_exe='g++ -mno-cygwin',
- linker_so='%s -mno-cygwin -mdll -static %s' %
- (self.linker, entry_point))
- elif self.gcc_version < "4.0":
- self.set_executables(
- compiler='gcc -mno-cygwin -O2 -Wall',
- compiler_so='gcc -mno-cygwin -O2 -Wall'
- ' -Wstrict-prototypes',
- linker_exe='g++ -mno-cygwin',
- linker_so='g++ -mno-cygwin -shared')
- else:
- # gcc-4 series releases do not support -mno-cygwin option
- self.set_executables(compiler='gcc -O2 -Wall',
- compiler_so='gcc -O2 -Wall -Wstrict-prototypes',
- linker_exe='g++ ',
- linker_so='g++ -shared')
+ self.set_executables(
+ compiler='gcc -O2 -Wall',
+ compiler_so='gcc -O2 -Wall -Wstrict-prototypes',
+ linker_exe='g++ ',
+ linker_so='g++ -shared')
# added for python2.3 support
# we can't pass it through set_executables because pre 2.2 would fail
self.compiler_cxx = ['g++']
@@ -198,10 +144,7 @@ def link(self,
extra_postargs,
build_temp,
target_lang)
- if self.gcc_version < "3.0.0":
- func = distutils.cygwinccompiler.CygwinCCompiler.link
- else:
- func = UnixCCompiler.link
+ func = UnixCCompiler.link
func(*args[:func.__code__.co_argcount])
return
--
2.33.0

View File

@@ -9,7 +9,7 @@ provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=1.21.2
pkgrel=2
pkgrel=3
pkgdesc="Scientific tools for Python (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
@@ -38,13 +38,13 @@ source=(https://github.com/numpy/numpy/releases/download/v${pkgver}/${_realname}
0010-mingw-inline-stuff.patch
0011-dont-die-if-no-fcompiler.patch
0012-clang-no-gcc-workaround.patch
1001-BUG-fix-gcc-version-detection-fallback-for-Mingw32CC.patch)
1001-DEP-remove-code-for-supporting-GCC-4-in-Mingw32CComp.patch)
sha256sums=('76af194fbc117934ec5bbe2ff15177adbd05aeed23f18ee209ed88edcd777e05'
'94f111ab238c4a82e8613ed14e4cbeb553eabff26523f576e5fcafdbfdc8ee29'
'3aacb1d92e7764c9f0f24afa1a97b136a069fcd81d63c9fa55565c40c5a29974'
'2679482ce9396b551e1e1e7674f373d139b3e8a2f9729026000dd3c581de41d7'
'a9023ca3ba0d4b444ef490ca9fa145896d24f34bb271676adf538d5da7546725'
'd2d7b83114e87f45656d9523f5536511bf16d5a54a4f3bfa852c5631651019f5'
'fb1a42a6eed1ea0795f9c91506623153157d4410a0f06ccb76eb80457fb6e8f5'
'fcacffaae853de592224bc51f1ecb3e617f2fc518d05373e1310aeabdf097254'
'cafc924fd11d8653a49970d0cce5b31869cce0e8996a3ae57bcbccca96bc8eb3'
'c7222c3cd85ff6af515514c5c3b8f3c02144c58c1373dec16683fa455504aa69'
@@ -52,7 +52,7 @@ sha256sums=('76af194fbc117934ec5bbe2ff15177adbd05aeed23f18ee209ed88edcd777e05'
'ae47d0c8adbae798ca1675ae9c0a35146bad00c6b5734f713cd76c01832e5436'
'87bdd0a47a8662bdb8acaca18452901ee1f42cf08b985443ffb214f7facfdb2d'
'86eceee1ec86934d416c52fe8197c09c644b9f27ab93454a849e065b1ddac12f'
'23fff39667622d0c76e16b213ce5f2543f3e6c1b7e32ce1448fd5f7c55cdd27d')
'6c4e44409e4611f7ddece6af7bb45bb31316ea031dca8a8794c3f1237f950db7')
# Helper macros to help make tasks easier #
@@ -66,6 +66,11 @@ apply_patch_with_msg() {
prepare() {
cd ${_realname}-${pkgver}
# https://github.com/numpy/numpy/pull/20333
apply_patch_with_msg \
1001-DEP-remove-code-for-supporting-GCC-4-in-Mingw32CComp.patch
apply_patch_with_msg \
0001-detect-mingw-environment.patch \
0002-fix-finding-python2.patch \
@@ -84,10 +89,6 @@ prepare() {
# Note, -mincoming-stack-boundary (and the other flags set) doesn't get used except
# in a test compilation, AFAICT.
# https://github.com/numpy/numpy/pull/20330
apply_patch_with_msg \
1001-BUG-fix-gcc-version-detection-fallback-for-Mingw32CC.patch
cd ..
cp -a ${_realname}-${pkgver} ${_realname}-py-${MSYSTEM}