From 9614357451c1d7266207fe3c843ceba4db7f12ee Mon Sep 17 00:00:00 2001 From: sergesanspaille Date: Mon, 14 Mar 2022 18:00:40 +0100 Subject: [PATCH] Fix gcc12 build --- 1976.patch | 24 ++++ 1979.patch | 121 ++++++++++++++++++ ...edbb455be8afdfeb6f9e092c5d36b7aa5c63.patch | 32 +++++ ...1440f5ba08ab3bbfb8aa01831904dfd96815.patch | 25 ++++ pythran.spec | 12 +- 5 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 1976.patch create mode 100644 1979.patch create mode 100644 8202edbb455be8afdfeb6f9e092c5d36b7aa5c63.patch create mode 100644 a0571440f5ba08ab3bbfb8aa01831904dfd96815.patch diff --git a/1976.patch b/1976.patch new file mode 100644 index 0000000..d0ed850 --- /dev/null +++ b/1976.patch @@ -0,0 +1,24 @@ +From 343cb724d857fe8adcef071ab088df2c02ba0d4c Mon Sep 17 00:00:00 2001 +From: Jonathan Wakely +Date: Mon, 14 Mar 2022 10:11:00 +0000 +Subject: [PATCH] Add default constructor to string_iterator + +A type must be default constructible to meet the forward iterator requirements. +GCC 12 won't compile `std::reverse_iterator` without +this change. +--- + pythran/pythonic/include/types/str.hpp | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/pythran/pythonic/include/types/str.hpp b/pythran/pythonic/include/types/str.hpp +index 329de1c1d..a0df45905 100644 +--- a/pythran/pythonic/include/types/str.hpp ++++ b/pythran/pythonic/include/types/str.hpp +@@ -231,6 +231,7 @@ namespace types + struct string_iterator : std::iterator { + std::string::const_iterator curr; ++ string_iterator() = default; + string_iterator(std::string::const_iterator iter) : curr(iter) + { + } diff --git a/1979.patch b/1979.patch new file mode 100644 index 0000000..ddd24aa --- /dev/null +++ b/1979.patch @@ -0,0 +1,121 @@ +From e06d2c95bf88f84f9e570eeece5c3408fd8f24fe Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Mon, 14 Mar 2022 16:10:12 +0100 +Subject: [PATCH] Move mult operator for str to the appropriate ns + +--- + pythran/pythonic/include/types/str.hpp | 11 +++-- + pythran/pythonic/types/str.hpp | 64 +++++++++++++------------- + 2 files changed, 38 insertions(+), 37 deletions(-) + +diff --git a/pythran/pythonic/include/types/str.hpp b/pythran/pythonic/include/types/str.hpp +index 329de1c1d..5aa526692 100644 +--- a/pythran/pythonic/include/types/str.hpp ++++ b/pythran/pythonic/include/types/str.hpp +@@ -318,6 +318,12 @@ namespace types + + std::ostream &operator<<(std::ostream &os, chr const &s); + std::ostream &operator<<(std::ostream &os, str const &s); ++ ++ str operator*(str const &s, long n); ++ str operator*(long t, str const &s); ++ str operator*(chr const &s, long n); ++ str operator*(long t, chr const &s); ++ + } + + namespace operator_ +@@ -356,11 +362,6 @@ struct assignable { + }; + PYTHONIC_NS_END + +-pythonic::types::str operator*(pythonic::types::str const &s, long n); +-pythonic::types::str operator*(long t, pythonic::types::str const &s); +-pythonic::types::str operator*(pythonic::types::chr const &s, long n); +-pythonic::types::str operator*(long t, pythonic::types::chr const &s); +- + namespace std + { + template <> +diff --git a/pythran/pythonic/types/str.hpp b/pythran/pythonic/types/str.hpp +index 6e9bc241f..ee540a73b 100644 +--- a/pythran/pythonic/types/str.hpp ++++ b/pythran/pythonic/types/str.hpp +@@ -655,6 +655,38 @@ namespace types + { + return os << s.c_str(); + } ++ ++ str operator*(str const &s, long n) ++ { ++ if (n <= 0) ++ return str(); ++ str other; ++ other.resize(s.size() * n); ++ auto where = other.chars().begin(); ++ for (long i = 0; i < n; i++, where += s.size()) ++ std::copy(s.chars().begin(), s.chars().end(), where); ++ return other; ++ } ++ ++ str operator*(long t, str const &s) ++ { ++ return s * t; ++ } ++ ++ str operator*(chr const &s, long n) ++ { ++ if (n <= 0) ++ return str(); ++ str other; ++ other.resize(n); ++ std::fill(other.chars().begin(), other.chars().end(), s.c); ++ return other; ++ } ++ ++ str operator*(long t, chr const &c) ++ { ++ return c * t; ++ } + } + + namespace operator_ +@@ -686,38 +718,6 @@ namespace operator_ + } + PYTHONIC_NS_END + +-pythonic::types::str operator*(pythonic::types::str const &s, long n) +-{ +- if (n <= 0) +- return pythonic::types::str(); +- pythonic::types::str other; +- other.resize(s.size() * n); +- auto where = other.chars().begin(); +- for (long i = 0; i < n; i++, where += s.size()) +- std::copy(s.chars().begin(), s.chars().end(), where); +- return other; +-} +- +-pythonic::types::str operator*(long t, pythonic::types::str const &s) +-{ +- return s * t; +-} +- +-pythonic::types::str operator*(pythonic::types::chr const &s, long n) +-{ +- if (n <= 0) +- return pythonic::types::str(); +- pythonic::types::str other; +- other.resize(n); +- std::fill(other.chars().begin(), other.chars().end(), s.c); +- return other; +-} +- +-pythonic::types::str operator*(long t, pythonic::types::chr const &c) +-{ +- return c * t; +-} +- + namespace std + { + diff --git a/8202edbb455be8afdfeb6f9e092c5d36b7aa5c63.patch b/8202edbb455be8afdfeb6f9e092c5d36b7aa5c63.patch new file mode 100644 index 0000000..8f5bdeb --- /dev/null +++ b/8202edbb455be8afdfeb6f9e092c5d36b7aa5c63.patch @@ -0,0 +1,32 @@ +From 8202edbb455be8afdfeb6f9e092c5d36b7aa5c63 Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Sat, 1 Jan 2022 13:17:07 +0100 +Subject: [PATCH] Rework numpy logical accumulate to match numpy update + +--- + pythran/tests/test_numpy_ufunc_binary.py | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/pythran/tests/test_numpy_ufunc_binary.py b/pythran/tests/test_numpy_ufunc_binary.py +index 139129ada..3485c0800 100644 +--- a/pythran/tests/test_numpy_ufunc_binary.py ++++ b/pythran/tests/test_numpy_ufunc_binary.py +@@ -31,6 +31,9 @@ class TestNumpyUFuncBinary(TestEnv): + reduced_ufunc = {'add', 'minimum', 'maximum', 'multiply', 'bitwise_or', + 'bitwise_and', 'bitwise_xor'} + ++cmp_ufunc = ('equal', 'greater_equal', 'less_equal', 'not_equal', 'greater', ++ 'less') ++ + for ns, f in binary_ufunc: + if 'bitwise_' in f or 'ldexp' in f or '_shift' in f : + setattr(TestNumpyUFuncBinary, 'test_' + f, eval("lambda self: self.run_test('def np_{0}(a): from {1} import {0} ; return {0}(a,a)', numpy.ones(10, numpy.int32), np_{0}=[NDArray[numpy.int32,:]])".format(f, ns))) +@@ -78,7 +81,7 @@ class TestNumpyUFuncBinary(TestEnv): + pass + + ## Tests for accumulation +- if 'scipy' not in ns: ++ if 'scipy' not in ns and f not in cmp_ufunc: + setattr(TestNumpyUFuncBinary, 'test_accumulate_' + f, eval("lambda self: self.run_test('def np_{0}_accumulate(a): from {1} import {0} ; return {0}.accumulate(a)', numpy.ones(10), np_{0}_accumulate=[NDArray[float,:]])".format(f, ns))) + setattr(TestNumpyUFuncBinary, 'test_accumulate_' + f + '_matrix', eval("lambda self: self.run_test('def np_{0}_matrix_accumulate(a): from {1} import {0} ; return {0}.accumulate(a)', numpy.ones((2,5)) - 0.2 , np_{0}_matrix_accumulate=[NDArray[float, :, :]])".format(f, ns))) + ## Tests for reduction diff --git a/a0571440f5ba08ab3bbfb8aa01831904dfd96815.patch b/a0571440f5ba08ab3bbfb8aa01831904dfd96815.patch new file mode 100644 index 0000000..f74356d --- /dev/null +++ b/a0571440f5ba08ab3bbfb8aa01831904dfd96815.patch @@ -0,0 +1,25 @@ +From a0571440f5ba08ab3bbfb8aa01831904dfd96815 Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Sat, 1 Jan 2022 10:02:43 +0100 +Subject: [PATCH] Numpy no longer supports floordiv on complex for python 3.10 + +--- + pythran/tests/test_complex.py | 5 ----- + 1 file changed, 5 deletions(-) + +diff --git a/pythran/tests/test_complex.py b/pythran/tests/test_complex.py +index f835ff3760..22a60afc29 100644 +--- a/pythran/tests/test_complex.py ++++ b/pythran/tests/test_complex.py +@@ -60,11 +60,6 @@ def test_complex_array_abs(self): + np.array([[3 + 2j]]), + test_complex_array_abs=[NDArray[complex, :, :]]) + +- def test_complex_floordiv(self): +- self.run_test('def complex_floordiv(x): import numpy as np; return np.floor_divide(x, 2 + 2j)', +- 3.5 - 3.5j, +- complex_floordiv=[complex]) +- + def test_complex_array_sqr(self): + self.run_test('def test_complex_array_sqr(a): return a ** 2', + np.array([[3 + 2j]]), diff --git a/pythran.spec b/pythran.spec index 7a8d0f1..fb5a860 100644 --- a/pythran.spec +++ b/pythran.spec @@ -1,6 +1,6 @@ Name: pythran Version: 0.11.0 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Ahead of Time Python compiler for numeric kernels # pythran is BSD @@ -50,6 +50,12 @@ Requires: python3-devel Requires: boost-devel Requires: xsimd-devel >= 8 +# Upstream fixes for GCC 12 +Patch: https://github.com/serge-sans-paille/pythran/pull/1976.patch +Patch: https://github.com/serge-sans-paille/pythran/pull/1979.patch +Patch: https://github.com/serge-sans-paille/pythran/commit/a0571440f5ba08ab3bbfb8aa01831904dfd96815.patch +Patch: https://github.com/serge-sans-paille/pythran/commit/8202edbb455be8afdfeb6f9e092c5d36b7aa5c63.patch + %description Pythran is an ahead of time compiler for a subset of the Python language, with a focus on scientific computing. It takes a Python module annotated with a few @@ -125,6 +131,10 @@ k="$k and not test_setup_bdist_install3" %changelog +* Mon Mar 14 2022 Serge Guelton - 0.11.0-3 +- Fix gcc12 build +- Fixes: rhbz#2046923 + * Fri Jan 21 2022 Fedora Release Engineering - 0.11.0-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild