Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure with -Werror=lto-type-mismatch (LTO) #4128

Open
orlitzky opened this issue Jul 6, 2023 · 12 comments
Open

Build failure with -Werror=lto-type-mismatch (LTO) #4128

orlitzky opened this issue Jul 6, 2023 · 12 comments

Comments

@orlitzky
Copy link

orlitzky commented Jul 6, 2023

This was reported on Gentoo at https://bugs.gentoo.org/878987, and I've verified that it still happens with the latest v0.3.23.

The -Wlto-type-mismatch flag warns about type mismatches in global declarations from different compilation units. The "lto" part is because those mismatches are dangerous in the presence of LTO, and the warnings are enabled by default with -flto. Adding -Werror=lto-type-mismatch moreover turns them into errors, so that said code cannot sneak into an LTO build. To reproduce, set CFLAGS="-flto -Werror=lto-type-mismatch" and build OpenBLAS.

For background, on Gentoo, users are likely to set CFLAGS="-flto" globally and then add CFLAGS+=" -Werror=lto-type-mismatch" as a safety net against miscompiled packages. On such a machine OpenBLAS will fail to build. As one of the maintainers, I could disable LTO wholesale, but of course it would be preferable (if not to difficult) to just fix the mismatches.

@isuruf
Copy link
Contributor

isuruf commented Jul 6, 2023

Most of those errors are when calling the Fortran function directly from C and the return type is expected to be long int whereas the C external function declaration uses void. Is long int the expected return type of a Fortran subroutine when interfacing from C?

@martin-frbg
Copy link
Collaborator

I'd expect them to be void (there is nowhere a return value from a subroutine could come from), AFAIK only some (all?) of the reimplemented LAPACK functions in OpenBLAS are returning (long) int for no specific reasons (other than so far it did not hurt), probably since the time of GotoBLAS.

@martin-frbg
Copy link
Collaborator

Now that I had a chance to look at the build log, it appears to be only the linktest.c that is causing the errors - this is a very simple test file meant to check that all the expected symbols are actually present in the library, and as such it only contains dummy function calls with empty parameter lists (and no type specifiers, causing the compiler to default them to int). The simplest solution would be to suppress any lto type checks on that specific file (or in the exports directory in general).

@orlitzky
Copy link
Author

orlitzky commented Jul 7, 2023

Now that I had a chance to look at the build log, it appears to be only the linktest.c that is causing the errors

I think that's just the first set of errors to arise. If I edit linktest out of exports/Makefile in a git checkout, this is what I eventually hit:

cc -O2 -pipe -march=native -O0 -flto -Werror=lto-type-mismatch   -DMAX_STACK_ALLOC=2048 -Wall -m64 -DF_INTERFACE_GFORT -fPIC -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=4 -DMAX_PARALLEL_NUMBER=1 -DBUILD_SINGLE=1 -DBUILD_DOUBLE=1 -DBUILD_COMPLEX=1 -DBUILD_COMPLEX16=1 -DVERSION=\"0.3.23.dev\" -msse3 -UASMNAME -UASMFNAME -UNAME -UCNAME -UCHAR_NAME -UCHAR_CNAME -DASMNAME= -DASMFNAME=_ -DNAME=_ -DCNAME= -DCHAR_NAME=\"_\" -DCHAR_CNAME=\"\" -DNO_AFFINITY -I.   -DSMALL_MATRIX_OPT -DMAX_STACK_ALLOC=2048 -Wall -m64 -DF_INTERFACE_GFORT -fPIC -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=4 -DMAX_PARALLEL_NUMBER=1 -DBUILD_SINGLE=1 -DBUILD_DOUBLE=1 -DBUILD_COMPLEX=1 -DBUILD_COMPLEX16=1 -DVERSION=\"0.3.23.dev\" -msse3 -UASMNAME -UASMFNAME -UNAME -UCNAME -UCHAR_NAME -UCHAR_CNAME -DASMNAME= -DASMFNAME=_ -DNAME=_ -DCNAME= -DCHAR_NAME=\"_\" -DCHAR_CNAME=\"\" -DNO_AFFINITY -I.. -Wl,-O1 -Wl,--as-needed -shared -o ../libopenblas_barcelonap-r0.3.23.dev.so \
-Wl,--whole-archive ../libopenblas_barcelonap-r0.3.23.dev.a -Wl,--no-whole-archive \
-Wl,-soname,libopenblas.so.0 -lm -lpthread -lgfortran -lm -lpthread -lgfortran
../lapack-netlib/LAPACKE/src/../include/lapack.h:17723:6: error: type of 'zsyr_' does not match original declaration [-Werror=lto-type-mismatch]
17723 | void LAPACK_zsyr_base(
      |      ^
../interface/zsyr.c:79:6: note: type mismatch in parameter 8
   79 | void NAME(char *UPLO, blasint *N, FLOAT  *ALPHA,
      |      ^
../interface/zsyr.c:79:6: note: type 'void' should match type 'size_t'
../interface/zsyr.c:79:6: note: 'zsyr_' was previously declared here
../interface/zsyr.c:79:6: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:22351:12: error: type of 'ztrtrs_' does not match original declaration [-Werror=lto-type-mismatch]
22351 | lapack_int LAPACK_ztrtrs_base(
      |            ^
../interface/lapack/ztrtrs.c:63:5: note: type mismatch in parameter 11
   63 | int NAME(char *UPLO, char* TRANS, char* DIAG, blasint *N, blasint *NRHS, FLOAT *a, blasint *ldA,
      |     ^
../interface/lapack/ztrtrs.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/ztrtrs.c:63:5: note: 'ztrtrs_' was previously declared here
../interface/lapack/ztrtrs.c:63:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:22284:12: error: type of 'ztrtri_' does not match original declaration [-Werror=lto-type-mismatch]
22284 | lapack_int LAPACK_ztrtri_base(
      |            ^
../interface/lapack/ztrtri.c:63:5: note: type mismatch in parameter 7
   63 | int NAME(char *UPLO, char *DIAG, blasint *N, FLOAT *a, blasint *ldA, blasint *Info){
      |     ^
../interface/lapack/ztrtri.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/ztrtri.c:63:5: note: 'ztrtri_' was previously declared here
../interface/lapack/ztrtri.c:63:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:11237:12: error: type of 'zlauum_' does not match original declaration [-Werror=lto-type-mismatch]
11237 | lapack_int LAPACK_zlauum_base(
      |            ^
../interface/lapack/zlauum.c:63:5: note: type mismatch in parameter 6
   63 | int NAME(char *UPLO, blasint *N, FLOAT *a, blasint *ldA, blasint *Info){
      |     ^
../interface/lapack/zlauum.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/zlauum.c:63:5: note: 'zlauum_' was previously declared here
../interface/lapack/zlauum.c:63:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:3480:12: error: type of 'zgesv_' does not match original declaration [-Werror=lto-type-mismatch]
 3480 | lapack_int LAPACK_zgesv(
      |            ^
../interface/lapack/gesv.c:63:5: note: 'zgesv_' was previously declared here
   63 | int NAME(blasint *N, blasint *NRHS, FLOAT *a, blasint *ldA, blasint *ipiv,
      |     ^
../interface/lapack/gesv.c:63:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:11096:12: error: type of 'zlaswp_' does not match original declaration [-Werror=lto-type-mismatch]
11096 | lapack_int LAPACK_zlaswp(
      |            ^
../interface/lapack/zlaswp.c:55:5: note: 'zlaswp_' was previously declared here
   55 | int NAME(blasint *N, FLOAT *a, blasint *LDA, blasint *K1, blasint *K2, blasint *ipiv, blasint *INCX){
      |     ^
../interface/lapack/zlaswp.c:55:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:4097:12: error: type of 'zgetf2_' does not match original declaration [-Werror=lto-type-mismatch]
 4097 | lapack_int LAPACK_zgetf2(
      |            ^
../interface/lapack/zgetf2.c:53:5: note: 'zgetf2_' was previously declared here
   53 | int NAME(blasint *M, blasint *N, FLOAT *a, blasint *ldA, blasint *ipiv, blasint *Info){
      |     ^
../interface/lapack/zgetf2.c:53:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:13578:12: error: type of 'zpotrf_' does not match original declaration [-Werror=lto-type-mismatch]
13578 | lapack_int LAPACK_zpotrf_base(
      |            ^
../interface/lapack/zpotrf.c:63:5: note: type mismatch in parameter 6
   63 | int NAME(char *UPLO, blasint *N, FLOAT *a, blasint *ldA, blasint *Info){
      |     ^
../interface/lapack/zpotrf.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/zpotrf.c:63:5: note: 'zpotrf_' was previously declared here
../interface/lapack/zpotrf.c:63:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:4230:12: error: type of 'zgetrs_' does not match original declaration [-Werror=lto-type-mismatch]
 4230 | lapack_int LAPACK_zgetrs_base(
      |            ^
../interface/lapack/zgetrs.c:63:5: note: type mismatch in parameter 10
   63 | int NAME(char *TRANS, blasint *N, blasint *NRHS, FLOAT *a, blasint *ldA,
      |     ^
../interface/lapack/zgetrs.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/zgetrs.c:63:5: note: 'zgetrs_' was previously declared here
../interface/lapack/zgetrs.c:63:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:4121:12: error: type of 'zgetrf_' does not match original declaration [-Werror=lto-type-mismatch]
 4121 | lapack_int LAPACK_zgetrf(
      |            ^
../interface/lapack/zgetrf.c:53:5: note: 'zgetrf_' was previously declared here
   53 | int NAME(blasint *M, blasint *N, FLOAT *a, blasint *ldA, blasint *ipiv, blasint *Info){
      |     ^
../interface/lapack/zgetrf.c:53:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:17706:6: error: type of 'csyr_' does not match original declaration [-Werror=lto-type-mismatch]
17706 | void LAPACK_csyr_base(
      |      ^
../interface/zsyr.c:79:6: note: type mismatch in parameter 8
   79 | void NAME(char *UPLO, blasint *N, FLOAT  *ALPHA,
      |      ^
../interface/zsyr.c:79:6: note: type 'void' should match type 'size_t'
../interface/zsyr.c:79:6: note: 'csyr_' was previously declared here
../interface/zsyr.c:79:6: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:22300:12: error: type of 'ctrtrs_' does not match original declaration [-Werror=lto-type-mismatch]
22300 | lapack_int LAPACK_ctrtrs_base(
      |            ^
../interface/lapack/ztrtrs.c:63:5: note: type mismatch in parameter 11
   63 | int NAME(char *UPLO, char* TRANS, char* DIAG, blasint *N, blasint *NRHS, FLOAT *a, blasint *ldA,
      |     ^
../interface/lapack/ztrtrs.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/ztrtrs.c:63:5: note: 'ctrtrs_' was previously declared here
../interface/lapack/ztrtrs.c:63:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:22236:12: error: type of 'ctrtri_' does not match original declaration [-Werror=lto-type-mismatch]
22236 | lapack_int LAPACK_ctrtri_base(
      |            ^
../interface/lapack/ztrtri.c:63:5: note: type mismatch in parameter 7
   63 | int NAME(char *UPLO, char *DIAG, blasint *N, FLOAT *a, blasint *ldA, blasint *Info){
      |     ^
../interface/lapack/ztrtri.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/ztrtri.c:63:5: note: 'ctrtri_' was previously declared here
../interface/lapack/ztrtri.c:63:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:11189:12: error: type of 'clauum_' does not match original declaration [-Werror=lto-type-mismatch]
11189 | lapack_int LAPACK_clauum_base(
      |            ^
../interface/lapack/zlauum.c:63:5: note: type mismatch in parameter 6
   63 | int NAME(char *UPLO, blasint *N, FLOAT *a, blasint *ldA, blasint *Info){
      |     ^
../interface/lapack/zlauum.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/zlauum.c:63:5: note: 'clauum_' was previously declared here
../interface/lapack/zlauum.c:63:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:3459:12: error: type of 'cgesv_' does not match original declaration [-Werror=lto-type-mismatch]
 3459 | lapack_int LAPACK_cgesv(
      |            ^
../interface/lapack/gesv.c:63:5: note: 'cgesv_' was previously declared here
   63 | int NAME(blasint *N, blasint *NRHS, FLOAT *a, blasint *ldA, blasint *ipiv,
      |     ^
../interface/lapack/gesv.c:63:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:11081:12: error: type of 'claswp_' does not match original declaration [-Werror=lto-type-mismatch]
11081 | lapack_int LAPACK_claswp(
      |            ^
../interface/lapack/zlaswp.c:55:5: note: 'claswp_' was previously declared here
   55 | int NAME(blasint *N, FLOAT *a, blasint *LDA, blasint *K1, blasint *K2, blasint *ipiv, blasint *INCX){
      |     ^
../interface/lapack/zlaswp.c:55:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:4079:12: error: type of 'cgetf2_' does not match original declaration [-Werror=lto-type-mismatch]
 4079 | lapack_int LAPACK_cgetf2(
      |            ^
../interface/lapack/zgetf2.c:53:5: note: 'cgetf2_' was previously declared here
   53 | int NAME(blasint *M, blasint *N, FLOAT *a, blasint *ldA, blasint *ipiv, blasint *Info){
      |     ^
../interface/lapack/zgetf2.c:53:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:13530:12: error: type of 'cpotrf_' does not match original declaration [-Werror=lto-type-mismatch]
13530 | lapack_int LAPACK_cpotrf_base(
      |            ^
../interface/lapack/zpotrf.c:63:5: note: type mismatch in parameter 6
   63 | int NAME(char *UPLO, blasint *N, FLOAT *a, blasint *ldA, blasint *Info){
      |     ^
../interface/lapack/zpotrf.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/zpotrf.c:63:5: note: 'cpotrf_' was previously declared here
../interface/lapack/zpotrf.c:63:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:4179:12: error: type of 'cgetrs_' does not match original declaration [-Werror=lto-type-mismatch]
 4179 | lapack_int LAPACK_cgetrs_base(
      |            ^
../interface/lapack/zgetrs.c:63:5: note: type mismatch in parameter 10
   63 | int NAME(char *TRANS, blasint *N, blasint *NRHS, FLOAT *a, blasint *ldA,
      |     ^
../interface/lapack/zgetrs.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/zgetrs.c:63:5: note: 'cgetrs_' was previously declared here
../interface/lapack/zgetrs.c:63:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:4103:12: error: type of 'cgetrf_' does not match original declaration [-Werror=lto-type-mismatch]
 4103 | lapack_int LAPACK_cgetrf(
      |            ^
../interface/lapack/zgetrf.c:53:5: note: 'cgetrf_' was previously declared here
   53 | int NAME(blasint *M, blasint *N, FLOAT *a, blasint *ldA, blasint *ipiv, blasint *Info){
      |     ^
../interface/lapack/zgetrf.c:53:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../lapack-netlib/LAPACKE/src/../include/lapack.h:22317:12: error: type of 'dtrtrs_' does not match original declaration [-Werror=lto-type-mismatch]
22317 | lapack_int LAPACK_dtrtrs_base(
      |            ^
../interface/lapack/trtrs.c:63:5: note: type mismatch in parameter 11
   63 | int NAME(char *UPLO, char* TRANS, char* DIAG, blasint *N, blasint *NRHS, FLOAT *a, blasint *ldA,
      |     ^
../interface/lapack/trtrs.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/trtrs.c:63:5: note: 'dtrtrs_' was previously declared here
../lapack-netlib/LAPACKE/src/../include/lapack.h:22252:12: error: type of 'dtrtri_' does not match original declaration [-Werror=lto-type-mismatch]
22252 | lapack_int LAPACK_dtrtri_base(
      |            ^
../interface/lapack/trtri.c:64:5: note: type mismatch in parameter 7
   64 | int NAME(char *UPLO, char *DIAG, blasint *N, FLOAT *a, blasint *ldA, blasint *Info){
      |     ^
../interface/lapack/trtri.c:64:5: note: type 'void' should match type 'size_t'
../interface/lapack/trtri.c:64:5: note: 'dtrtri_' was previously declared here
../lapack-netlib/LAPACKE/src/../include/lapack.h:11205:12: error: type of 'dlauum_' does not match original declaration [-Werror=lto-type-mismatch]
11205 | lapack_int LAPACK_dlauum_base(
      |            ^
../interface/lapack/lauum.c:63:5: note: type mismatch in parameter 6
   63 | int NAME(char *UPLO, blasint *N, FLOAT *a, blasint *ldA, blasint *Info){
      |     ^
../interface/lapack/lauum.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/lauum.c:63:5: note: 'dlauum_' was previously declared here
../lapack-netlib/LAPACKE/src/../include/lapack.h:13546:12: error: type of 'dpotrf_' does not match original declaration [-Werror=lto-type-mismatch]
13546 | lapack_int LAPACK_dpotrf_base(
      |            ^
../interface/lapack/potrf.c:63:5: note: type mismatch in parameter 6
   63 | int NAME(char *UPLO, blasint *N, FLOAT *a, blasint *ldA, blasint *Info){
      |     ^
../interface/lapack/potrf.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/potrf.c:63:5: note: 'dpotrf_' was previously declared here
../lapack-netlib/LAPACKE/src/../include/lapack.h:4196:12: error: type of 'dgetrs_' does not match original declaration [-Werror=lto-type-mismatch]
 4196 | lapack_int LAPACK_dgetrs_base(
      |            ^
../interface/lapack/getrs.c:63:5: note: type mismatch in parameter 10
   63 | int NAME(char *TRANS, blasint *N, blasint *NRHS, FLOAT *a, blasint *ldA,
      |     ^
../interface/lapack/getrs.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/getrs.c:63:5: note: 'dgetrs_' was previously declared here
../lapack-netlib/LAPACKE/src/../include/lapack.h:22334:12: error: type of 'strtrs_' does not match original declaration [-Werror=lto-type-mismatch]
22334 | lapack_int LAPACK_strtrs_base(
      |            ^
../interface/lapack/trtrs.c:63:5: note: type mismatch in parameter 11
   63 | int NAME(char *UPLO, char* TRANS, char* DIAG, blasint *N, blasint *NRHS, FLOAT *a, blasint *ldA,
      |     ^
../interface/lapack/trtrs.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/trtrs.c:63:5: note: 'strtrs_' was previously declared here
../lapack-netlib/LAPACKE/src/../include/lapack.h:22268:12: error: type of 'strtri_' does not match original declaration [-Werror=lto-type-mismatch]
22268 | lapack_int LAPACK_strtri_base(
      |            ^
../interface/lapack/trtri.c:64:5: note: type mismatch in parameter 7
   64 | int NAME(char *UPLO, char *DIAG, blasint *N, FLOAT *a, blasint *ldA, blasint *Info){
      |     ^
../interface/lapack/trtri.c:64:5: note: type 'void' should match type 'size_t'
../interface/lapack/trtri.c:64:5: note: 'strtri_' was previously declared here
../lapack-netlib/LAPACKE/src/../include/lapack.h:11221:12: error: type of 'slauum_' does not match original declaration [-Werror=lto-type-mismatch]
11221 | lapack_int LAPACK_slauum_base(
      |            ^
../interface/lapack/lauum.c:63:5: note: type mismatch in parameter 6
   63 | int NAME(char *UPLO, blasint *N, FLOAT *a, blasint *ldA, blasint *Info){
      |     ^
../interface/lapack/lauum.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/lauum.c:63:5: note: 'slauum_' was previously declared here
../lapack-netlib/LAPACKE/src/../include/lapack.h:13562:12: error: type of 'spotrf_' does not match original declaration [-Werror=lto-type-mismatch]
13562 | lapack_int LAPACK_spotrf_base(
      |            ^
../interface/lapack/potrf.c:63:5: note: type mismatch in parameter 6
   63 | int NAME(char *UPLO, blasint *N, FLOAT *a, blasint *ldA, blasint *Info){
      |     ^
../interface/lapack/potrf.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/potrf.c:63:5: note: 'spotrf_' was previously declared here
../lapack-netlib/LAPACKE/src/../include/lapack.h:4213:12: error: type of 'sgetrs_' does not match original declaration [-Werror=lto-type-mismatch]
 4213 | lapack_int LAPACK_sgetrs_base(
      |            ^
../interface/lapack/getrs.c:63:5: note: type mismatch in parameter 10
   63 | int NAME(char *TRANS, blasint *N, blasint *NRHS, FLOAT *a, blasint *ldA,
      |     ^
../interface/lapack/getrs.c:63:5: note: type 'void' should match type 'size_t'
../interface/lapack/getrs.c:63:5: note: 'sgetrs_' was previously declared here
lto1: some warnings being treated as errors
lto-wrapper: fatal error: cc returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:195: ../libopenblas_barcelonap-r0.3.23.dev.so] Error 1
make[1]: Leaving directory '/home/mjo/src/OpenBLAS/exports'
make: *** [Makefile:132: shared] Error 2

It looks like you've already tried to account for the extra FORTRAN_STRLEN parameter, so I'm not sure yet exactly what the problem is.

@martin-frbg
Copy link
Collaborator

Where it complains about size_t it is almost certainly referring to those hidden LEN arguments. But at least some of that is inside original Reference-LAPACK Fortran code and I do not see how to apply a C size_t there (unless gfortran actually uses something smaller than a size_t internally, or it is the LTO checker itself not realizing the equivalence)

@martin-frbg
Copy link
Collaborator

martin-frbg commented Jul 8, 2023

Pretty messy - older gfortran (7.5) appears to use unsigned int for the hidden arguments, newer (11.3 at least) unsigned long and in both cases the first case the size_t in lapack.h is seen as a mismatch. Then there are some recent additions to Reference-LAPACK where the entry in lapack.h fails to account for those newfangled arguments at all...

@martin-frbg
Copy link
Collaborator

the LAPACKE interfaces for the recently added ?gedmg/?gedmdq functions from reference-lapack turn out to be completely bogus, probably based on an earlier draft. I'm working on a PR.
Also LTO mismatch errors are a known problem with LAPACK
Reference-LAPACK/lapack#334

@martin-frbg
Copy link
Collaborator

created Reference-LAPACK/lapack#879 to track this in Reference-LAPACK

@orlitzky
Copy link
Author

orlitzky commented Jul 9, 2023

Ugh, thank you. I didn't mean to cause this much trouble.

@martin-frbg
Copy link
Collaborator

Well, the ?GEDMD interface problem was a good if accidental catch. I'm still unsure how much of gcc's other complaints are actually warranted - gcc13 (built from source) seems to have problems equating size_t with "long int" again, where it looked like gcc11 made that connection alright. (lots of "type long int should match type size_t"). Then there are other instances where gcc just complains that some function "does not match original declaration" without being more specific. I think this is caused by additional layers of typedefs like GFORTRAN_DOUBLE_COMPLEX and lapack_complex_double that evaluate to the exact same construct but are not getting evaluated in time. At least the existing prototypes look correct and match the output of gfortran -fc-prototypes-external for the respective source file.

@martin-frbg
Copy link
Collaborator

martin-frbg commented Jul 11, 2023

No errors or warnings with the Intel oneAPI compiler and -flto (needs setting AR, LD and RANLIB to the llvm-ar etc. that come with oneAPI for linking to work), but I do not think it has a specific warning option like gcc has (and nor does LLVM)

@kloczek
Copy link

kloczek commented Nov 15, 2023

Just FTR: in #4318 are attached two sets of warnings + stats for c lapack nad fortran lapack produced using gcc 13.2.1 against OpenBLAS 0.3.25.
Amongst those warnings are two most important LTO and strict aliasing warnings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants