-
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
CRYPTOPP_DISABLE_ASM is broken in 8.9.0 for MSVC x64 builds #1240
Comments
…erting <weidai11/cryptopp@e65fa00>. git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@19809 56274372-70c3-4bfc-bfc3-4c3a0b034d27
In the long term, |
[Fix] Crypto++: Work-around <weidai11/cryptopp#1240> by partially reverting <weidai11/cryptopp@e65fa00>. ........ git-svn-id: https://source.openmpt.org/svn/openmpt/branches/OpenMPT-1.31@19810 56274372-70c3-4bfc-bfc3-4c3a0b034d27
I don't quite understand your use case. But looking at the comment that says, "XGETBV64 and CPUID64 are in x64dll.asm," I'm thinking it should be in |
CRYPTOPP_DISABLE_ASM claims to disable all assembler. x64dll.asm is assembler. Why do I suddenly need to teach my build system how to build asm files with Crypto++ 8.9.0? This was NOT the case in 8.8.0. This is a very obvious regression and in conflict with documentation of CRYPTOPP_DISABLE_ASM. |
That's not quite correct.
I think moving forward, I'm going to put XGETBV64 and CPUID64 in its own *.asm file to avoid both Now, when |
But feature detection did not required ASM with MSVC before.
I fail to see how that will help. The problem is requiring ASM at all, which was introduced by removing the use of the compiler intrinsics.
That might also be an option. Let me try to rephrase the problem I am complaining about here: There is currently no way at all disable the dependency of the C++ code on ASM code for MSVC x64. There was in 8.8.0, which used intrinsics instead of requiring ASM. Intrinsics are less of a problem because they are provided by the compiler itself and do not require build system adoption. |
How does this look to you: $ git diff
diff --git a/cpu.cpp b/cpu.cpp
index 44b57c4d..ff8c5cee 100644
--- a/cpu.cpp
+++ b/cpu.cpp
@@ -388,9 +388,14 @@ extern bool CPU_ProbeSSE2();
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85684.
word64 XGetBV(word32 num)
{
+// Explicitly handle CRYPTOPP_DISABLE_ASM case.^M
+// https://github.com/weidai11/cryptopp/issues/1240^M
+#if defined(CRYPTOPP_DISABLE_ASM)^M
+ return 0;^M
+^M
// Required by Visual Studio 2008 and below and Clang on Windows.
// Use it for all MSVC-compatible compilers.
-#if defined(_M_X64) && defined(CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY)
+#elif defined(_M_X64) && defined(CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY)^M
return XGETBV64(num);
@@ -446,9 +451,15 @@ word64 XGetBV(word32 num)
// cpu.cpp (131): E2211 Inline assembly not allowed in inline and template functions
bool CpuId(word32 func, word32 subfunc, word32 output[4])
{
+// Explicitly handle CRYPTOPP_DISABLE_ASM case.^M
+// https://github.com/weidai11/cryptopp/issues/1240^M
+#if defined(CRYPTOPP_DISABLE_ASM)^M
+ output[0] = output[1] = output[2] = output[3] = 0;^M
+ return false;^M
+^M
// Required by Visual Studio 2008 and below and Clang on Windows.
// Use it for all MSVC-compatible compilers.
-#if defined(_M_X64) && defined(CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY)
+#elif defined(_M_X64) && defined(CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY)^M
CPUID64(func, subfunc, output);
return true; A quick smoke test on Linux looks like it does nto break the compile, and the self tests pass. Looking at
|
… in effect (GH #1240) Some folks were defining CRYPTOPP_DISABLE_ASM and not building the *.asm files on WIndows. That happened to work until we refactored code for XGetBV and CpuId. These alternate build systems are going to be the death of us...
This should be cleared at Commit 121014baf0e8. |
Yeah, that certainly works for me. I still wonder why you prefer to keep only the ASM CPUID implementation even if the compiler supports intrinsics which do not require the use of an external assembler? It does not look like Crypto++ currently distinguish at a high level between using ASM or intrinsic implementations for its algorithms, but if it someday does, having the intrinsic CPUID implementation has clear advantages (i.e. not requiring tools other than the compiler itself). At a lower level there are more fine-grained macros (i.e. |
A single implementation is advantageous for maintenance. We no longer need to differentiate between versions of Visual Studio or GCC or Clang that added support for something. |
I somewhat doubt that adding a forced dependency on another build tool was advantageous for maintenance or for your users. It made Crypto++ impossible to build with solely a C++ compiler. |
I told you why we did it. You can take it or leave it. You happened to get lucky in the past with your practices. That broke at Crypto++ 8.9. That's what happens when you wander off the ranch, and start making up your own rules like not compiling or assembling certain source files. You're the cause of this problem, not the library. |
…dai11/cryptopp@121014baf0e8>. git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@19811 56274372-70c3-4bfc-bfc3-4c3a0b034d27
[Fix] Crypto++: Work-around <weidai11/cryptopp#1240> by applying <weidai11/cryptopp@121014baf0e8>. ........ git-svn-id: https://source.openmpt.org/svn/openmpt/branches/OpenMPT-1.31@19812 56274372-70c3-4bfc-bfc3-4c3a0b034d27
Your C++ library suddenly REQUIRING not only a C++ compiler but also an assembler is the root cause of the problem. This advertised feature was the single main reason for choosing Crypto++ at all in the first place for me. |
You have always needed a complete toolchain. We have never advertised you did not need one. You should probably switch to Botan or OpenSSL since you are so dissatisfied at the job we are doing. |
yeah ... so?! What am I misunderstanding here?! |
It looks like we're getting a fix for this... Just chill for a bit while @noloader is preparing it. |
... and I am already using it (see above / OpenMPT/openmpt@979aece) ...
As an Open Source maintainer myself I certainly know that. I still do not get why removing essential features (like not requiring additional tools over solely a C++ compiler) that your users have been relying upon for multiple years is something I should just swallow without complaining about. Pretty please revert 49fef81 - this decision IMHO needs far more discussion and approval from other contributors and users. |
Just making sure we're on the same page here... |
Yes, confirmed. I still take issue with the removed comment for |
My understanding is that the revised comment reflects the actual state of the implementation. How would you rephrase it? |
I would very much prefer if the implementation would stick to its historic promises, as it did in earlier versions. If Crypto++ really wants to start requiring building with an assembler, it fails to meet my requirements for a "C++ library". |
This will allow us to define CRYPTOPP_DISABLE_ASM and completely avoid building x64dll.asm and x64masm.asm
#define CRYPTOPP_DISABLE_ASM 1
does not disable all assembler / builtins / intrinsics (as documented here: https://github.com/weidai11/cryptopp/blob/CRYPTOPP_8_9_0/config_asm.h#L30).cpu.cpp
on x86-64 Windows MSVC builds still wantsCPUID64
andXGETBV64
which are only implemented inx64dll.asm
(seecryptopp/cpu.cpp
Line 451 in 843d74c
cryptopp/cpu.cpp
Line 393 in 843d74c
cryptopp/cpu.cpp
Line 81 in 843d74c
@noloader The offending commit is e65fa00 which removes the use of the MSVC-specific intrinsics for MSVC versions new enough to actually provide it. I suggest reverting the part of this commit that removes the use of
__cpuidex
and_xgetbv
.For OpenMPT, we are building Crypto++ with our own build system in which we define
CRYPTOPP_DISABLE_ASM 1
. This worked with 8.8.0, however it fails now with 8.9.0. Crypto++ is not performance critical in our case, thus we very much prefer a simple C++-only solution in order to keep the build system simple.We are using Crypto++ to secure our automatic updates on older Windows versions which do not provide the necessary crypto primitives themselves. In the failing case, we use VS2017 to target Windows XP.
The text was updated successfully, but these errors were encountered: