Skip to content

Commit

Permalink
darwin 333
Browse files Browse the repository at this point in the history
  • Loading branch information
ca333 committed Oct 22, 2017
1 parent db402e4 commit a2d7c03
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 9 deletions.
11 changes: 10 additions & 1 deletion depends/packages/boost.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ $(package)_config_opts_i686_linux=address-model=32 architecture=x86
$(package)_toolset_$(host_os)=gcc
$(package)_archiver_$(host_os)=$($(package)_ar)
$(package)_toolset_darwin=gcc
$(package)_archiver_darwin=$($(package)_ar)
$(package)_config_libraries=chrono,filesystem,program_options,system,thread,test
$(package)_cxxflags=-fvisibility=hidden
$(package)_cxxflags_linux=-fPIC
Expand All @@ -34,10 +35,18 @@ define $(package)_config_cmds
./bootstrap.sh --without-icu --with-libraries=$(boost_config_libraries)
endef

ifeq ($(host_os),linux)
define $(package)_build_cmds
./b2 -d2 -j2 -d1 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) cxxflags=-std=c++11 stage
endef

define $(package)_stage_cmds
./b2 -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) cxxflags=-std=c++11 install
endef
else
define $(package)_build_cmds
./b2 -d2 -j2 -d1 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) stage
endef
define $(package)_stage_cmds
./b2 -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) install
endef
endif
6 changes: 6 additions & 0 deletions depends/packages/libgmp.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ define $(package)_config_cmds
$($(package)_autoconf) --host=$(host) --build=$(build)
endef

ifeq ($(build_os),darwin)
define $(package)_build_cmds
$(MAKE)
endef
else
define $(package)_build_cmds
$(MAKE) CPPFLAGS='-fPIC'
endef
endif

define $(package)_stage_cmds
$(MAKE) DESTDIR=$($(package)_staging_dir) install ; echo '=== staging find for $(package):' ; find $($(package)_staging_dir)
Expand Down
13 changes: 7 additions & 6 deletions depends/packages/libsnark.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,24 @@ $(package)_git_commit=3854b20c25e8bc567aab2b558dec84d45f4a3e73
$(package)_dependencies=libgmp libsodium

ifeq ($(build_os),darwin)
define $(package)_set_vars
$(package)_build_env=CC="$($(package)_cc)" CXX="$($(package)_cxx)"
$(package)_build_env+=CXXFLAGS="$($(package)_cxxflags) -DBINARY_OUTPUT -DSTATICLIB -DNO_PT_COMPRESSION=1 "
endef
define $(package)_build_cmds
CC=gcc-5 CXX=g++-5 CXXFLAGS="-arch x86_64 -DBINARY_OUTPUT -DNO_PT_COMPRESSION=1" $(MAKE) lib DEPINST=$(host_prefix) CURVE=ALT_BN128 MULTICORE=0 NO_PROCPS=1 NO_GTEST=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT
$(MAKE) lib DEPINST=$(host_prefix) CURVE=ALT_BN128 MULTICORE=1 NO_PROCPS=1 NO_GTEST=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT OPTFLAGS="-O2 -march=x86-64"
endef
else ifeq ($(host_os),mingw32)
define $(package)_build_cmds
CXX="x86_64-w64-mingw32-g++-posix" CXXFLAGS="-DBINARY_OUTPUT -DPTW32_STATIC_LIB -DSTATICLIB -DNO_PT_COMPRESSION=1 -fopenmp" $(MAKE) lib DEPINST=$(host_prefix) CURVE=ALT_BN128 MULTICORE=1 NO_PROCPS=1 NO_GTEST=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT OPTFLAGS="-O2 -march=x86-64"
CXX="x86_64-w64-mingw32-g++-posix" CXXFLAGS="-DBINARY_OUTPUT -DPTW32_STATIC_LIB -DSTATICLIB -DNO_PT_COMPRESSION=1 -fopenmp" $(MAKE) lib DEPINST=$(host_prefix) CURVE=ALT_BN128 MULTICORE=1 NO_PROCPS=1 NO_GTEST=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT OPTFLAGS="-O2 -march=x86-64"
endef
else
define $(package)_build_cmds
CXXFLAGS="-fPIC -DBINARY_OUTPUT -DNO_PT_COMPRESSION=1" $(MAKE) lib DEPINST=$(host_prefix) CURVE=ALT_BN128 MULTICORE=1 NO_PROCPS=1 NO_GTEST=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT OPTFLAGS="-O2 -march=x86-64"
CXXFLAGS="-fPIC -DBINARY_OUTPUT -DNO_PT_COMPRESSION=1" $(MAKE) lib DEPINST=$(host_prefix) CURVE=ALT_BN128 MULTICORE=1 NO_PROCPS=1 NO_GTEST=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT OPTFLAGS="-O2 -march=x86-64"
endef
endif





define $(package)_stage_cmds
$(MAKE) install STATIC=1 DEPINST=$(host_prefix) PREFIX=$($(package)_staging_dir)$(host_prefix) CURVE=ALT_BN128 NO_SUPERCOP=1
endef
2 changes: 1 addition & 1 deletion depends/packages/packages.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
rust_packages := rust librustzcash
zcash_packages := libsnark libgmp libsodium

ifeq ($(build_os),linux)
ifeq ($(host_os),linux)
packages := boost openssl libevent zeromq $(zcash_packages) googletest googlemock
else
packages := boost openssl libevent zeromq $(zcash_packages) googletest googlemock libcurl
Expand Down
3 changes: 2 additions & 1 deletion src/crypto/equihash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <boost/optional.hpp>

/*
#ifdef __APPLE__
#include <machine/endian.h>
#include <libkern/OSByteOrder.h>
Expand All @@ -51,7 +52,7 @@
#define __LITTLE_ENDIAN LITTLE_ENDIAN
#define __BYTE_ORDER BYTE_ORDER
#endif

*/
EhSolverCancelledException solver_cancelled;

template<unsigned int N, unsigned int K>
Expand Down
25 changes: 25 additions & 0 deletions src/gtest/test_transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ TEST(Transaction, JSDescriptionRandomized) {
libzcash::JSOutput(addr, 50),
libzcash::JSOutput(addr, 50)
};
#ifdef __LP64__ // required for building on MacOS
boost::array<uint64_t, ZC_NUM_JS_INPUTS> inputMap;
boost::array<uint64_t, ZC_NUM_JS_OUTPUTS> outputMap;
#else
boost::array<size_t, ZC_NUM_JS_INPUTS> inputMap;
boost::array<size_t, ZC_NUM_JS_OUTPUTS> outputMap;
#endif

{
auto jsdesc = JSDescription::Randomized(
Expand All @@ -48,12 +53,22 @@ TEST(Transaction, JSDescriptionRandomized) {
inputMap, outputMap,
0, 0, false);

#ifdef __LP64__ // required for building on MacOS
std::set<uint64_t> inputSet(inputMap.begin(), inputMap.end());
std::set<uint64_t> expectedInputSet {0, 1};
#else
std::set<size_t> inputSet(inputMap.begin(), inputMap.end());
std::set<size_t> expectedInputSet {0, 1};
#endif
EXPECT_EQ(expectedInputSet, inputSet);

#ifdef __LP64__ // required for building on MacOS
std::set<uint64_t> outputSet(outputMap.begin(), outputMap.end());
std::set<uint64_t> expectedOutputSet {0, 1};
#else
std::set<size_t> outputSet(outputMap.begin(), outputMap.end());
std::set<size_t> expectedOutputSet {0, 1};
#endif
EXPECT_EQ(expectedOutputSet, outputSet);
}

Expand All @@ -64,8 +79,13 @@ TEST(Transaction, JSDescriptionRandomized) {
inputMap, outputMap,
0, 0, false, GenZero);

#ifdef __LP64__ // required for building on MacOS
boost::array<uint64_t, ZC_NUM_JS_INPUTS> expectedInputMap {1, 0};
boost::array<uint64_t, ZC_NUM_JS_OUTPUTS> expectedOutputMap {1, 0};
#else
boost::array<size_t, ZC_NUM_JS_INPUTS> expectedInputMap {1, 0};
boost::array<size_t, ZC_NUM_JS_OUTPUTS> expectedOutputMap {1, 0};
#endif
EXPECT_EQ(expectedInputMap, inputMap);
EXPECT_EQ(expectedOutputMap, outputMap);
}
Expand All @@ -77,8 +97,13 @@ TEST(Transaction, JSDescriptionRandomized) {
inputMap, outputMap,
0, 0, false, GenMax);

#ifdef __LP64__ // required for building on MacOS
boost::array<uint64_t, ZC_NUM_JS_INPUTS> expectedInputMap {0, 1};
boost::array<uint64_t, ZC_NUM_JS_OUTPUTS> expectedOutputMap {0, 1};
#else
boost::array<size_t, ZC_NUM_JS_INPUTS> expectedInputMap {0, 1};
boost::array<size_t, ZC_NUM_JS_OUTPUTS> expectedOutputMap {0, 1};
#endif
EXPECT_EQ(expectedInputMap, inputMap);
EXPECT_EQ(expectedOutputMap, outputMap);
}
Expand Down
3 changes: 3 additions & 0 deletions src/primitives/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
#include "serialize.h"
#include "uint256.h"
#include "consensus/consensus.h"

#ifndef __APPLE__
#include <stdint.h>
#endif

#include <boost/array.hpp>

Expand Down
1 change: 1 addition & 0 deletions user-config.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
using : : : <cxxflags>" " <linkflags>"" <archiver>"" <striper>"" <ranlib>"" <rc>"" : ;

0 comments on commit a2d7c03

Please sign in to comment.