osrm-backend icon indicating copy to clipboard operation
osrm-backend copied to clipboard

Replace libfmt with std::format

Open nyllet opened this issue 3 months ago • 2 comments

Issue

This is an alternative solution to https://github.com/Project-OSRM/osrm-backend/issues/7238

Tasklist

Requirements / Relations

none

nyllet avatar Sep 14 '25 10:09 nyllet

Please do not forget to remove the fmt from scripts/update_dependencies.sh

afarber avatar Sep 14 '25 14:09 afarber

Hi @nyllet, your PR removes the fmt library entirely and switches directly to std::format...

However, this might cause build failures on systems where std::format is incomplete. For example:

  • Clang with older libstdc++: The <format> header exists, but symbols are missing at link time
  • Some GCC 13 installations: Have incomplete chrono formatting support
  • Alpine Linux with GCC 14: Missing chrono formatters

I've just submitted #7261 which takes a different approach:

  • Adds a thin compatibility layer (util/format.hpp) that automatically uses std::format when available
  • Falls back to fmt::format on systems where std::format doesn't work
  • Uses CMake runtime detection (check_cxx_source_runs) to test compile, link and execution
  • Also fixes the node_osrm C++17/C++20 ABI mismatch that was overlooked in #6877

This way, we can:

  1. Keep fmt as a fallback for systems with incomplete std::format
  2. Gradually phase out fmt as older compilers are retired
  3. Avoid breaking builds for users on platforms with partial C++20 support

Would you be open to reviewing #7261 as an alternative approach?

afarber avatar Oct 18 '25 22:10 afarber