<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/86463>86463</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [flang] OpenBLAS 0.3.26 not buildable with flang 18
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          h-vetinari
      </td>
    </tr>
</table>

<pre>
    I had been under the impression that flang had already been able to compile BLAS/LAPACK and OpenBLAS successfully (c.f. https://github.com/llvm/llvm-project/issues/64750, https://github.com/llvm/llvm-project/issues/67675, https://github.com/llvm/llvm-project/issues/70458).

However, while [trying](https://github.com/conda-forge/openblas-feedstock/pull/115)[^1] to use flang 18.1.2 to compile the latest OpenBLAS 0.3.26 (aside from from backporting a small [fix](https://github.com/OpenMathLib/OpenBLAS/commit/52b71a1673dfe1fddfcbae3b8a03486438223fdf) due to flang 18 being stricter on unknown flags), things fail pretty early with what looks like a parsing problem...

[^1]: despite the title of the PR, the error here is for the case with `USE_OPENMP=0`, i.e. no OpenMP; with OpenMP I still have to fix stuff around `OpenMP_Fortran`

```
[2005/19090] Building Fortran object CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\sgbcon.f.obj
FAILED: CMakeFiles/LAPACK_OVERRIDES.dir/lapack-netlib/SRC/sgbcon.f.obj 
%BUILD_PREFIX%\Library\bin\flang.exe -I%SRC_DIR%\lapack-netlib\SRC -I%SRC_DIR%\lapack-netlib\LAPACKE\include -ffixed-line-length-72 -o CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\sgbcon.f.obj -c CMakeFiles\LAPACK_OVERRIDES.dir\lapack-netlib\SRC\sgbcon.f-pp.f
error: loc("D:\\bld\\openblas_1711274852957\\work\\lapack-netlib\\SRC\\sgbcon.f":206:7): operation with block successors must terminate its parent block

error: verification of lowering to FIR failed
```

Looking for the error message, the only open issue I've found is https://github.com/llvm/llvm-project/issues/61281, but that issue explicitly says "This case is OK in OpenMP". There's also https://github.com/llvm/llvm-project/issues/74348 (which got fixed in 18.1) and https://github.com/llvm/llvm-project/issues/72792 (where it's unclear when/what was fixed).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVl1v2zYU_TX0y4UFifr0gx8c28KMpkvgtMPeAlK6sljTpEBScfzvB4px63bFNiwFAkWyLs_9OvceMWvFQSEuSX5H8s2Mja7XZtnPX9AJxYyYcd1eljvoWQscUcGoWjTgegRxGgxaK7QC1zMHnWTqMBkyaZC1l3CAcYngNDT6NAiJcHe_eiK0vl89rtYfgKkWHgZU_lewY9Ogtd0o5QUIrZqoi6B3brAkXRFaE1ofhOtHHjX6RGgt5cv133ww-gs2jtBaWDuiJbQusjKPCV2_B6Isyvx9EGWc5RWhi4jEGxKvwvU3fcYXNB753PuqkPzOmYtQB5JvCK3-wV2jVcvmnTYHJLTWAyoumZ13iK11ujkSWg-jlITWSZITupg6u01IvvFdGC2-NSqpoiSit53xTZXMoXXfWhJHaUQL3wxmRYvQGX0KF86a46CNE-oADOyJSemz6MTrv6bg0T8y198L_vb0RopGn07CVy-nvExYUpRp22HStW3XcIYpr1icZlWRpRWladd2hC6gHSd-XbMCjj4k64xoHBrQnrNHpc_KmxysLwldg-uFOljomJAwGHTuAsiMvMBZuB7OntBS66MFKY4IDAZmrMcdjOYST1H0XT-_FZmkK2jRDsKFgjrhJILupofHfXCNgMZoAz0aBGGh02GkGmYxBECK-PPT9vnhcfv7x0eSbmJSTFQWEUag9NQg_-IumIdH2IF1Qkro2UuoiXgF68auA2b0qFoPG0yfa22cYcrD3uZRxG9_17RoHOeeS4t4EXsO3Y1Ctr4QbwCguWc8rD-yI9ZCoiX5Ogz388Mf2_1-t9k-Ra0wJF9LNrDmOFfopOAkXz_t1yRf2wNvtIq6SPMvwW292t1vp0reoF5Xxg-otP4eldYelda3qPCWDc3vPu_uN8-P-229-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