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

Failed to compile fmt on emscripten using C++20 #22795

Closed
Floris0106 opened this issue Oct 27, 2024 · 2 comments
Closed

Failed to compile fmt on emscripten using C++20 #22795

Floris0106 opened this issue Oct 27, 2024 · 2 comments

Comments

@Floris0106
Copy link

When compiling fmt using emscripten's CMake toolchain file (obtained through the emsdk) with the following errors:

error: call to consteval function 'fmt::basic_format_string<char, const char *>::basic_format_string<FMT_COMPILE_STRING, 0>' is not a constant expression
error: call to consteval function 'fmt::basic_format_string<char, const char *>::basic_format_string<FMT_COMPILE_STRING, 0>' is not a constant expression
error: call to consteval function 'fmt::basic_format_string<char, int &>::basic_format_string<FMT_COMPILE_STRING, 0>' is not a constant expression
error: call to consteval function 'fmt::basic_format_string<char, int &, int &>::basic_format_string<FMT_COMPILE_STRING, 0>' is not a constant expression
error: call to consteval function 'fmt::basic_format_string<char, fmt::basic_string_view<char> &, const char (&)[3]>::basic_format_string<FMT_COMPILE_STRING, 0>' is not a constant expression
error: call to consteval function 'fmt::basic_format_string<char, const char (&)[7], int &>::basic_format_string<FMT_COMPILE_STRING, 0>' is not a constant expression
error: call to consteval function 'fmt::basic_format_string<char, unsigned int &>::basic_format_string<FMT_COMPILE_STRING, 0>' is not a constant expression
error: call to consteval function 'fmt::basic_format_string<char, unsigned int &>::basic_format_string<FMT_COMPILE_STRING, 0>' is not a constant expression
error: call to consteval function 'fmt::basic_format_string<char, int>::basic_format_string<FMT_COMPILE_STRING, 0>' is not a constant expression

I'm able to reproduce this issue with the latest versions of emsdk (3.1.70) and fmt (11.0.2). I used the following CMakePresets.json:

{
	"version": 1,
	"configurePresets": [
		{
			"name": "Emscripten",
			"generator": "Ninja",
			"toolchainFile": "$env{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
		}
	]
}

Here EMSDK is an environment variable that points to the root directory of the emsdk. CMakeLists.txt:

include(FetchContent)

project(Test)

set(CMAKE_CXX_STANDARD 20)

FetchContent_Declare(fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git GIT_TAG 11.0.2 DOWNLOAD_EXTRACT_TIMESTAMP true)
FetchContent_MakeAvailable(fmt)

I'm not sure whether this is an issue with fmt or emscripten, so I've made an issue on the fmt repository as well. (see here)

@Twinklebear
Copy link
Contributor

I think I hit the same and it was fixed for me by this PR on fmt: fmtlib/fmt#4187 , if you switch to pull fmt commit 22701d5f63fd9ba3ffa35fe94585b5bfcb69238b or later it should compile.

@Floris0106
Copy link
Author

Ah perfect, now it works. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants