Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ code failing to build on OpenBSD/amd64 missing CRT functions #56694

Open
brad0 opened this issue Jul 25, 2022 · 4 comments
Open

C++ code failing to build on OpenBSD/amd64 missing CRT functions #56694

brad0 opened this issue Jul 25, 2022 · 4 comments

Comments

@brad0
Copy link
Contributor

brad0 commented Jul 25, 2022

Clang / LLVM / lld / libc++ / compiler-rt 13.0.0.

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 defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT).

I see CRT_HAS_128BIT is defined. CRT_LDBL_128BIT is not defined.

fp_lib.h checks __LDBL_MANT_DIG__ == 113 && defined(__SIZEOF_INT128__).

$ clang -dM -E - < /dev/null | grep __LDBL_MANT_DIG__
#define __LDBL_MANT_DIG__ 64
$ 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 __LDBL_MANT_DIG__ on amd64.

@brad0
Copy link
Contributor Author

brad0 commented Aug 7, 2022

@MaskRay

@brad0
Copy link
Contributor Author

brad0 commented Nov 27, 2023

I think these commits to compiler-rt should resolve my issues, but I'll have to do some testing and see what happens.

910a4bf
d2ce3e9

@MaskRay
Copy link
Member

MaskRay commented Nov 27, 2023

I think these commits to compiler-rt should resolve my issues, but I'll have to do some testing and see what happens.

910a4bf d2ce3e9

Yes. There are other compiler-rt/lib/builtins commits that are related to float128/long double that you may want to cherry pick: 05a4212/b745ce952560716545e82770bf835e48a567eaf1

@brad0
Copy link
Contributor Author

brad0 commented Nov 27, 2023

Yes. There are other compiler-rt/lib/builtins commits that are related to float128/long double that you may want to cherry pick: 05a4212/b745ce952560716545e82770bf835e48a567eaf1

Thanks. Yes, I noticed one or two other related commits just after that.

@brad0 brad0 changed the title C++ code failing to build on OpenBSD/amd 64 missing CRT functions C++ code failing to build on OpenBSD/amd64 missing CRT functions Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants