Skip to content

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

Open

Description

@orlitzky

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.

Activity

  1. isuruf commented on Jul 6, 2023

    @isuruf
    Contributor

    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?

  2. martin-frbg commented on Jul 7, 2023

    @martin-frbg
    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.

  3. martin-frbg commented on Jul 7, 2023

    @martin-frbg
    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).

  4. orlitzky commented on Jul 7, 2023

    @orlitzky
    Author

    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.

  5. martin-frbg commented on Jul 8, 2023

    @martin-frbg
    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)

  6. martin-frbg commented on Jul 8, 2023

    @martin-frbg
    Collaborator

    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...

  7. martin-frbg commented on Jul 8, 2023

    @martin-frbg
    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

  8. martin-frbg commented on Jul 9, 2023

    @martin-frbg
    Collaborator

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

  9. orlitzky commented on Jul 9, 2023

    @orlitzky
    Author

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

  10. martin-frbg commented on Jul 9, 2023

    @martin-frbg
    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.

  11. martin-frbg commented on Jul 11, 2023

    @martin-frbg
    Collaborator

    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)

  12. kloczek commented on Nov 15, 2023

    @kloczek

    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.

  13. foxtran commented on Jun 25, 2025

    @foxtran
    Contributor

    There is an example fix one of LTO issues:

    diff --git a/ctest/c_c2chke.c b/ctest/c_c2chke.c
    index eb5b99008..7ebab588c 100644
    --- a/ctest/c_c2chke.c
    +++ b/ctest/c_c2chke.c
    @@ -24,7 +24,7 @@ void chkxer(void) {
        cblas_lerr = 1 ;
     }
    
    -void F77_c2chke(char *rout) {
    +void F77_c2chke(char *rout, size_t len) {
        char *sf = ( rout ) ;
        float  A[2] = {0.0,0.0},
               X[2] = {0.0,0.0},

    One just need to make it with each routine which gets Fortran string(s) for GCC Fortran ABI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions