# FindBLAS needs a try\_run to test link from Fortran

**URL:** <https://discourse.cmake.org/t/findblas-needs-a-try-run-to-test-link-from-fortran/7114>\
**Category:** Code\
**Created:** [December 22, 2022, 11:49am UTC](https://discourse.cmake.org/t/findblas-needs-a-try-run-to-test-link-from-fortran/7114 "2022-12-22T11:49:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![krefson](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/d2c977/32.png) [@krefson](https://discourse.cmake.org/u/krefson)\
**Post date:** [December 22, 2022, 11:49am UTC](https://discourse.cmake.org/t/findblas-needs-a-try-run-to-test-link-from-fortran/7114/1 "2022-12-22T11:49:01Z")

</div>

Having spent 30 minutes in puzzlement over a bad build with segfaulting executables, I would like to propose an enhancement of FindBLAS to check that the BLAS libraries found are ABI-compatible with the Fortran compiler in use.

Scenario - on my development machine I like to have multiple compilers installed for testing. Therefore I need multiple different builds of OpenBLAS, because Fortran compilers differ in their ABI requirements. (Function calls such as zdotc differ in how return values are passed). A mismatch results in an apparently successful but non-functional link, which will crash/give incorrect results at run-time.

I observe that FindBLAS contains code to check the link. This is not sufficient, and I propose that it should also attempt a try\_run() to test correct ABI calling sequence for a fortran _function_ not subroutine.

Of course I can include a test compile and run in my CMakelists.txt, but all that can do is abort the configuration step on failure. If this were done _within_ FindBLAS, it could skip over that set of libraries and try another.

Any takers? I will be happy to contribute a test program.

K.R.
