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

slow compilation times when including fmt/format.h #1537

Closed
ankut opened this issue Jan 29, 2020 · 3 comments
Closed

slow compilation times when including fmt/format.h #1537

ankut opened this issue Jan 29, 2020 · 3 comments
Labels

Comments

@ankut
Copy link

ankut commented Jan 29, 2020

I am seeing singnificantly slower compilation times when including fmt/format.h with a single trivial fmt::format(“hello {}”, 5) use, as compared to fmt/core.h. However, since i would like to do FMT_STRING() validation at compile time, i am forced to include the format.h header. The compilation time goes up regardless of using the macro. Is there any way that i could have compile time format string checking, without the steep compilation time penalty? I tried on several recent gcc versions and saw the same compilation time hit. Any guidance on this is appreciated.

@vitaut
Copy link
Contributor

vitaut commented Jan 29, 2020

Compile-time checks require all of the format string parsing logic from fmt/format.h. You could speed up your builds by using precompiled headers or by only enabling checks in CI or some other build mode, e.g.

// helper header:
#if CI
# include <fmt/format.h>
#else
# include <fmt/core.h>
# define FMT_STRING(s) s
#endif

@marlowa
Copy link

marlowa commented Jan 22, 2024

Precompiled headers? How will that work on linux/g++?

@vitaut
Copy link
Contributor

vitaut commented Jan 23, 2024

https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html. Note that this issue is somewhat outdated since consteval-based format string compilation doesn't require including fmt/format.h.

@vitaut vitaut added the question label Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants