-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
__GNUC__ isn't always defined #7318
Comments
I marked those two checks to check for |
For this specific case, another even better alternative would be using __has_builtin #if defined __has_builtin
# if __has_builtin (__builtin_ctz)
# define _trailing_zeros32(X) __builtin_ctz(X)
# endif
# if __has_builtin (__builtin_ctzll)
# define _trailing_zeros64(X) __builtin_ctzll(X)
# endif
#endif |
Naville
changed the title
__GNUC__ doesn't always imply __clang__ or __llvm__ defined
__GNUC__ isn't always defined
Aug 1, 2024
ping |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We're cross-compiling Z3 for Windows using MSVC Sysroot and clang-cl on Linux.
The compile steps are fine, but linking would fail due to
_tzcnt_u64
symbol not defined.I'm clueless with how MSVC works, so here are some educated assumptions:
From https://github.com/llvm/llvm-project/blob/07d2709a17860a202d91781769a88837e4fb5f2a/clang/lib/Frontend/InitPreprocessor.cpp#L868 we could see that while
__clang__
and__llvm__
are always defined, but__GNUC__
is only defined when building with GNU C Version specified, which is not the case when using Clang-CL.This results in the following Z3 code:
z3/src/util/mpz.cpp
Line 50 in 0c16d34
z3/src/util/mpz.cpp
Line 65 in 0c16d34
falls back to using
#define _trailing_zeros**(X) _tzcnt_u**(X)
Grepping through Windows SDK:
We can see that these two builtins are listed as an external function, which makes compilation success.
However without c1xx and c1.dll to lower those intrinsics calls, clang generates them to actual lib call, which fails in linking due to those functions only exists as intrinsics
The text was updated successfully, but these errors were encountered: