From 7c591c6d2f6466f1adda6f85122098db327ad32e Mon Sep 17 00:00:00 2001 From: syd Date: Sat, 25 Nov 2017 10:58:37 -0500 Subject: [PATCH] Don't compile libgtest.a when building libsnark. Previously libsnark would try to build libgtest if /usr/src/gtest exists on the build machine. This caused issues because the version of libgtest in /usr/src isn't necessarily the same as the one that the rest of zcash's gtests were built with. --- src/Makefile.am | 2 +- src/snark/Makefile | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index ea745a1f7..48b60911a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,7 +46,7 @@ $(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*) collate-libsnark: $(LIBSNARK) LIBSNARK_CXXFLAGS = -fPIC -DBINARY_OUTPUT -DNO_PT_COMPRESSION=1 -LIBSNARK_CONFIG_FLAGS = CURVE=ALT_BN128 MULTICORE=1 NO_PROCPS=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT NO_COPY_DEPINST=1 +LIBSNARK_CONFIG_FLAGS = CURVE=ALT_BN128 MULTICORE=1 NO_PROCPS=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT NO_COPY_DEPINST=1 NO_COMPILE_LIBGTEST=1 $(LIBSNARK): $(wildcard snark/src/*) $(AM_V_at) CXXFLAGS="$(LIBSNARK_CXXFLAGS)" $(MAKE) $(AM_MAKEFLAGS) -C snark/ install PREFIX=$(srcdir)/build DEPINST="$(LIBSNARK_DEPINST)" $(LIBSNARK_CONFIG_FLAGS) OPTFLAGS="-O2 -march=x86-64" diff --git a/src/snark/Makefile b/src/snark/Makefile index cceffb989..32b8609f2 100644 --- a/src/snark/Makefile +++ b/src/snark/Makefile @@ -27,13 +27,13 @@ INSTALL_LIBS = $(LIB_FILE) # Sentinel file to check existence of this directory (since directories don't work as a Make dependency): DEPINST_EXISTS = $(DEPINST)/.exists - -COMPILE_GTEST := ifneq ($(NO_GTEST),1) - GTESTDIR=/usr/src/gtest -# Compile GTest from sourcecode if we can (e.g., Ubuntu). Otherwise use precompiled one (e.g., Fedora). -# See https://code.google.com/p/googletest/wiki/FAQ#Why_is_it_not_recommended_to_install_a_pre-compiled_copy_of_Goog . - COMPILE_GTEST :=$(shell test -d $(GTESTDIR) && echo -n 1) + # Compile GTest from sourcecode if we can (e.g., Ubuntu). Otherwise use precompiled one (e.g., Fedora). + # See https://github.com/google/googletest/blob/master/googletest/docs/FAQ.md#why-is-it-not-recommended-to-install-a-pre-compiled-copy-of-google-test-for-example-into-usrlocal + ifneq ($(NO_COMPILE_LIBGTEST),1) + GTESTDIR=/usr/src/gtest + COMPILE_LIBGTEST = $(shell test -d $(GTESTDIR) && echo -n 1) + endif GTEST_LDLIBS += -lgtest -lpthread endif @@ -221,13 +221,13 @@ src/gadgetlib2/tests/gadgetlib2_test: \ $(EXECUTABLES): %: %.o $(LIBSNARK_A) $(DEPINST_EXISTS) $(CXX) -o $@ $@.o $(LIBSNARK_A) $(CXXFLAGS) $(LDFLAGS) $(LDLIBS) -$(EXECUTABLES_WITH_GTEST): %: %.o $(LIBSNARK_A) $(if $(COMPILE_GTEST),$(LIBGTEST_A)) $(DEPINST_EXISTS) +$(EXECUTABLES_WITH_GTEST): %: %.o $(LIBSNARK_A) $(if $(COMPILE_LIBGTEST),$(LIBGTEST_A)) $(DEPINST_EXISTS) $(CXX) -o $@ $@.o $(LIBSNARK_A) $(CXXFLAGS) $(LDFLAGS) $(GTEST_LDLIBS) $(LDLIBS) $(EXECUTABLES_WITH_SUPERCOP): %: %.o $(LIBSNARK_A) $(DEPINST_EXISTS) $(CXX) -o $@ $@.o $(LIBSNARK_A) $(CXXFLAGS) $(LDFLAGS) $(SUPERCOP_LDLIBS) $(LDLIBS) -$(GTEST_TESTS): %: $(GTEST_OBJS) $(LIBSNARK_A) $(if $(COMPILE_GTEST),$(LIBGTEST_A)) $(DEPINST_EXISTS) +$(GTEST_TESTS): %: $(GTEST_OBJS) $(LIBSNARK_A) $(if $(COMPILE_LIBGTEST),$(LIBGTEST_A)) $(DEPINST_EXISTS) $(CXX) -o $@ $(GTEST_OBJS) $(LIBSNARK_A) $(CXXFLAGS) $(LDFLAGS) $(GTEST_LDLIBS) $(LDLIBS)