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

Error in CMake build on MacOS with Clang #4173

Closed
Khrysys opened this issue Sep 21, 2024 · 6 comments
Closed

Error in CMake build on MacOS with Clang #4173

Khrysys opened this issue Sep 21, 2024 · 6 comments

Comments

@Khrysys
Copy link

Khrysys commented Sep 21, 2024

I'm building a library that extensively uses fmt for it's debugging and error system, and on MacOS the build fails with the following error in my actions builds. The project uses C++20 and adds fmt as a subdirectory. It appears to be a clang specific problem.

/Users/runner/work/VkBootstrap3/VkBootstrap3/external/fmt/include/fmt/base.h:401:1: warning: unknown warning group '-Wbit-int-extension', ignored [-Wunknown-warning-option]
FMT_PRAGMA_CLANG(diagnostic ignored "-Wbit-int-extension")

/Users/runner/work/VkBootstrap3/VkBootstrap3/external/fmt/include/fmt/base.h:402:33: error: unknown type name '_BitInt'
template <int N> using bitint = _BitInt(N);

The error then seems to cascade down and cause many other errors in the file, but it appears to be centered around this one. I'm sure it's probably some error on my end, but multiple separate pieces have this error, so I'm not sure where it comes from.

@Khrysys Khrysys changed the title Error in CMake build on MacOS Error in CMake build on MacOS with Clang Sep 21, 2024
@vitaut
Copy link
Contributor

vitaut commented Sep 22, 2024

What clang version do you use? Could you provide a godbolt repro?

@Khrysys
Copy link
Author

Khrysys commented Sep 22, 2024

Clang version is 14.0.0.14000029. The error does not come from my own code, but from fmt's src/format.cc. That's the reason why I opened this instead of debugging my own things.

@vitaut
Copy link
Contributor

vitaut commented Sep 22, 2024

clang 14 should support _BitInt: https://www.godbolt.org/z/bn7WaErG5. You might need to provide more repro details such as compiler flags.

@Arghnews
Copy link
Contributor

Arghnews commented Sep 23, 2024

My understanding: Apple clang is similar to but not the same as clang, and the version numbers while similar are apple's own. Ie. just because it works in llvm's clang 14 doesn't mean it will work in appleclang 14, as evidenced

Currently the _BitInt feature check is just

fmt/include/fmt/base.h

Lines 396 to 398 in 891c9a7

#ifndef FMT_USE_BITINT
# define FMT_USE_BITINT (FMT_CLANG_VERSION >= 1400)
#endif

so we could expand it to rule out appleclang 14. I happen to have a macbook with apple clang: Apple clang version 15.0.0 (clang-1500.1.0.2.5) and can confirm _BitInt works fine there. On godbolt clang 13 doesn't support it, so maybe it's only appleclang 14. I'll put in a PR if this seems reasonable

@Khrysys you should be able to get round this error by defining -DFMT_USE_BITINT=0 when building fmtlib to force _BitInt compilation to be disabled in the meantime.
I see you're adding via subdirectory, I think you can do

add_compile_definitions(DFMT_USE_BITINT=0)
add_subdirectory(fmt)

As I'm not certain if you can use target_compile_definitions on a target added via subdirectory (but that's nicer cmake if you can)

@Khrysys
Copy link
Author

Khrysys commented Sep 23, 2024

This seems like this should just be an easy, couple line PR then. I'll add that definition and see what happens when I get back home.

@vitaut
Copy link
Contributor

vitaut commented Sep 24, 2024

I think we can bump clang requirement to 15. It's a very niche feature anyway.

Arghnews added a commit to Arghnews/fmt that referenced this issue Sep 26, 2024
vitaut pushed a commit that referenced this issue Sep 26, 2024
@vitaut vitaut closed this as completed Sep 26, 2024
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

3 participants