Man did I open a can of worms when fixing GAS detection under Clang...

So, LLVM has a bug where the integrated assembler does not accept a syntax 
string with "prefix" or "noprefix" 
(https://llvm.org/bugs/show_bug.cgi?id=18916). So these cause a compile 
failure:

  * ".att_syntax prefix;"
  * ".att_syntax noprefix;"
  * ".intel_syntax prefix;"
  * ".intel_syntax noprefix;"

Below is the patch that fixes it. I also included one diff where the macro 
was applied, but it applies to all sources using GNU inline assembly.

Any comments or objections?

**********

$ git diff cpu.h
diff --git a/cpu.h b/cpu.h
index 3b258d8..115ed31 100644
--- a/cpu.h
+++ b/cpu.h
@@ -228,6 +228,18 @@ inline int GetCacheLineSize()
        #define AS_HEX(y) 0x##y
 #endif
 
+// https://llvm.org/bugs/show_bug.cgi?id=18916
+#if defined(__clang__)
+# define GNU_ATT_SYNTAX ".att_syntax;"
+# define GNU_INTEL_SYNTAX ".intel_syntax;"
+#elif defined(__GNUC__)
+# define GNU_ATT_SYNTAX ".att_syntax prefix;"
+# define GNU_INTEL_SYNTAX ".intel_syntax noprefix;"
+#else
+# define GNU_ATT_SYNTAX ".att_syntax prefix;"
+# define GNU_INTEL_SYNTAX ".intel_syntax noprefix;"
+#endif
+
 #define IF0(y)
 #define IF1(y) y
 
$ git diff vmac.cpp
diff --git a/vmac.cpp b/vmac.cpp
index 86d4b2e..cb78d4e 100644
--- a/vmac.cpp
+++ b/vmac.cpp
@@ -158,7 +158,7 @@ VMAC_Base::VHASH_Update_SSE2(const word64 *data, size_t 
bloc
        (
        AS2(    mov             %%ebx, %0)
        AS2(    mov             %1, %%ebx)
-       ".intel_syntax noprefix;"
+       GNU_INTEL_SYNTAX
 #else
        #if _MSC_VER < 1300 || defined(__INTEL_COMPILER)
        char isFirstBlock = m_isFirstBlock;
@@ -377,7 +377,7 @@ VMAC_Base::VHASH_Update_SSE2(const word64 *data, size_t 
bloc
        AS1(    pop             ebp)
        AS1(    emms)
 #ifdef __GNUC__
-       ".att_syntax prefix;"
+       GNU_ATT_SYNTAX
        AS2(    mov     %0, %%ebx)
                : "=m" (temp)
                : "m" (L1KeyLength), "c" (blocksRemainingInWord64), "S" 
(data), 

-- 
-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscr...@googlegroups.com.
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cryptopp-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to