Bug 1642802 - Win64 GYP builds to use HACL* curve25519. r=bbeurdouche
authorKevin Jacobs <kjacobs@mozilla.com>
Mon, 08 Jun 2020 20:14:28 +0000
changeset 15657 566fa62d65225e98593e2caa58b592b2f1eeb4ba
parent 15656 5ee293d1a282abd28c0e0c27282420fe95d0340b
child 15658 238bd7912429145d5f3ec2442fb61bb0b5602dfc
push id3768
push userkjacobs@mozilla.com
push dateMon, 08 Jun 2020 20:15:48 +0000
reviewersbbeurdouche
bugs1642802
Bug 1642802 - Win64 GYP builds to use HACL* curve25519. r=bbeurdouche This patch causes Windows 64-bit GYP builds to use HACL* curve25519 rather than the 32-bit (fiat-crypto) implementation. For non-clang/GCC Win64 builds, we define `KRML_VERIFIED_UINT128` to workaround an upstream bug that breaks Win32 builds by selecting a 64-bit `__int128` implementation (in types.h). For clang/GCC builds, using the compiler-provided type yields a ~5x speedup on Win64. Differential Revision: https://phabricator.services.mozilla.com/D78549
lib/freebl/freebl.gyp
lib/freebl/freebl_base.gypi
--- a/lib/freebl/freebl.gyp
+++ b/lib/freebl/freebl.gyp
@@ -649,17 +649,19 @@
         ],
       }],
       [ 'cc_use_gnu_ld==1 and OS=="win" and target_arch=="x64"', {
         # mingw x64
         'defines': [
           'MP_IS_LITTLE_ENDIAN',
          ],
       }],
-      [ 'have_int128_support==1', {
+      # MSVC has no __int128 type. Use emulated int128 and leave
+      # have_int128_support as-is for Curve25519 impl. selection.
+      [ 'have_int128_support==1 and (OS!="win" or cc_is_clang==1 or cc_is_gcc==1)', {
         'defines': [
           # The Makefile does version-tests on GCC, but we're not doing that here.
           'HAVE_INT128_SUPPORT',
         ],
       }, {
         'defines': [
           'KRML_VERIFIED_UINT128',
         ],
@@ -717,24 +719,18 @@
           }],
         ],
       }],
     ],
   },
   'variables': {
     'module': 'nss',
     'conditions': [
-      [ 'OS!="win"', {
-        'conditions': [
-          [ 'target_arch=="x64" or target_arch=="arm64" or target_arch=="aarch64"', {
-            'have_int128_support%': 1,
-          }, {
-            'have_int128_support%': 0,
-          }],
-        ],
+      [ 'target_arch=="x64" or target_arch=="arm64" or target_arch=="aarch64"', {
+        'have_int128_support%': 1,
       }, {
         'have_int128_support%': 0,
       }],
       [ 'target_arch=="arm"', {
         # When the compiler uses the softfloat ABI, we want to use the compatible softfp ABI when enabling NEON for these objects.
         # Confusingly, __SOFTFP__ is the name of the define for the softfloat ABI, not for the softfp ABI.
         'softfp_cflags': '<!(${CC:-cc} -o - -E -dM - ${CFLAGS} < /dev/null | grep __SOFTFP__ > /dev/null && echo -mfloat-abi=softfp || true)',
       }],
--- a/lib/freebl/freebl_base.gypi
+++ b/lib/freebl/freebl_base.gypi
@@ -126,18 +126,17 @@
         [ 'cc_is_clang!=1', {
           # MSVC
           'sources': [
             'intel-gcm-wrap.c',
           ],
         }],
       ],
     }],
-    ['have_int128_support==1 and \
-      (target_arch=="x64" or target_arch=="arm64" or target_arch=="aarch64")', {
+    ['have_int128_support==1', {
       'sources': [
         # All intel x64 and 64-bit ARM architectures get the 64 bit version.
         'ecl/curve25519_64.c',
         'verified/Hacl_Curve25519_51.c',
       ],
     }, {
       'sources': [
         # All other architectures get the generic 32 bit implementation.