aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2018-06-05 10:31:15 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2018-06-05 10:31:15 +0800
commitc4c1d4c1fede91f9d3bcf0761a1d5215b3efd9b1 (patch)
tree43c8c344cc0a83b99361d87cdf3e6297a24da8a2
parentecc6ad34f27b0eb449c2b8031607a808505b09bb (diff)
downloadtangerine-mcl-c4c1d4c1fede91f9d3bcf0761a1d5215b3efd9b1.tar.gz
tangerine-mcl-c4c1d4c1fede91f9d3bcf0761a1d5215b3efd9b1.tar.zst
tangerine-mcl-c4c1d4c1fede91f9d3bcf0761a1d5215b3efd9b1.zip
test for clang
-rw-r--r--Makefile13
-rw-r--r--include/mcl/bn.h2
-rw-r--r--include/mcl/gmp_util.hpp2
-rw-r--r--include/mcl/op.hpp6
-rw-r--r--include/mcl/she.h2
-rw-r--r--include/mcl/vint.hpp2
6 files changed, 20 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 63adea4..445d842 100644
--- a/Makefile
+++ b/Makefile
@@ -280,9 +280,22 @@ she-wasm:
ecdsa-wasm:
$(MAKE) ../ecdsa-wasm/ecdsa_c.js
+# test
bin/emu:
$(CXX) -g -o $@ src/fp.cpp src/bn_c256.cpp test/bn_c256_test.cpp -DMCL_DONT_USE_XBYAK -DMCL_DONT_USE_OPENSSL -DMCL_USE_VINT -DMCL_SIZEOF_UNIT=8 -DMCL_VINT_64BIT_PORTABLE -DMCL_VINT_FIXED_BUFFER -DMCL_MAX_BIT_SIZE=256 -I./include -I../cybozulib/include
+# test
+CLANG_WASM=-DNDEBUG -DMCLSHE_WIN_SIZE=8 -DCYBOZU_MINIMUM_EXCEPTION
+CLANG_WASM+=-DMCL_SIZEOF_UNIT=8 -DMCL_MAX_BIT_SIZE=256
+CLANG_WASM+=-DCYBOZU_DONT_USE_EXCEPTION -DCYBOZU_DONT_USE_STRING -DMCL_DONT_USE_CSRPNG
+CLANG_WASM+=-O3 -Oz -target wasm32-wasm -fno-exceptions
+CLANG_WASM+=-Wall -Wextra
+CLANG_WASM+=-I./include -I../cybozulib/include -std=c++03
+mcl-wasm-clang:
+ clang++-6.0 -c -o bin/fp.o src/fp.cpp $(CLANG_WASM)
+ clang++-6.0 -c -o bin/bn_c256.o src/bn_c256.cpp $(CLANG_WASM)
+ wasm-ld-6.0 -o bin/mcl256.wasm bin/fp.o bin/bn_c256.o -no-entry --strip-all --allow-undefined
+
clean:
$(RM) $(MCL_LIB) $(MCL_SLIB) $(BN256_LIB) $(BN256_SLIB) $(BN384_LIB) $(BN384_SLIB) $(BN512_LIB) $(BN512_SLIB) $(SHE256_LIB) $(OBJ_DIR)/*.o $(OBJ_DIR)/*.d $(EXE_DIR)/*.exe $(GEN_EXE) $(ASM_OBJ) $(LIB_OBJ) $(BN256_OBJ) $(BN384_OBJ) $(BN512_OBJ) $(LLVM_SRC) $(FUNC_LIST) src/*.ll
diff --git a/include/mcl/bn.h b/include/mcl/bn.h
index f996d00..3072904 100644
--- a/include/mcl/bn.h
+++ b/include/mcl/bn.h
@@ -31,6 +31,8 @@
#endif
#elif defined(__EMSCRIPTEN__) && !defined(MCLBN_DONT_EXPORT)
#define MCLBN_DLL_API __attribute__((used))
+#elif defined(__wasm__) && !defined(MCLBN_DONT_EXPORT)
+ #define MCLBN_DLL_API __attribute__((visibility("default")))
#else
#define MCLBN_DLL_API
#endif
diff --git a/include/mcl/gmp_util.hpp b/include/mcl/gmp_util.hpp
index 6146b45..4ae95a3 100644
--- a/include/mcl/gmp_util.hpp
+++ b/include/mcl/gmp_util.hpp
@@ -21,7 +21,7 @@
#pragma warning(disable : 4512)
#pragma warning(disable : 4146)
#endif
-#ifdef __EMSCRIPTEN__
+#if defined(__EMSCRIPTEN__) || defined(__wasm__)
#define MCL_USE_VINT
#endif
#ifdef MCL_USE_VINT
diff --git a/include/mcl/op.hpp b/include/mcl/op.hpp
index 7e27821..690af16 100644
--- a/include/mcl/op.hpp
+++ b/include/mcl/op.hpp
@@ -13,7 +13,7 @@
#ifndef MCL_MAX_BIT_SIZE
#define MCL_MAX_BIT_SIZE 521
#endif
-#ifdef __EMSCRIPTEN__
+#if defined(__EMSCRIPTEN__) || defined(__wasm__)
#define MCL_DONT_USE_XBYAK
#define MCL_DONT_USE_OPENSSL
#endif
@@ -23,10 +23,6 @@
#define MCL_MAX_HASH_BIT_SIZE 512
-#if CYBOZU_CPP_VERSION >= CYBOZU_CPP_VERSION_CPP11
-#include <random>
-#endif
-
namespace mcl {
/*
diff --git a/include/mcl/she.h b/include/mcl/she.h
index d8f5514..2036719 100644
--- a/include/mcl/she.h
+++ b/include/mcl/she.h
@@ -26,6 +26,8 @@
#else
#ifdef __EMSCRIPTEN__
#define MCLSHE_DLL_API __attribute__((used))
+#elif defined(__wasm__)
+ #define MCLSHE_DLL_API __attribute__((visibility("default")))
#else
#define MCLSHE_DLL_API
#endif
diff --git a/include/mcl/vint.hpp b/include/mcl/vint.hpp
index ce8ceb6..92b2d22 100644
--- a/include/mcl/vint.hpp
+++ b/include/mcl/vint.hpp
@@ -14,7 +14,7 @@
#include <mcl/randgen.hpp>
#include <mcl/conversion.hpp>
-#ifdef __EMSCRIPTEN__
+#if defined(__EMSCRIPTEN__) || defined(__wasm__)
#define MCL_VINT_64BIT_PORTABLE
#define MCL_VINT_FIXED_BUFFER
#endif