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

    <tr>
        <th>Summary</th>
        <td>
            [builtins] Missing `__extendhfxf2` and `__truncxfhf2`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            compiler-rt:builtins
      </td>
    </tr>

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

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

<pre>
    These functions convert their argument between `_Float16` and x86 80-bit `long double`.

https://godbolt.org/z/YqWsToYde

C++ code:

```cpp
long double foo(_Float16 x) {
    return x;
}
```

Error when running Clang with `-rtlib=compiler-rt`:

```
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../x86_64-linux-gnu/bin/ld: /tmp/example-2fb810.o: undefined reference to symbol '__extendhfxf2@@GCC_12.0.0'
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../x86_64-linux-gnu/bin/ld: /opt/compiler-explorer/gcc-snapshot/lib64/libgcc_s.so.1: error adding symbols: DSO missing from command line
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Compiler returned: 1
```

C++ code:

```cpp
_Float16 bar(long double x) {
 return static_cast<_Float16>(x);
}
```

Error when running Clang with `-rtlib=compiler-rt`:

```
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../x86_64-linux-gnu/bin/ld: /tmp/example-32f526.o: undefined reference to symbol '__truncxfhf2@@GCC_12.0.0'
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../x86_64-linux-gnu/bin/ld: /opt/compiler-explorer/gcc-snapshot/lib64/libgcc_s.so.1: error adding symbols: DSO missing from command line
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Compiler returned: 1
```

cc @lntue

</pre>
<img width="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