-
Notifications
You must be signed in to change notification settings - Fork 2.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
changed detection of Intel Compiler Classic to distinguish MS-Windows #2510
changed detection of Intel Compiler Classic to distinguish MS-Windows #2510
Conversation
__ICL is only defined on Windows, __INTEL_COMPILER on all platforms. I verified this myself, but you can read about it here. |
include/fmt/core.h
Outdated
#if defined(__INTEL_COMPILER) | ||
#ifdef __ICL | ||
# define FMT_ICC_VERSION __ICL | ||
# define FMT_ICC_ON_WINDOWS 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest replacing FMT_ICC_ON_WINDOWS
with FMT_ICC_POSIX
defined to 1 on non-Windows platforms. This will simplify the checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with me.
include/fmt/format.h
Outdated
# pragma managed(push, off) | ||
# if !defined(__ICL) | ||
# pragma managed(push, off) | ||
# endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove #pragma managed
completely as we don't support managed extensions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So done. Please have a look.
include/fmt/format.h
Outdated
#if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_ctz) || FMT_ICC_VERSION) && \ | ||
FMT_ICC_POSIX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can simplify this to just
#if FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_ctz) || FMT_ICC_POSIX
and similarly below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately not.
FMT_HAS_BUILTIN(__builtin_ctz) and FMT_HAS_BUILTIN(__builtin_ctzll) evaluate true on the Intel Classic 2021, and using those intrinsics compiles just fine, but results in linker errors. I think that's a bug in the compiler.
include/fmt/core.h
Outdated
#else | ||
# define FMT_ICC_VERSION 0 | ||
# define FMT_ICC_POSIX 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is FMT_ICC_POSIX
equal to 1 for other compilers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are making a good point. It is misleading. But it makes sure the intrinsic detection still works here for other compilers:
Lines 168 to 169 in 17fb5de
#if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_ctz) || FMT_ICC_VERSION) && \ | |
FMT_ICC_POSIX |
Since this is essentially a work around for a compiler bug, perhaps we should introduce something like FMT_ICC_BUILTIN_CTZ_BUG to be crystal clear about it?
… about the macro's purpose
I have renamed the macro to make the intend clear. It's a work around for a compiler bug. |
Thank you. Please report the compiler bug to Intel. |
…fmtlib#2510) * changed detection of Intel Compiler Classic to distinguish MS-Windows * replaced !FMT_ICC_ON_WINDOWS by FMT_ICC_POSIX removed #pragma manged * replaced FMT_ICC_POSIX with FMT_ICC_INTRINSIC_BUG to be crystal clear about the macro's purpose
…fmtlib#2510) * changed detection of Intel Compiler Classic to distinguish MS-Windows * replaced !FMT_ICC_ON_WINDOWS by FMT_ICC_POSIX removed #pragma manged * replaced FMT_ICC_POSIX with FMT_ICC_INTRINSIC_BUG to be crystal clear about the macro's purpose
The Intel Compiler Classic on MS-Windows doesn't have the intrinsics "__builtin_ctz" nor "__builtin_ctzll". Instead, it emulates MSVC. Unfortunately, "__has_builtin" works for version 2021, but results in a linker error nonetheless.
This pull request changes the detection of these intrinsics accordingly.
I also took the liberty to remove it from format.h, because it was already defined in core.h.
The Intel compiler also doesn't know "#pragma managed(push/pop", so I guarded those as well to get rid of the resulting warnings.
Best Regards,
Mathias