Subject: libint2: ftbfs with -march=x86-64-v3

From: Matthias Klose <[email-masked]>
Date: Wed, 03 Mar 2021 15:39:13 +0000

Package: src:libint2
Version: 2.6.0-13
Severity: minor
User: [email-masked]
Usertags: ftbfs-x86-64-v3

Starting with LLVM 12 and GCC 11 (and backported to gcc-10 for Debian), 
GCC introduces optimizations for new micro-architecture levels from
the x86-64 psABI.  Filing these bug reports for packages building with
the current level (x86-64), but not with x86-64-v3.

To reproduce these issues, append -march=x86-64-v3 to the compiler
flags (CFLAGS, CXXFLAGS, ...).  You also need hardware supporting these.
The easiest way is to call the dynamic linker in glibc 2.33 like
  /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 --help
Otherwise look at the flags in /proc/cpuinfo and compare these with
those from table 3.1 in the System V Application Binary Interface doc:
https://gitlab.com/x86-psABIs/x86-64-ABI/-/wikis/x86-64-psABI

Please don't upload a package setting these flags by default.  The
x86-64 baseline is still unchanged.

The full build log can be found at:
http://people.debian.org/~doko/logs/20210228/filtered/gcc10-v3/libint2_2.6.0-13_unstable_gcc10-v3.log
The last lines of the build log are at the end of this report.

[...]
  108 |           double QDy = Qy - D[1];
      |                  ^~~
test-eri.cc:109:18: warning: unused variable ‘QDz’ [-Wunused-variable]
  109 |           double QDz = Qz - D[2];
      |                  ^~~
test-eri.cc:156:18: warning: unused variable ‘PQ2’ [-Wunused-variable]
  156 |           double PQ2 = PQx*PQx + PQy*PQy + PQz*PQz;
      |                  ^~~
test-eri.cc: In function ‘bool test_eri_c_f(int&, int&, double*, double*, double*, int&, double*, double*, double*, int&, double*, double*, double*, int&, double*, double*, double*, int&, const double&)’:
test-eri.cc:434:19: warning: comparison of integer expressions of different signedness: ‘int’ and ‘const unsigned int’ [-Wsign-compare]
  434 |     for(int a=0; a<n1; a++) {
      |                  ~^~~
test-eri.cc:435:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘const unsigned int’ [-Wsign-compare]
  435 |       for(int b=0; b<n2; b++) {
      |                    ~^~~
test-eri.cc:436:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘const unsigned int’ [-Wsign-compare]
  436 |         for(int c=0; c<n3; c++) {
      |                      ~^~~
test-eri.cc:437:25: warning: comparison of integer expressions of different signedness: ‘int’ and ‘const unsigned int’ [-Wsign-compare]
  437 |           for(int d=0; d<n4; d++, nel++) {
      |                        ~^~~
In file included from ../tests/eri/prep_libint2.h:26,
                 from test-eri.cc:2:
../include/libint2/boys.h: In instantiation of ‘libint2::FmEval_Chebyshev7<Real>::FmEval_Chebyshev7(int, double) [with Real = double]’:
test-eri.cc:374:51:   required from here
../include/libint2/boys.h:286:18: warning: comparison of integer expressions of different signedness: ‘int’ and ‘const size_t’ {aka ‘const long unsigned int’} [-Wsign-compare]
  286 |         if (mmax > cheb_table_mmax)
      |             ~~~~~^~~~~~~~~~~~~~~~~
/bin/bash   ../libtool --mode=link --tag=CXX      g++ -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security  -g -O2 -Wall -DNDEBUG  -Wl,-z,relro -L../lib -lint2 -lm   -L/usr/lib/gcc/x86_64-linux-gnu/10 -L/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/10/../../.. -lgfortran -lm -lquadmath -o test test.o test-eri.o libint_f.o
libtool: link: g++ -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -Wall -DNDEBUG -Wl,-z -Wl,relro -o .libs/test test.o test-eri.o libint_f.o  -L../lib /<<PKGBUILDDIR>>/sourcedir/lib/.libs/libint2.so -L/usr/lib/gcc/x86_64-linux-gnu/10 -L/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/10/../../.. -lgfortran -lm -lquadmath
./test
Filters: 
Elem 0 di= 0, : C = -3.5142137742932786, Fortran = -3.5142137742932813, abs_error = 2.6645352591003757e-15
Elem 2 di= 0, : C = -0.6329542207797425, Fortran = -0.63295422077974206, abs_error = 4.4408920985006262e-16
Elem 3 di= 0, : C = -4.3153187678579608, Fortran = -4.3153187678579643, abs_error = 3.5527136788005009e-15
Elem 4 di= 0, : C = 0.61124657267633409, Fortran = 0.6112465726763342, abs_error = 1.1102230246251565e-16
Elem 5 di= 0, : C = -6.5220032795273593, Fortran = -6.5220032795273628, abs_error = 3.5527136788005009e-15
Elem 7 di= 0, : C = -0.10973733194857166, Fortran = -0.10973733194857153, abs_error = 1.2490009027033011e-16
Elem 10 di= 0, : C = 0.22036551405284832, Fortran = 0.22036551405284807, abs_error = 2.4980018054066022e-16
Elem 11 di= 0, : C = -9.660859873583842, Fortran = -9.6608598735838385, abs_error = 3.5527136788005009e-15
Elem 12 di= 0, : C = 6.246315769599124, Fortran = 6.2463157695991249, abs_error = 8.8817841970012523e-16
Elem 14 di= 0, : C = -0.25346568240718897, Fortran = -0.2534656824071892, abs_error = 2.2204460492503131e-16
Elem 15 di= 0, : C = 7.059545818381725, Fortran = 7.0595458183817268, abs_error = 1.7763568394002505e-15
Elem 17 di= 0, : C = 8.6681462233342259, Fortran = 8.6681462233342277, abs_error = 1.7763568394002505e-15

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test is a Catch v2.7.1 host application.
Run with -? for options

-------------------------------------------------------------------------------
Fortran ERI
-------------------------------------------------------------------------------
test-eri.cc:480
...............................................................................

test-eri.cc:514: FAILED:
  REQUIRE( test_eri_c_f(contrdepth, am1, c1, alpha1, A, am2, c2, alpha2, B, am3, c3, alpha3, C, am4, c4, alpha4, D, deriv_order, threshold) )
with expansion:
  false

===============================================================================
test cases: 1 | 1 failed
assertions: 1 | 1 failed

make[2]: *** [Makefile:47: check_test] Error 1
make[2]: Leaving directory '/<<PKGBUILDDIR>>/sourcedir/fortran'
make[1]: *** [debian/rules:77: override_dh_auto_test] Error 2
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
make: *** [debian/rules:24: build] Error 2
dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2