Closed mcepl closed 3 years ago
Also, on aarch64 I get this:
[ 62s] C compiler: g++ -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DOPENSSL_LOAD_CONF -fwrapv -fno-semantic-interposition -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -fPIC
[ 62s]
[ 62s] creating build/temp.linux-aarch64-3.8/thewalrus
[ 62s] compile options: '-Ithewalrus -I -I/usr/lib64/python3.8/site-packages/numpy/core/include -I/usr/local/include/eigen3 -I/usr/include/eigen3 -Iinclude -I/usr/lib64/python3.8/site-packages/numpy/core/include -I/usr/include/python3.8 -c'
[ 62s] extra options: '-std=c++11 -O3 -Wall -fPIC -shared -fopenmp -I/usr/lib64/python3.8/site-packages/numpy/core/include'
[ 62s] g++: thewalrus/libwalrus.cpp
[ 62s] In file included from /usr/lib64/python3.8/site-packages/numpy/core/include/numpy/ndarraytypes.h:1822,
[ 62s] from /usr/lib64/python3.8/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
[ 62s] from /usr/lib64/python3.8/site-packages/numpy/core/include/numpy/arrayobject.h:4,
[ 62s] from thewalrus/libwalrus.cpp:675:
[ 62s] /usr/lib64/python3.8/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
[ 62s] 17 | #warning "Using deprecated NumPy API, disable it with " \
[ 62s] | ^~~~~~~
[ 65s] In file included from thewalrus/../include/libwalrus.hpp:21,
[ 65s] from thewalrus/libwalrus.cpp:687:
[ 65s] include/permanent.hpp:25:9: error: ‘__float128’ does not name a type; did you mean ‘_Float128’?
[ 65s] 25 | typedef __float128 qp;
[ 65s] | ^~~~~~~~~~
[ 65s] | _Float128
[ 65s] include/permanent.hpp: In function ‘double libwalrus::permanent_quad(std::vector<double>&)’:
[ 65s] include/permanent.hpp:326:17: error: ‘qp’ was not declared in this scope
[ 65s] 326 | std::vector<qp> matq(mat.begin(), mat.end());
[ 65s] | ^~
[ 65s] include/permanent.hpp:326:19: error: template argument 1 is invalid
[ 65s] 326 | std::vector<qp> matq(mat.begin(), mat.end());
[ 65s] | ^
[ 65s] include/permanent.hpp:326:19: error: template argument 2 is invalid
[ 65s] include/permanent.hpp:326:48: error: expression list treated as compound expression in initializer [-fpermissive]
[ 65s] 326 | std::vector<qp> matq(mat.begin(), mat.end());
[ 65s] | ^
[ 65s] include/permanent.hpp:326:46: error: cannot convert ‘std::vector<double>::iterator’ to ‘int’ in initialization
[ 65s] 326 | std::vector<qp> matq(mat.begin(), mat.end());
[ 65s] | ~~~~~~~^~
[ 65s] | |
[ 65s] | std::vector<double>::iterator
[ 65s] include/permanent.hpp:327:7: error: expected ‘;’ before ‘perm’
[ 65s] 327 | qp perm = permanent(matq);
[ 65s] | ^~~~~
[ 65s] | ;
[ 65s] include/permanent.hpp:328:32: error: ‘perm’ was not declared in this scope
[ 65s] 328 | return static_cast<double>(perm);
[ 65s] | ^~~~
[ 65s] include/permanent.hpp:326:21: warning: unused variable ‘matq’ [-Wunused-variable]
[ 65s] 326 | std::vector<qp> matq(mat.begin(), mat.end());
[ 65s] | ^~~~
[ 66s] In file included from thewalrus/../include/libwalrus.hpp:20,
[ 66s] from thewalrus/libwalrus.cpp:687:
[ 66s] include/torontonian.hpp: In instantiation of ‘double libwalrus::torontonian_fsum(std::vector<T>&) [with T = std::complex<double>]’:
[ 66s] thewalrus/libwalrus.cpp:3874:100: required from here
[ 66s] include/torontonian.hpp:211:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long long unsigned int’ [-Wsign-compare]
[ 66s] 211 | for (int k = 0; k < x; k++) {
[ 66s] | ~~^~~
[ 66s] include/torontonian.hpp: In instantiation of ‘double libwalrus::torontonian_fsum(std::vector<T>&) [with T = double]’:
[ 66s] thewalrus/libwalrus.cpp:4103:84: required from here
[ 66s] include/torontonian.hpp:211:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long long unsigned int’ [-Wsign-compare]
[ 66s] In file included from thewalrus/../include/libwalrus.hpp:22,
[ 66s] from thewalrus/libwalrus.cpp:687:
[ 66s] include/hermite_multidimensional.hpp: In instantiation of ‘T* libwalrus::hermite_multidimensional_cpp(const std::vector<T>&, const std::vector<T>&, const int&) [with T = std::complex<double>]’:
[ 66s] thewalrus/libwalrus.cpp:6330:127: required from here
[ 66s] include/hermite_multidimensional.hpp:105:11: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct std::complex<double>’; use assignment or value-initialization instead [-Wclass-memaccess]
[ 66s] 105 | memset(&H[0],0,sizeof(T)*Hdim);
[ 66s] | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
[ 66s] In file included from include/stdafx.h:19,
[ 66s] from include/eigenvalue_hafnian.hpp:21,
[ 66s] from thewalrus/../include/libwalrus.hpp:16,
[ 66s] from thewalrus/libwalrus.cpp:687:
[ 66s] /usr/include/c++/10/complex:1227:12: note: ‘struct std::complex<double>’ declared here
[ 66s] 1227 | struct complex<double>
[ 66s] | ^~~~~~~~~~~~~~~
[ 66s] In file included from thewalrus/../include/libwalrus.hpp:22,
[ 66s] from thewalrus/libwalrus.cpp:687:
[ 66s] include/hermite_multidimensional.hpp: In instantiation of ‘T* libwalrus::renorm_hermite_multidimensional_cpp(const std::vector<T>&, const std::vector<T>&, const int&) [with T = std::complex<double>]’:
[ 66s] thewalrus/libwalrus.cpp:6812:134: required from here
[ 66s] include/hermite_multidimensional.hpp:162:11: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct std::complex<double>’; use assignment or value-initialization instead [-Wclass-memaccess]
[ 66s] 162 | memset(&H[0],0,sizeof(T)*Hdim);
[ 66s] | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
[ 66s] In file included from include/stdafx.h:19,
[ 66s] from include/eigenvalue_hafnian.hpp:21,
[ 66s] from thewalrus/../include/libwalrus.hpp:16,
[ 66s] from thewalrus/libwalrus.cpp:687:
[ 66s] /usr/include/c++/10/complex:1227:12: note: ‘struct std::complex<double>’ declared here
[ 66s] 1227 | struct complex<double>
[ 66s] | ^~~~~~~~~~~~~~~
[ 66s] In file included from thewalrus/../include/libwalrus.hpp:22,
[ 66s] from thewalrus/libwalrus.cpp:687:
[ 66s] include/hermite_multidimensional.hpp: In instantiation of ‘T* libwalrus::interferometer_cpp(const std::vector<T>&, const int&) [with T = std::complex<double>]’:
[ 66s] thewalrus/libwalrus.cpp:7259:102: required from here
[ 66s] include/hermite_multidimensional.hpp:214:11: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct std::complex<double>’; use assignment or value-initialization instead [-Wclass-memaccess]
[ 66s] 214 | memset(&H[0],0,sizeof(T)*Hdim);
[ 66s] | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
[ 66s] In file included from include/stdafx.h:19,
[ 66s] from include/eigenvalue_hafnian.hpp:21,
[ 66s] from thewalrus/../include/libwalrus.hpp:16,
[ 66s] from thewalrus/libwalrus.cpp:687:
[ 66s] /usr/include/c++/10/complex:1227:12: note: ‘struct std::complex<double>’ declared here
[ 66s] 1227 | struct complex<double>
[ 66s] | ^~~~~~~~~~~~~~~
[ 87s] /usr/lib64/python3.8/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /home/abuild/rpmbuild/BUILD/thewalrus-0.13.0/thewalrus/libwalrus.pyx
[ 87s] tree = Parsing.p_module(s, pxd, full_module_name)
[ 87s] error: Command "g++ -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DOPENSSL_LOAD_CONF -fwrapv -fno-semantic-interposition -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -fPIC -Ithewalrus -I -I/usr/lib64/python3.8/site-packages/numpy/core/include -I/usr/local/include/eigen3 -I/usr/include/eigen3 -Iinclude -I/usr/lib64/python3.8/site-packages/numpy/core/include -I/usr/include/python3.8 -c thewalrus/libwalrus.cpp -o build/temp.linux-aarch64-3.8/thewalrus/libwalrus.o -MMD -MF build/temp.linux-aarch64-3.8/thewalrus/libwalrus.o.d -std=c++11 -O3 -Wall -fPIC -shared -fopenmp -I/usr/lib64/python3.8/site-packages/numpy/core/include" failed with exit status 1
Thanks for the bug report @mcepl! From reading the logs, I can see that the errors are
[ 39s] In file included from thewalrus/../include/libwalrus.hpp:18,
[ 39s] from thewalrus/libwalrus.cpp:691:
[ 39s] include/repeated_hafnian.hpp: In function ‘T libwalrus::hafnian_rpt(std::vector<T>&, std::vector<int>&)’:
[ 39s] include/repeated_hafnian.hpp:124:18: error: there are no arguments to ‘omp_get_num_threads’ that depend on a template parameter, so a declaration of ‘omp_get_num_threads’ must be available [-fpermissive]
[ 39s] 124 | int chunks = omp_get_num_threads();
[ 39s] | ^~~~~~~~~~~~~~~~~~~
[ 39s] include/repeated_hafnian.hpp:124:18: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
[ 39s] include/repeated_hafnian.hpp:125:14: error: there are no arguments to ‘omp_get_thread_num’ that depend on a template parameter, so a declaration of ‘omp_get_thread_num’ must be available [-fpermissive]
and
[ 39s] include/repeated_hafnian.hpp:220:52: error: ‘omp_get_thread_num’ was not declared in this scope
I'm guessing these are from the stricter flags -fstack-protector-strong -fstack-clash-protection -Werror=return-type
?
I'm guessing these are from the stricter flags
-fstack-protector-strong -fstack-clash-protection -Werror=return-type
?
Most likely. Those CFLAGS
I mentioned are the standard for OpenSUSE (and I guess Fedora and other Linux distros have something very similar).
This is caused by line 94 in setup.py
:
CFLAGS = os.environ.get('CFLAGS', cflags_default).split() + ['-I{}'.format(np.get_include())]
This will override all the previously configured flags if the build environment sets the CFLAGS
variable. So in a linux environment, the build failure occurs because the -fopenmp
flag is not appended to the g++
command. I was able to build successfully in Debian 10 with the following environment:
'CFLAGS=-O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -fopenmp'
Thank you, that works as a workaround. I can now build thewalrus even with the standard SUSE CFLAGS.
Also, on aarch64 I get this:
I tried this patch which make the build to succeed:
--- thewalrus-0.13.0.orig/include/permanent.hpp 2020-10-06 14:13:38.061198553 +0200
+++ thewalrus-0.13.0/include/permanent.hpp 2020-10-06 14:13:53.633353500 +0200
@@ -22,7 +22,7 @@ typedef long long int llint;
//typedef long double qp;
#if (defined(__GNUC__) || defined(__GNUG__)) && !(defined(__clang__) || defined(__INTEL_COMPILER))
-typedef __float128 qp;
+typedef _Float128 qp;
//#include <quadmath.h>
#else
typedef long double qp;
But then, it SegFaults on test_real_wrapper
:
[ 104s] ============================= test session starts ==============================
[ 104s] platform linux -- Python 3.8.5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1 -- /usr/bin/python3
[ 104s] cachedir: .pytest_cache
[ 104s] rootdir: /home/abuild/rpmbuild/BUILD/thewalrus-0.13.0
[ 108s] collecting ... collected 2017 items
[ 108s]
[ 112s] thewalrus/tests/test_fock_gradients.py::test_grad_displacement PASSED [ 0%]
[ 114s] thewalrus/tests/test_fock_gradients.py::test_grad_squeezing PASSED [ 0%]
[ 119s] thewalrus/tests/test_fock_gradients.py::test_grad_two_mode_squeezing PASSED [ 0%]
[ 122s] thewalrus/tests/test_fock_gradients.py::test_grad_beamspitter PASSED [ 0%]
[ 122s] thewalrus/tests/test_fock_gradients.py::test_displacement_values PASSED [ 0%]
[ 122s] thewalrus/tests/test_fock_gradients.py::test_squeezing_values PASSED [ 0%]
[ 122s] thewalrus/tests/test_fock_gradients.py::test_BS_selection_rules PASSED [ 0%]
[ 122s] thewalrus/tests/test_fock_gradients.py::test_BS_hong_ou_mandel_interference PASSED [ 0%]
[ 122s] thewalrus/tests/test_fock_gradients.py::test_S2_selection_rules PASSED [ 0%]
[ 122s] thewalrus/tests/test_fock_gradients.py::test_beamsplitter_values PASSED [ 0%]
[ 122s] thewalrus/tests/test_fock_gradients.py::test_two_mode_squeezing_values PASSED [ 0%]
[ 122s] thewalrus/tests/test_hafnian.py::TestReduction::test_reduction[6] PASSED [ 0%]
[ 122s] thewalrus/tests/test_hafnian.py::TestReduction::test_reduction[8] PASSED [ 0%]
[ 122s] thewalrus/tests/test_hafnian.py::TestReduction::test_reduction_vector[6] PASSED [ 0%]
[ 122s] thewalrus/tests/test_hafnian.py::TestReduction::test_reduction_vector[8] PASSED [ 0%]
[ 122s] thewalrus/tests/test_hafnian.py::TestHafnianWrapper::test_version_number PASSED [ 0%]
[ 122s] thewalrus/tests/test_hafnian.py::TestHafnianWrapper::test_array_exception PASSED [ 0%]
[ 122s] thewalrus/tests/test_hafnian.py::TestHafnianWrapper::test_square_exception PASSED [ 0%]
[ 122s] thewalrus/tests/test_hafnian.py::TestHafnianWrapper::test_odd_dim PASSED [ 0%]
[ 122s] thewalrus/tests/test_hafnian.py::TestHafnianWrapper::test_non_symmetric_exception PASSED [ 0%]
[ 122s] thewalrus/tests/test_hafnian.py::TestHafnianWrapper::test_nan PASSED [ 1%]
[ 122s] thewalrus/tests/test_hafnian.py::TestHafnianWrapper::test_empty_matrix PASSED [ 1%]
[ 122s] thewalrus/tests/test_hafnian.py::TestHafnianWrapper::test_real_wrapper Fatal Python error: Fatal Python error: Segmentation fault
[ 122s]
[ 122s] Thread 0x0000ffff87ce7cb0 (most recent call first):
[ 122s] File "/home/abuild/rpmbuild/BUILDROOT/python-thewalrus-0.13.0-8.1.aarch64/usr/lib64/python3.8/site-packages/thewalrus/_hafnian.py", line 171 in hafnian
[ 122s] File "/home/abuild/rpmbuild/BUILD/thewalrus-0.13.0/thewalrus/tests/test_hafnian.py", line 115 in test_real_wrapper
[ 122s] File "/usr/lib/python3.8/site-packages/_pytest/python.py", line 180 in pytest_pyfunc_call
[ 122s] File "/usr/lib/python3.8/site-packages/pluggy/c/var/tmp/rpm-tmp.RqsqE4: line 38: 1936 Segmentation fault PYTHONPATH=${PYTHONPATH:+$PYTHONPATH:}/home/abuild/rpmbuild/BUILDROOT/python-thewalrus-0.13.0-8.1.aarch64/usr/lib64/python3.8/site-packages PYTHONDONTWRITEBYTECODE=1 pytest-3.8 --ignore=_build.python2 --ignore=_build.python3 --ignore=_build.pypy3 -v
[ 122s] error: Bad exit status from /var/tmp/rpm-tmp.RqsqE4 (%check)
Issue description
Description of the issue - include code snippets and screenshots here if relevant. You may use the following template below
Expected behavior: build passes
Actual behavior:
Reproduces how often: always
System information:
export 'CFLAGS=-O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto'
Additional information
Complete build log