Commit efc9b9f3 authored by Kevin Jacobs's avatar Kevin Jacobs

Bug 1548398 - Add freebl_gtest to nss.gyp, fix freebl_gtest cross-compilation...

Bug 1548398 - Add freebl_gtest to nss.gyp, fix freebl_gtest cross-compilation and gcc-4.8 support. r=jcj

Updated gyp files to add -msse2 GCC option, iff the compiler is gcc and target is x64 or ia32.

Root cause for the 4.8 failure is a gcc bug where the "#pragma GCC target("sse2")" option used in gcm.h doesn't work when compiling C++ code, as the gtests do.

Differential Revision: https://phabricator.services.mozilla.com/D29886

--HG--
extra : moz-landing-system : lando
parent b48f0086
...@@ -5,17 +5,18 @@ import subprocess ...@@ -5,17 +5,18 @@ import subprocess
import sys import sys
def main(): def main():
if sys.platform == 'win32': if sys.platform == 'win32' or len(sys.argv) < 2:
print(0) print(0)
else: else:
cc = os.environ.get('CC', 'cc') cc = os.environ.get('CC', 'cc')
try: try:
cc_is_clang = 'clang' in subprocess.check_output( cc_is_arg = sys.argv[1] in subprocess.check_output(
[cc, '--version'], universal_newlines=True) [cc, '--version'], universal_newlines=True)
except OSError: except OSError:
# We probably just don't have CC/cc. # We probably just don't have CC/cc.
cc_is_clang = False cc_is_arg = False
print(int(cc_is_clang)) print(int(cc_is_arg))
if __name__ == '__main__': if __name__ == '__main__':
main() main()
...@@ -64,10 +64,15 @@ ...@@ -64,10 +64,15 @@
], ],
}], }],
['"<(GENERATOR)"=="ninja"', { ['"<(GENERATOR)"=="ninja"', {
'cc_is_clang%': '<!(<(python) <(DEPTH)/coreconf/check_cc_clang.py)', 'cc_is_clang%': '<!(<(python) <(DEPTH)/coreconf/check_cc.py clang)',
}, { }, {
'cc_is_clang%': '0', 'cc_is_clang%': '0',
}], }],
['"<(GENERATOR)"=="ninja"', {
'cc_is_gcc%': '<!(<(python) <(DEPTH)/coreconf/check_cc.py gcc)',
}, {
'cc_is_gcc%': '0',
}],
], ],
}, },
# Copy conditionally-set variables out one scope. # Copy conditionally-set variables out one scope.
...@@ -86,6 +91,7 @@ ...@@ -86,6 +91,7 @@
'dll_suffix': '<(dll_suffix)', 'dll_suffix': '<(dll_suffix)',
'freebl_name': '<(freebl_name)', 'freebl_name': '<(freebl_name)',
'cc_is_clang%': '<(cc_is_clang)', 'cc_is_clang%': '<(cc_is_clang)',
'cc_is_gcc%': '<(cc_is_gcc)',
'cc_use_gnu_ld%': '<(cc_use_gnu_ld)', 'cc_use_gnu_ld%': '<(cc_use_gnu_ld)',
# Some defaults # Some defaults
'disable_tests%': 0, 'disable_tests%': 0,
......
...@@ -40,6 +40,13 @@ ...@@ -40,6 +40,13 @@
'freebl_gtest_deps', 'freebl_gtest_deps',
'<(DEPTH)/exports.gyp:nss_exports', '<(DEPTH)/exports.gyp:nss_exports',
], ],
'conditions': [
[ 'cc_is_gcc==1 and (target_arch=="ia32" or target_arch=="x64")', {
'cflags_cc': [
'-msse2',
],
}],
],
}, },
{ {
'target_name': 'prng_gtest', 'target_name': 'prng_gtest',
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <memory>
#ifdef __MACH__ #ifdef __MACH__
#include <mach/clock.h> #include <mach/clock.h>
...@@ -27,7 +28,7 @@ void gettime(struct timespec* tp) { ...@@ -27,7 +28,7 @@ void gettime(struct timespec* tp) {
tp->tv_sec = mts.tv_sec; tp->tv_sec = mts.tv_sec;
tp->tv_nsec = mts.tv_nsec; tp->tv_nsec = mts.tv_nsec;
#else #else
clock_gettime(CLOCK_MONOTONIC, tp); ASSERT_NE(0, timespec_get(tp, TIME_UTC));
#endif #endif
} }
...@@ -84,8 +85,9 @@ class MPITest : public ::testing::Test { ...@@ -84,8 +85,9 @@ class MPITest : public ::testing::Test {
mp_int a; mp_int a;
ASSERT_EQ(MP_OKAY, mp_init(&a)); ASSERT_EQ(MP_OKAY, mp_init(&a));
ASSERT_EQ(MP_OKAY, mp_read_unsigned_octets(&a, ref.data(), ref.size())); ASSERT_EQ(MP_OKAY, mp_read_unsigned_octets(&a, ref.data(), ref.size()));
uint8_t buf[len]; std::unique_ptr<uint8_t[]> buf(new uint8_t[len]);
ASSERT_EQ(MP_OKAY, mp_to_fixlen_octets(&a, buf, len)); ASSERT_NE(buf, nullptr);
ASSERT_EQ(MP_OKAY, mp_to_fixlen_octets(&a, buf.get(), len));
size_t compare; size_t compare;
if (len > ref.size()) { if (len > ref.size()) {
for (size_t i = 0; i < len - ref.size(); ++i) { for (size_t i = 0; i < len - ref.size(); ++i) {
...@@ -96,9 +98,9 @@ class MPITest : public ::testing::Test { ...@@ -96,9 +98,9 @@ class MPITest : public ::testing::Test {
compare = len; compare = len;
} }
dump("value", ref.data(), ref.size()); dump("value", ref.data(), ref.size());
dump("output", buf, len); dump("output", buf.get(), len);
ASSERT_EQ(0, memcmp(buf + len - compare, ref.data() + ref.size() - compare, ASSERT_EQ(0, memcmp(buf.get() + len - compare,
compare)) ref.data() + ref.size() - compare, compare))
<< "comparing " << compare << " octets"; << "comparing " << compare << " octets";
mp_clear(&a); mp_clear(&a);
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <stdint.h> #include <stdint.h>
#include <memory>
#include "blapi.h" #include "blapi.h"
#include "secitem.h" #include "secitem.h"
......
...@@ -198,6 +198,7 @@ ...@@ -198,6 +198,7 @@
'gtests/certdb_gtest/certdb_gtest.gyp:certdb_gtest', 'gtests/certdb_gtest/certdb_gtest.gyp:certdb_gtest',
'gtests/freebl_gtest/freebl_gtest.gyp:prng_gtest', 'gtests/freebl_gtest/freebl_gtest.gyp:prng_gtest',
'gtests/freebl_gtest/freebl_gtest.gyp:blake2b_gtest', 'gtests/freebl_gtest/freebl_gtest.gyp:blake2b_gtest',
'gtests/freebl_gtest/freebl_gtest.gyp:freebl_gtest',
'gtests/mozpkix_gtest/mozpkix_gtest.gyp:mozpkix_gtest', 'gtests/mozpkix_gtest/mozpkix_gtest.gyp:mozpkix_gtest',
'gtests/nss_bogo_shim/nss_bogo_shim.gyp:nss_bogo_shim', 'gtests/nss_bogo_shim/nss_bogo_shim.gyp:nss_bogo_shim',
'gtests/pk11_gtest/pk11_gtest.gyp:pk11_gtest', 'gtests/pk11_gtest/pk11_gtest.gyp:pk11_gtest',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment