From 728e9372bb5feb867b494c7c5572b47c4d089f47 Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Tue, 17 Dec 2013 14:28:14 -0500 Subject: [PATCH 1/8] makefile: increase portability Fix bogus use 'g++'. On some systems 'g++' is more correctly spelled 'g++48' or the like. --- Build-gcc/makefile | 20 ++++++++++---------- Build-gcc/subdir.mk | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Build-gcc/makefile b/Build-gcc/makefile index 684687e..4b934c4 100644 --- a/Build-gcc/makefile +++ b/Build-gcc/makefile @@ -45,36 +45,36 @@ all: libzerocoin test tutorial # Tool invocations libzerocoin: $(OBJS) $(USER_OBJS) @echo 'Building target: $@' - @echo 'Invoking: Cross G++ Linker' - g++ -fopenmp -L/opt/local/lib -shared -o "libzerocoin.so" $(OBJS) $(USER_OBJS) $(LIBS) + @echo 'Invoking: Cross ${CXX} Linker' + ${CXX} -fopenmp -L/opt/local/lib -shared -o "libzerocoin.so" $(OBJS) $(USER_OBJS) $(LIBS) @echo 'Finished building target: $@' @echo ' ' test: $(OBJS) $(USER_OBJS) @echo 'Building target: $@' - @echo 'Invoking: Cross G++ Linker' - g++ -fopenmp -L/opt/local/lib -o "tests" ../Tests.cpp $(OBJS) $(USER_OBJS) $(LIBS) + @echo 'Invoking: Cross ${CXX} Linker' + ${CXX} -fopenmp -L/opt/local/lib -o "tests" ../Tests.cpp $(OBJS) $(USER_OBJS) $(LIBS) @echo 'Finished building target: $@' @echo ' ' paramgen: $(OBJS) $(USER_OBJS) @echo 'Building target: $@' - @echo 'Invoking: Cross G++ Linker' - g++ -fopenmp -L/opt/local/lib -o "paramgen" ../paramgen.cpp $(OBJS) $(USER_OBJS) $(LIBS) + @echo 'Invoking: Cross ${CXX} Linker' + ${CXX} -fopenmp -L/opt/local/lib -o "paramgen" ../paramgen.cpp $(OBJS) $(USER_OBJS) $(LIBS) @echo 'Finished building target: $@' @echo ' ' benchmark: $(OBJS) $(USER_OBJS) @echo 'Building target: $@' - @echo 'Invoking: Cross G++ Linker' - g++ -fopenmp -L/opt/local/lib -o "benchmark" ../Benchmark.cpp $(OBJS) $(USER_OBJS) $(LIBS) + @echo 'Invoking: Cross ${CXX} Linker' + ${CXX} -fopenmp -L/opt/local/lib -o "benchmark" ../Benchmark.cpp $(OBJS) $(USER_OBJS) $(LIBS) @echo 'Finished building target: $@' @echo ' ' tutorial: $(OBJS) $(USER_OBJS) @echo 'Building target: $@' - @echo 'Invoking: Cross G++ Linker' - g++ -fopenmp -L/opt/local/lib -o "tutorial" ../Tutorial.cpp $(OBJS) $(USER_OBJS) $(LIBS) + @echo 'Invoking: Cross ${CXX} Linker' + ${CXX} -fopenmp -L/opt/local/lib -o "tutorial" ../Tutorial.cpp $(OBJS) $(USER_OBJS) $(LIBS) @echo 'Finished building target: $@' @echo ' ' diff --git a/Build-gcc/subdir.mk b/Build-gcc/subdir.mk index c18b53f..4dd1fb3 100644 --- a/Build-gcc/subdir.mk +++ b/Build-gcc/subdir.mk @@ -40,7 +40,7 @@ CPP_DEPS += \ %.o: ../%.cpp @echo 'Building file: $<' @echo 'Invoking: Cross G++ Compiler' - g++ -fopenmp -g -L/opt/local/lib -I/opt/local/include -g -Wall -fpic -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" + ${CXX} -fopenmp -g -L/opt/local/lib -I/opt/local/include -g -Wall -fpic -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" @echo 'Finished building: $<' @echo ' ' From 80ee0b1543b9783bd6b944e5a1bc3b5f925e04c4 Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Tue, 17 Dec 2013 14:29:41 -0500 Subject: [PATCH 2/8] makefile: fix build boost no longer uses the 'mt' suffix. --- Build-gcc/objects.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build-gcc/objects.mk b/Build-gcc/objects.mk index 02799e3..90d640b 100644 --- a/Build-gcc/objects.mk +++ b/Build-gcc/objects.mk @@ -4,5 +4,5 @@ USER_OBJS := -LIBS := -I/opt/local/include -lboost_system-mt -lcrypto +LIBS := -I/opt/local/include -lboost_system -lcrypto From b482652ec947557a7d20d563189106a1a6491419 Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Tue, 17 Dec 2013 14:34:03 -0500 Subject: [PATCH 3/8] makefile: remove chatty messages make(1) is already chatty for you. You can even make it more verbose. Adding manual echo lines is pointless. --- Build-gcc/makefile | 21 --------------------- Build-gcc/subdir.mk | 4 ---- 2 files changed, 25 deletions(-) diff --git a/Build-gcc/makefile b/Build-gcc/makefile index 4b934c4..a793529 100644 --- a/Build-gcc/makefile +++ b/Build-gcc/makefile @@ -44,44 +44,23 @@ all: libzerocoin test tutorial # Tool invocations libzerocoin: $(OBJS) $(USER_OBJS) - @echo 'Building target: $@' - @echo 'Invoking: Cross ${CXX} Linker' ${CXX} -fopenmp -L/opt/local/lib -shared -o "libzerocoin.so" $(OBJS) $(USER_OBJS) $(LIBS) - @echo 'Finished building target: $@' - @echo ' ' test: $(OBJS) $(USER_OBJS) - @echo 'Building target: $@' - @echo 'Invoking: Cross ${CXX} Linker' ${CXX} -fopenmp -L/opt/local/lib -o "tests" ../Tests.cpp $(OBJS) $(USER_OBJS) $(LIBS) - @echo 'Finished building target: $@' - @echo ' ' paramgen: $(OBJS) $(USER_OBJS) - @echo 'Building target: $@' - @echo 'Invoking: Cross ${CXX} Linker' ${CXX} -fopenmp -L/opt/local/lib -o "paramgen" ../paramgen.cpp $(OBJS) $(USER_OBJS) $(LIBS) - @echo 'Finished building target: $@' - @echo ' ' benchmark: $(OBJS) $(USER_OBJS) - @echo 'Building target: $@' - @echo 'Invoking: Cross ${CXX} Linker' ${CXX} -fopenmp -L/opt/local/lib -o "benchmark" ../Benchmark.cpp $(OBJS) $(USER_OBJS) $(LIBS) - @echo 'Finished building target: $@' - @echo ' ' tutorial: $(OBJS) $(USER_OBJS) - @echo 'Building target: $@' - @echo 'Invoking: Cross ${CXX} Linker' ${CXX} -fopenmp -L/opt/local/lib -o "tutorial" ../Tutorial.cpp $(OBJS) $(USER_OBJS) $(LIBS) - @echo 'Finished building target: $@' - @echo ' ' # Other Targets clean: -$(RM) $(C++_DEPS)$(OBJS)$(C_DEPS)$(CC_DEPS)$(LIBRARIES)$(CPP_DEPS)$(CXX_DEPS)$(C_UPPER_DEPS) libzerocoin.so tests benchmark paramgen - -@echo ' ' .PHONY: all clean dependents .SECONDARY: diff --git a/Build-gcc/subdir.mk b/Build-gcc/subdir.mk index 4dd1fb3..6cf779e 100644 --- a/Build-gcc/subdir.mk +++ b/Build-gcc/subdir.mk @@ -38,10 +38,6 @@ CPP_DEPS += \ # Each subdirectory must supply rules for building sources it contributes %.o: ../%.cpp - @echo 'Building file: $<' - @echo 'Invoking: Cross G++ Compiler' ${CXX} -fopenmp -g -L/opt/local/lib -I/opt/local/include -g -Wall -fpic -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" - @echo 'Finished building: $<' - @echo ' ' From c34b1dec46f35308d2b8fbed1bb95ff4ae5e4d33 Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Tue, 17 Dec 2013 14:38:44 -0500 Subject: [PATCH 4/8] makefile: Fix toolchain invocations Most users expect CXXFLAGS and LDFLAGS to be used. --- Build-gcc/makefile | 15 ++++++++++----- Build-gcc/subdir.mk | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Build-gcc/makefile b/Build-gcc/makefile index a793529..cd1bb07 100644 --- a/Build-gcc/makefile +++ b/Build-gcc/makefile @@ -12,6 +12,11 @@ RM := rm -include subdir.mk -include objects.mk +DEBUG_FLAGS= -g +CXXFLAGS= -fopenmp -I/opt/local/include -I/usr/local/include -Wall -fpic +LDFLAGS= -L /opt/local/lib -L /usr/local/lib + + ifneq ($(MAKECMDGOALS),clean) ifneq ($(strip $(C++_DEPS)),) -include $(C++_DEPS) @@ -44,19 +49,19 @@ all: libzerocoin test tutorial # Tool invocations libzerocoin: $(OBJS) $(USER_OBJS) - ${CXX} -fopenmp -L/opt/local/lib -shared -o "libzerocoin.so" $(OBJS) $(USER_OBJS) $(LIBS) + ${CXX} ${LDFLAGS} -shared -o "libzerocoin.so" $(OBJS) $(USER_OBJS) $(LIBS) test: $(OBJS) $(USER_OBJS) - ${CXX} -fopenmp -L/opt/local/lib -o "tests" ../Tests.cpp $(OBJS) $(USER_OBJS) $(LIBS) + ${CXX} ${LDFLAGS} -o "tests" ../Tests.cpp $(OBJS) $(USER_OBJS) $(LIBS) paramgen: $(OBJS) $(USER_OBJS) - ${CXX} -fopenmp -L/opt/local/lib -o "paramgen" ../paramgen.cpp $(OBJS) $(USER_OBJS) $(LIBS) + ${CXX} ${LDFLAGS} -o "paramgen" ../paramgen.cpp $(OBJS) $(USER_OBJS) $(LIBS) benchmark: $(OBJS) $(USER_OBJS) - ${CXX} -fopenmp -L/opt/local/lib -o "benchmark" ../Benchmark.cpp $(OBJS) $(USER_OBJS) $(LIBS) + ${CXX} ${LDFLAGS} -o "benchmark" ../Benchmark.cpp $(OBJS) $(USER_OBJS) $(LIBS) tutorial: $(OBJS) $(USER_OBJS) - ${CXX} -fopenmp -L/opt/local/lib -o "tutorial" ../Tutorial.cpp $(OBJS) $(USER_OBJS) $(LIBS) + ${CXX} ${LDFLAGS} -o "tutorial" ../Tutorial.cpp $(OBJS) $(USER_OBJS) $(LIBS) # Other Targets clean: diff --git a/Build-gcc/subdir.mk b/Build-gcc/subdir.mk index 6cf779e..6e68ae7 100644 --- a/Build-gcc/subdir.mk +++ b/Build-gcc/subdir.mk @@ -38,6 +38,6 @@ CPP_DEPS += \ # Each subdirectory must supply rules for building sources it contributes %.o: ../%.cpp - ${CXX} -fopenmp -g -L/opt/local/lib -I/opt/local/include -g -Wall -fpic -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" + ${CXX} ${CXXFLAGS} ${DEBUG_FLAGS} -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" From 1a716317d4ac93d36365322074db45b34d9f17a4 Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Tue, 17 Dec 2013 14:40:14 -0500 Subject: [PATCH 5/8] makefile: don't rebuild libzerocoin.so if it already exists --- Build-gcc/makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Build-gcc/makefile b/Build-gcc/makefile index cd1bb07..85069b6 100644 --- a/Build-gcc/makefile +++ b/Build-gcc/makefile @@ -40,15 +40,15 @@ endif -include ../makefile.defs -.DEFAULT_GOAL := libzerocoin +.DEFAULT_GOAL := libzerocoin.so # Add inputs and outputs from these tool invocations to the build variables # All Target -all: libzerocoin test tutorial +all: libzerocoin.so test tutorial # Tool invocations -libzerocoin: $(OBJS) $(USER_OBJS) +libzerocoin.so: $(OBJS) $(USER_OBJS) ${CXX} ${LDFLAGS} -shared -o "libzerocoin.so" $(OBJS) $(USER_OBJS) $(LIBS) test: $(OBJS) $(USER_OBJS) From ef8cc7177fd2436d56eae92b2a7f800022bf8a52 Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Tue, 17 Dec 2013 14:40:40 -0500 Subject: [PATCH 6/8] makefile: don't fail make clean if no objects exist. rm -f is safe here :)) --- Build-gcc/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build-gcc/makefile b/Build-gcc/makefile index 85069b6..89c2222 100644 --- a/Build-gcc/makefile +++ b/Build-gcc/makefile @@ -65,7 +65,7 @@ tutorial: $(OBJS) $(USER_OBJS) # Other Targets clean: - -$(RM) $(C++_DEPS)$(OBJS)$(C_DEPS)$(CC_DEPS)$(LIBRARIES)$(CPP_DEPS)$(CXX_DEPS)$(C_UPPER_DEPS) libzerocoin.so tests benchmark paramgen + -$(RM) -f $(C++_DEPS)$(OBJS)$(C_DEPS)$(CC_DEPS)$(LIBRARIES)$(CPP_DEPS)$(CXX_DEPS)$(C_UPPER_DEPS) libzerocoin.so tests benchmark paramgen .PHONY: all clean dependents .SECONDARY: From 27a01674be86a3dd70fe0d7c8ebaa00d529c7827 Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Tue, 17 Dec 2013 14:43:06 -0500 Subject: [PATCH 7/8] bitcoin_bignum/serialize.h: duplicate declaration of insert function. Without this the C++ code could not compile: bitcoin_bignum/serialize.h:911:10: error: class member cannot be redeclared void insert(iterator it, std::vector::const_iterator first, std::vector::const_iterator last) ^ bitcoin_bignum/serialize.h:898:10: note: previous declaration is here void insert(iterator it, const_iterator first, const_iterator last) ^ --- bitcoin_bignum/serialize.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/bitcoin_bignum/serialize.h b/bitcoin_bignum/serialize.h index e3d9939..eac4e06 100644 --- a/bitcoin_bignum/serialize.h +++ b/bitcoin_bignum/serialize.h @@ -895,19 +895,6 @@ class CDataStream iterator insert(iterator it, const char& x=char()) { return vch.insert(it, x); } void insert(iterator it, size_type n, const char& x) { vch.insert(it, n, x); } - void insert(iterator it, const_iterator first, const_iterator last) - { - assert(last - first >= 0); - if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos) - { - // special case for inserting at the front when there's room - nReadPos -= (last - first); - memcpy(&vch[nReadPos], &first[0], last - first); - } - else - vch.insert(it, first, last); - } - void insert(iterator it, std::vector::const_iterator first, std::vector::const_iterator last) { assert(last - first >= 0); From 1c02078dd9b760f5308301b7b1d58f6bd92d4ae5 Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Tue, 17 Dec 2013 14:46:46 -0500 Subject: [PATCH 8/8] makefile: use c++11 The C++ code uses 'long long' which is a C++11 feature, so depend on it. --- Build-gcc/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build-gcc/makefile b/Build-gcc/makefile index 89c2222..5e8c05d 100644 --- a/Build-gcc/makefile +++ b/Build-gcc/makefile @@ -13,7 +13,7 @@ RM := rm -include objects.mk DEBUG_FLAGS= -g -CXXFLAGS= -fopenmp -I/opt/local/include -I/usr/local/include -Wall -fpic +CXXFLAGS= -std=c++11 -fopenmp -I/opt/local/include -I/usr/local/include -Wall -fpic LDFLAGS= -L /opt/local/lib -L /usr/local/lib