Skip to content

Issues still existing in new SET_*_XERBLA functionality #1477

Open

Description

@mohawk2

Originally posted by @ACSimon33 in #1407 (review):

There are a few smaller issues but they could be handled in follow-up PRs. This is the list of smaller issues and nits that I found:

  • the FCHAR change breaks some callers. Making FCHAR const char * changes every installed F77_* prototype in cblas_f77.h, so code that declares them with char * no longer compiles. Release notes could cover it, or the change can be limited to the callback typedef.
  • libblas and libcblas both define strong set_blas_xerbla_/get_blas_xerbla_, so a static -lblas -lcblas -lblas link fails with “multiple definition”. (Could be fixed with weak symbols as with the other symbols; the cblas_xerbla could become a strong symbol now on the other hand)
  • The callback typedef is defined in both cblas.h and cblas_f77.h. That costs 334 -Wpedantic warnings per build and is a hard error in F77_CHAR (Cray) builds.

Activity

  1. mohawk2 commented on Nov 4, 2026

    @mohawk2
    ContributorAuthor

    As I noted on that issue:

    Regarding the strong set_blas_xerbla, that won't hit Debian because they remove the Fortran xerbla.o (which can't be weakened at least on some compilers) for their combined library. I do intend to make the CMake able to implement that "natively" which I'll also track [here].

  2. ACSimon33 commented on Nov 4, 2026

    @ACSimon33
    Collaborator

    Thanks for creating the issue. I'm already working on the follow-up PR. Regarding the strong set_blas_xerbla, the issue is that users who use two separate static libraries for blas and cblas are affected, regardless of what Debian does. That's why I think it is necessary to add.

  3. ACSimon33 commented on Nov 4, 2026

    @ACSimon33
    Collaborator

    Another issue is that NAG Fortran builds now fail. I forgot to test those before merging:

    [6609/28493] Building Fortran object BLAS/SRC/CMakeFiles/blas_obj.dir/xerbla_blas.f90.o
    FAILED: [code=2] BLAS/SRC/CMakeFiles/blas_obj.dir/xerbla_blas.f90.o BLAS/SRC/xerbla_blas.mod 
    /usr/local/bin/nagfor -I/home/runner/work/lapack/lapack/BLAS/SRC -O2 -DNDEBUG -mdir BLAS/SRC -IBLAS/SRC -PIC -ieee=full -dcfuns -thread_safe -recursive -w=obs -w=x77 -w=ques -w=unused -quiet -c BLAS/SRC/CMakeFiles/blas_obj.dir/xerbla_blas.f90-pp.f90 -o BLAS/SRC/CMakeFiles/blas_obj.dir/xerbla_blas.f90.o
    Error: /home/runner/work/lapack/lapack/BLAS/SRC/xerbla_blas.f90, line 116: Pointer assignment to ACTIVE_CALLBACK in thread-safe procedure SET_BLAS_XERBLA
    

    I'll fix that in the follow-up as well.

  4. mohawk2 commented on Nov 5, 2026

    @mohawk2
    ContributorAuthor

    3. Thanks for creating the issue. I'm already working on the follow-up PR. Regarding the strong set_blas_xerbla, the issue is that users who use two separate static libraries for blas and cblas are affected, regardless of what Debian does. That's why I think it is necessary to add.

    I didn't know that multiple definitions of a symbol in a building situation is actually an error, thank you. I don't like the idea of weakening the C implementation, because it's the Fortran one I believe "should" be weak. I do think this proves it is beneficial to promote what Debian does with its ar stuff to combine the libraries into fully-available functionality here, that can be tested with CI.

  5. mohawk2 commented on Nov 5, 2026

    @mohawk2
    ContributorAuthor

    I'm actually wondering now how well in practice the CBLAS replacement of XERBLA worked in calling into cblas_xerbla when CBLAS_CallFromC, since for any real work, a program would need to link in BLAS, and its Fortran XERBLA (or the application's own one) would "win".

    If it's truly necessary to weaken the CBLAS implementations of {SET,GET}_BLAS_XERBLA, let me know and I'll do it, unless you're already on it :-)

  6. ACSimon33 commented on Nov 5, 2026

    @ACSimon33
    Collaborator

    A few notes:

    • Weak doesn't make the linker go looking for a strong definition. Once CBLAS's weak xerbla_ is in the link, it satisfies dgemm_'s reference, and libblas's xerbla.o is never extracted. So, with CBLAS first, BLAS does not override it. It only matters when both definitions end up in the same static link: the strong one then wins silently instead of causing a "multiple definition" error.
    • Weak is ignored by dynamic linking. On ELF, ld.so takes the first definition in lookup order.

    So my guess is it worked at least on Linux. I'll do some more experiments on other platforms and configurations.

  7. mohawk2 commented on Nov 16, 2026

    @mohawk2
    ContributorAuthor

    @ACSimon33 I look forward to seeing the results of your experiments! Please also let me know if you need anything from me in re const pointers, I can tell you've been busy lately.

    I've been pondering LAPACKE_set_xerbla, and I'm starting to think that we should adjust it so that routines passed in would actually be compatible with cblas_xerbla replacements (i.e. taking a va_list). The main LAPACKE_xerbla would then not need changing for existing code, but if called with one of its magic values and there was an override, it could do slightly fancier behaviour.

    That would also allow changing the main LAPACKE calls to it to be a bit more CBLAS-like, though given its interface in documented in https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-c/2026-0/lapacke-xerbla.html that might limit the options, and it might be best to just make the more powerful function only available with LAPACKE_set_xerbla.

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