mp-units icon indicating copy to clipboard operation
mp-units copied to clipboard

failure to install with gcc14

Open VictorEijkhout opened this issue 9 months ago • 10 comments

/work2/00434/eijkhout/mpunits/mpunits-2.4.0/src/core/include/mp-units/format.h:255:44: error: no matching function for call to ‘unit_symbol_to<char>(fmt::v11::context::iterator, const mp_units::si::femt
o_<mp_units::si::metre>&, fmt::v11::formatter<mp_units::si::femto_<mp_units::si::metre>, char, void>::format_specs&)’
  255 |       return mp_units::unit_symbol_to<Char>(ctx.out(), u, specs);
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

VictorEijkhout avatar Apr 13 '25 02:04 VictorEijkhout

@VictorEijkhout, could you provide more details about your problem? The best would be a Compiler Explorer link with the code that does not compile. I just tried the following https://godbolt.org/z/Mzq7TcssY, and everything seems to work fine for gcc-14. Our CI has also not reported any issues for a long time now.

mpusz avatar Apr 13 '25 14:04 mpusz

Here's the context:

[  5%] ESC[32mBuilding CXX object example/CMakeFiles/clcpp_response-headers.dir/clcpp_response.cpp.oESC[0m
cd /work2/00434/eijkhout/mpunits/build-2.4.0-stampede3-gcc13.2/example && /opt/apps/gcc/13.2.0/bin/g++ -DFMT_SHARED -DMP_UNITS_API_CONTRACTS=2 -DMP_UNITS_API_NO_CRTP=0 -DMP_UNITS_API_STD_FORMAT=0 -DMP_U
NITS_API_STRING_VIEW_RET=0 -DMP_UNITS_HOSTED=1 -I/work2/00434/eijkhout/mpunits/mpunits-2.4.0/src/core/include -I/work2/00434/eijkhout/mpunits/mpunits-2.4.0/src/systems/include -isystem /work2/00434/eijk
hout/fmtlib/installation-fmtlib-11.0.2-stampede3-gcc13.2/include -isystem /work2/00434/eijkhout/gsllite/installation-gsllite-0.42.0-stampede3-gcc13.2/include -O2 -g -DNDEBUG -std=gnu++20 -Wall -Wextra -
Wpedantic -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wcast-qual -Wconversion -Wsign-conversion -Wnull-dereference -Wformat=2 -Wdangling-else -Wdouble-promot
ion -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Werror -MD -MT example/CMakeFiles/clcpp_response-headers.dir/clcpp_response.cpp.o -MF CMakeFiles/clcpp_response-headers
.dir/clcpp_response.cpp.o.d -o CMakeFiles/clcpp_response-headers.dir/clcpp_response.cpp.o -c /work2/00434/eijkhout/mpunits/mpunits-2.4.0/example/clcpp_response.cpp
In file included from /work2/00434/eijkhout/mpunits/mpunits-2.4.0/example/clcpp_response.cpp:28:
/work2/00434/eijkhout/mpunits/mpunits-2.4.0/src/core/include/mp-units/format.h: In instantiation of ‘constexpr decltype (ctx.out()) formatter<T, Char>::format(const U&, FormatContext&) const [with Forma
tContext = fmt::v11::context; U = mp_units::si::femto_<mp_units::si::metre>; Char = char; decltype (ctx.out()) = fmt::v11::basic_appender<char>]’:
/work2/00434/eijkhout/fmtlib/installation-fmtlib-11.0.2-stampede3-gcc13.2/include/fmt/base.h:1402:29:   required from ‘static void fmt::v11::detail::value<Context>::format_custom_arg(void*, typename Con
text::parse_context_type&, Context&) [with T = mp_units::si::femto_<mp_units::si::metre>; Formatter = fmt::v11::formatter<mp_units::si::femto_<mp_units::si::metre>, char, void>; Context = fmt::v11::cont
ext; typename Context::parse_context_type = fmt::v11::basic_format_parse_context<char>]’
/work2/00434/eijkhout/fmtlib/installation-fmtlib-11.0.2-stampede3-gcc13.2/include/fmt/base.h:1383:19:   required from ‘constexpr fmt::v11::detail::value<Context>::value(T&) [with T = const mp_units::si:
:femto_<mp_units::si::metre>; Context = fmt::v11::context]’
/work2/00434/eijkhout/mpunits/mpunits-2.4.0/src/core/include/mp-units/format.h:469:3:   required from ‘OutputIt fmt::v11::formatter<mp_units::quantity<R, Rep>, Char>::format_quantity(OutputIt, const qua
ntity_t&, FormatContext&) const [with OutputIt = fmt::v11::basic_appender<char>; FormatContext = fmt::v11::context; auto Reference = mp_units::si::femto_<mp_units::si::metre>(); Rep = float; Char = char
; quantity_t = mp_units::quantity<mp_units::si::femto_<mp_units::si::metre>(), float>]’
/work2/00434/eijkhout/mpunits/mpunits-2.4.0/src/core/include/mp-units/format.h:494:22:   required from ‘auto fmt::v11::formatter<mp_units::quantity<R, Rep>, Char>::format(const quantity_t&, FormatContex
t&) const [with FormatContext = fmt::v11::context; auto Reference = mp_units::si::femto_<mp_units::si::metre>(); Rep = float; Char = char; quantity_t = mp_units::quantity<mp_units::si::femto_<mp_units::
si::metre>(), float>]’
/work2/00434/eijkhout/fmtlib/installation-fmtlib-11.0.2-stampede3-gcc13.2/include/fmt/base.h:1224:70:   [ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/work2/00434/eijkhout/fmtlib/installation-fmtlib-11.0.2-stampede3-gcc13.2/include/fmt/base.h:1523:69:   required from ‘struct fmt::v11::detail::arg_mapper<fmt::v11::context>::formattable<const mp_units:
:quantity<mp_units::si::femto_<mp_units::si::metre>(), float>, mp_units::quantity<mp_units::si::femto_<mp_units::si::metre>(), float> >’
/work2/00434/eijkhout/fmtlib/installation-fmtlib-11.0.2-stampede3-gcc13.2/include/fmt/base.h:1531:25:   required by substitution of ‘template<class T, typename std::enable_if<(! fmt::v11::detail::arg_ma
pper<fmt::v11::context>::formattable<T, typename std::remove_const<_Tp>::type>::value), int>::type <anonymous> > constexpr fmt::v11::detail::unformattable fmt::v11::detail::arg_mapper<fmt::v11::context>
::do_map(T&) [with T = const mp_units::quantity<mp_units::si::femto_<mp_units::si::metre>(), float>; typename std::enable_if<(! fmt::v11::detail::arg_mapper<fmt::v11::context>::formattable<T, typename s
td::remove_const<_Tp>::type>::value), int>::type <anonymous> = <missing>]’
/work2/00434/eijkhout/fmtlib/installation-fmtlib-11.0.2-stampede3-gcc13.2/include/fmt/base.h:1544:68:   required by substitution of ‘template<class T, class U, typename std::enable_if<((((((((std::is_cl
ass<U>::value || std::is_enum<_Tp2>::value) || std::is_union<U>::value) || std::is_fundamental<U>::value) && (! fmt::v11::detail::has_to_string_view<U, void>::value)) && (! fmt::v11::is_char<U>::value))
 && (! fmt::v11::detail::is_named_arg<T>::value)) && (! std::is_integral<_Size>::value)) && (! std::is_arithmetic<typename fmt::v11::detail::format_as_result<U>::type>::value)), int>::type <anonymous> >
 constexpr decltype (((fmt::v11::detail::arg_mapper<fmt::v11::context>*)this)->fmt::v11::detail::arg_mapper<fmt::v11::context>::do_map(val)) fmt::v11::detail::arg_mapper<fmt::v11::context>::map(T&) [wit
h T = const mp_units::quantity<mp_units::si::femto_<mp_units::si::metre>(), float>; U = mp_units::quantity<mp_units::si::femto_<mp_units::si::metre>(), float>; typename std::enable_if<((((((((std::is_cl
ass<U>::value || std::is_enum<_Tp2>::value) || std::is_union<U>::value) || std::is_fundamental<U>::value) && (! fmt::v11::detail::has_to_string_view<U, void>::value)) && (! fmt::v11::is_char<U>::value))
 && (! fmt::v11::detail::is_named_arg<T>::value)) && (! std::is_integral<_Size>::value)) && (! std::is_arithmetic<typename fmt::v11::detail::format_as_result<U>::type>::value)), int>::type <anonymous> =
 0]’
/work2/00434/eijkhout/fmtlib/installation-fmtlib-11.0.2-stampede3-gcc13.2/include/fmt/base.h:1560:53:   required by substitution of ‘template<class T, class Context> using fmt::v11::detail::mapped_type_
constant = fmt::v11::detail::type_constant<decltype (fmt::v11::detail::arg_mapper<Context>().map(declval<const T&>())), typename Context::char_type> [with T = mp_units::quantity<mp_units::si::femto_<mp_
units::si::metre>(), float>; Context = fmt::v11::context]’
/work2/00434/eijkhout/fmtlib/installation-fmtlib-11.0.2-stampede3-gcc13.2/include/fmt/base.h:2733:68:   required from ‘constexpr fmt::v11::detail::format_string_checker<Char, Args>::format_string_checke
r(fmt::v11::basic_string_view<Char>) [with Char = char; Args = {mp_units::quantity<mp_units::si::femto_<mp_units::si::metre>(), float>, mp_units::quantity<mp_units::si::femto_<mp_units::si::metre>(), fl
oat>, mp_units::quantity<mp_units::si::femto_<mp_units::si::metre>(), float>}]’
/work2/00434/eijkhout/mpunits/mpunits-2.4.0/example/clcpp_response.cpp:126:40:   required from here
/work2/00434/eijkhout/mpunits/mpunits-2.4.0/src/core/include/mp-units/format.h:255:44: error: no matching function for call to ‘unit_symbol_to<char>(fmt::v11::context::iterator, const mp_units::si::femto_<mp_units::si::metre>&, fmt::v11::formatter<mp_units::si::femto_<mp_units::si::metre>, char, void>::format_specs&)’

VictorEijkhout avatar Apr 13 '25 18:04 VictorEijkhout

Do you use Conan, or do you provide dependencies manually? In case you do it by yourself, you might be using an unstable version of fmt. There was a known error in this library, which should be fixed in the latest versions. It should also work with std::format instead.

mpusz avatar Apr 13 '25 19:04 mpusz

Everything by hand. And after I updated fmtlib to the latest release the installation succeeds. Yay.

This is probably my problem:

[ 63%] ESC[32mESC[1mLinking CXX executable unit_tests_runtimeESC[0m
cd /work2/00434/eijkhout/mpunits/build-2.4.0-stampede3-gcc13.2/test/runtime && /home1/apps/cmake/3.31.5/bin/cmake -E cmake_link_script CMakeFiles/unit_tests_runtime.dir/link.txt --verbose=1
/opt/apps/gcc/13.2.0/bin/ld: /work2/00434/eijkhout/catch2/installation-catch2-3.5.4-stampede3-gcc13.2/lib64/libCatch2.so.3.5.4: undefined reference to `__cxa_call_terminate@CXXABI_1.3.15'
collect2: error: ld returned 1 exit status

Can I hack around this by disabling the unit tests?

VictorEijkhout avatar Apr 13 '25 19:04 VictorEijkhout

Sure! However, if you just want to consume the library, you do not have to compile any of our tests or examples. Just use src directory as stated in:

  • https://mpusz.github.io/mp-units/latest/getting_started/project_structure/#cmake-projects-and-dependencies
  • https://mpusz.github.io/mp-units/latest/getting_started/installation_and_usage/#copy-cmake

or use Conan 😉

mpusz avatar Apr 14 '25 08:04 mpusz

The problem with conan is that other developers will tell me to use spack or whatever. So the interaction becomes a nightmare. Especially since I have to build for multple compilers.

But ok, you're headers only (and compilation times be damned? I love it that catch2 has both header-only & library modes) so I'll install it that way.

EDIT previous remark deleted.

VictorEijkhout avatar Apr 14 '25 12:04 VictorEijkhout

Top level CMakeLists.txt file should only be used by mp-units developers and contributors as an entry point for the project's development. ./src/CMakeLists.txt contains only a pure library definition and should be used by the customers 

Why didn't you tell me so in the first place? This works perfectly. And it installs the .cmake files which I think I wouldn't get from copying the source files.

VictorEijkhout avatar Apr 14 '25 12:04 VictorEijkhout

You complained about the library not compiling for you. I didn't know that you just want to install it. You just mentioned it in another thread 😉

Anyway, if my examples do not compile for you, the code written in your production project may not compile as well, so it might be worth solving it out. Unless you do not plan to use text formatting in your project...

mpusz avatar Apr 14 '25 16:04 mpusz

Well, I was using the default cmake file. The fact that I could install only the sources through an embedded cmake setup was well hidden. You could for instance make a tiny Installation section on the main README.md

VictorEijkhout avatar Apr 14 '25 16:04 VictorEijkhout

This is why we have an extensive "Installation And Usage" chapter in our documentation, and the link to it is provided in the README.md and on a GitHub repo page.

mpusz avatar Apr 14 '25 16:04 mpusz