osrm-backend
osrm-backend copied to clipboard
Replace libfmt with std::format
Issue
This is an alternative solution to https://github.com/Project-OSRM/osrm-backend/issues/7238
Tasklist
- [ x] CHANGELOG.md entry (How to write a changelog entry)
- [ ] update relevant Wiki pages
- [ ] add tests (see testing documentation)
- [ ] review
- [ ] adjust for comments
Requirements / Relations
none
Please do not forget to remove the fmt from scripts/update_dependencies.sh
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 usesstd::formatwhen available - Falls back to
fmt::formaton systems wherestd::formatdoesn'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:
- Keep fmt as a fallback for systems with incomplete std::format
- Gradually phase out fmt as older compilers are retired
- Avoid breaking builds for users on platforms with partial C++20 support
Would you be open to reviewing #7261 as an alternative approach?