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

    <tr>
        <th>Summary</th>
        <td>
            C++ code failing to build on OpenBSD/amd 64 missing CRT functions
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    Trying to figure out why some C++ code is not building on OpenBSD/amd64.

Trying to build fmt 9.0.0 one of the tests is failing like so...

```
[55/68] : && /home/ports/pobj/fmt-9.0.0/bin/c++ -O2 -pipe -DNDEBUG  test/CMakeFiles/format-test.dir/format-test.cc.o -o bin/format-test  -Wl,-z,origin,-rpath,/home/ports/pobj/fmt-9.0.0/build-amd64  test/libtest-main.a  libfmt.so.1.1  -Wl,--as-needed  test/gtest/libgtest.a  -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib && :
FAILED: bin/format-test
: && /home/ports/pobj/fmt-9.0.0/bin/c++ -O2 -pipe -DNDEBUG  test/CMakeFiles/format-test.dir/format-test.cc.o -o bin/format-test  -Wl,-z,origin,-rpath,/home/ports/pobj/fmt-9.0.0/build-amd64  test/libtest-main.a  libfmt.so.1.1  -Wl,--as-needed  test/gtest/libgtest.a  -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib && :
ld: error: undefined symbol: __eqtf2
>>> referenced by format-test.cc
>>>               test/CMakeFiles/format-test.dir/format-test.cc.o:(std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > fmt::v9::detail::write<char, std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, __float128, 0>(std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, __float128, fmt::v9::basic_format_specs<char>, fmt::v9::detail::locale_ref))
>>> did you mean: __eqdf2
>>> defined in: /usr/lib/libcompiler_rt.a

ld: error: undefined symbol: __unordtf2
>>> referenced by format-test.cc
>>>               test/CMakeFiles/format-test.dir/format-test.cc.o:(std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > fmt::v9::detail::write<char, std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, __float128, 0>(std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, __float128, fmt::v9::basic_format_specs<char>, fmt::v9::detail::locale_ref))
>>> referenced by format-test.cc
>>>               test/CMakeFiles/format-test.dir/format-test.cc.o:(std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > fmt::v9::detail::write<char, std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, __float128, 0>(std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, __float128, fmt::v9::basic_format_specs<char>, fmt::v9::detail::locale_ref))
>>> did you mean: __unorddf2
>>> defined in: /usr/lib/libcompiler_rt.a

ld: error: undefined symbol: __netf2
>>> referenced by format-test.cc
>>>               test/CMakeFiles/format-test.dir/format-test.cc.o:(std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > fmt::v9::detail::write<char, std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, __float128, 0>(std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, __float128, fmt::v9::basic_format_specs<char>, fmt::v9::detail::locale_ref))

ld: error: undefined symbol: __letf2
>>> referenced by format-test.cc
>>>               test/CMakeFiles/format-test.dir/format-test.cc.o:(int fmt::v9::detail::format_float<__float128>(__float128, int, fmt::v9::detail::float_specs, fmt::v9::detail::buffer<char>&))

ld: error: undefined symbol: __trunctfsf2
>>> referenced by format-test.cc
>>>               test/CMakeFiles/format-test.dir/format-test.cc.o:(int fmt::v9::detail::format_float<__float128>(__float128, int, fmt::v9::detail::float_specs, fmt::v9::detail::buffer<char>&))
c++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
```

The functions in compiler-rt come from comparetf2.c and trunctfsf2.c. They're built if CRT_HAS_128BIT and CRT_LDBL_128BIT are defined. I see CRT_HAS_128BIT is. CRT_LDBL_128BIT is not. fp_lib.h checks ```__LDBL_MANT_DIG__ == 113 && defined(__SIZEOF_INT128__)``` .

```
humpty$ clang -dM -E - < /dev/null | grep __LDBL_MANT_DIG__
#define __LDBL_MANT_DIG__ 64
humpty$ clang -dM -E - < /dev/null | grep __SIZEOF_INT128__
#define __SIZEOF_INT128__ 16
```

test/Preprocessor/init-x86.c seems to show that 64 is the expected value for amd64.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWd1v2zYQ_2vkl4MESbZk-8EPiZ10AfoxNBk27EWgpJPFRiI9kkrq_vU7UrIT20FatMXQAQ4YkSKP9_0jjVMuy-3iTm25WIORUPF1pxBkZ-Cx3oKWLcLSiy-pQSFLBK5BSAN5x5vS7pECPmxQXN6uvPiatWU6Cbxw5YUX_fOJs9sBVWtgHoRBSBtJTAWmRjCojbacK8YbS97weyTZQXDAy0vDofWvyWWSkNB05iUr8MYX4MUpNequa9Kbuo1URrs-_0QdCfedcBrnXNCzGEzzP8Tgb_gGwV-9X11d_vEGnFZEsnzH7vGaN2gZVVK1zPh2KSi5OpopikCCT6Y63s9WAPw_Gy9e-l_oIRVfW4KlrzbM1DT4NoWt_3zn4b1uDc_tyG8ZFwED8ltOWwLyXBREe6E-075ALLHcb1w_MXBDu3mgdkr5FIb7XrNOWzP_iqKPab-BPL2fbmTBmn567_3xEK7ri5u3VysblxN_DAE8h-wXC1lT2pigUlLZQSdKrLggJfS2zWVj57IM_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