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

    <tr>
        <th>Summary</th>
        <td>
            [flang] COMPLEX*32 works but COMPLEX(real128) - Open MPI build fails
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          hakostra
      </td>
    </tr>
</table>

<pre>
    I encountered a problem building Open MPI 5.0.7 with a newly compiled `flang` from git sources, reported here: https://github.com/open-mpi/ompi/issues/13136

The version of `flang` I built is:

```
flang version 21.0.0git (https://github.com/llvm/llvm-project.git 5d50af3f0368847ab9ce1d86cb6e46ffaf317b59)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/llvm/llvm-project/install/bin
```

The problem is in short that variable declarations `COMPLEX(real128)` does not work, take the following as an example:

```
PROGRAM real128test
    USE iso_fortran_env, ONLY: real128
    IMPLICIT NONE (type, external)

    COMPLEX(real128) :: test

    test = CMPLX(1.0, 2.0)
    WRITE(*, *) "test: ", test
 WRITE(*, *) "storage_size: ", storage_size(test)
END PROGRAM real128test
```

Compiling this I get:

```
error: Semantic errors in real128.F90
./real128.F90:5:5: error: COMPLEX(KIND=-1) is not a supported type
      COMPLEX(real128) :: test
```

However, the similar example, using COMPLEX*32, works:

```
PROGRAM complextest
    IMPLICIT NONE (type, external)

    COMPLEX*32 test

    test = CMPLX(1.0, 2.0)
 WRITE(*, *) "test: ", test
    WRITE(*, *) "storage_size: ", storage_size(test)
END PROGRAM complextest
```

Giving me the output:

```
$ flang complex32.F90 
$ ./a.out 
 test:  (1.,2.)
 storage_size:  256
```

Which I think is a bit weird. In my mind, `COMPLEX*32` and `COMPLEX(real128)` should be the same type, but maybe I'm wrong...

So it seems my `flang` was compiled without support for `real128`, which is fine, I don't need it. However, I find it strange that `COMPLEX*32` works in this scenario. A side-note is that I have attempted to build `flang` wit OpenMP offloading support, maybe that is why `real128` is disabled.

So the reason the Open MPI build fails, is that it checks for the support of `COMPLEX*32` with some simple test, then, if this is support is present, it goes ahead and use `COMPLEX(real128)` as if these two declarations are equivalent. This does not work and the build fails.

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVltv47gO_jXKCxHDlmMnechDTi9zjNMbZnowu0-FbNOxtrLkleSk3V-_oOxe0skWO7tACycORfL7-ImkcE7uNOKGZf9h2flMDL41dtOKR-O8FbPS1M-bAlBXZtAeLdYgoLemVNhBOUhVS72D2x41XN8VkEVxtISD9C0I0HhQz1CZrpcKa2B53CihdyyPobGmg5304MxgK3SMn4HF3liPNbRokaVbaL3vHUu3jF8yfrmTvh3KqDId45emRz3vekkfx4d0biA_l0mapDmLtyze3rcIe7ROGg2mOUqgCMl7kCFAsGZ5PP3F22D3epYnURzFlC7jq0-yUmr_8pj31vyGlY_oVFZnsWjSJk7z1WqxFOW6wqRe5VWZ4yJvGtGkybLM1oyvKWthd-iJgKdV_pAv5oN-1Oag50rq4Wm-00OAZlHU0JkaFZn2xsknFm8L7bxQCutzael94Mqfzo1YG80Zvyyl_sDBROBLsaUDqcG1xnrwrfCwF1aKUiHUWClhhZdGOyL57Pb67uriF8ZXFoVK-Ipw5THUBh1o4-Fg7CNV3ItHBN8iNEYpcyAlCQdCAz6Jrld4sjR3X2-_fN1ew-Tbo_Ms3gIA_P_bBUhnHhpjvRX6AfWeotzeXP1KVLwkMxoX13dXxVlxDze3NxdUV__cI5njk0erhRqLMVmfggSUXrqFKYPJkr4BS8_h7Pruig4kUUxuOT3Wk9H3r8X9BSMvW_otPNbAOA--Qtl4IGgC95f2zhsrdvjg5B_47tzR64mjEPzi5hxOE_ih8mfh1lJFfCsdFDBK8sdyoLUmKO0bdkJ7WUF4E8QyRYgu12QZMX75_k26zaZ_eHXyxvP_iptzlp7PE0IqR90IcEM_NYlQrpHNv1eeY3z_NQfcow0ktwhOdlIJ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