]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
ext: build equix and hashx using automake
authorMicah Elizabeth Scott <beth@torproject.org>
Fri, 10 Mar 2023 03:33:41 +0000 (19:33 -0800)
committerMicah Elizabeth Scott <beth@torproject.org>
Wed, 10 May 2023 14:38:28 +0000 (07:38 -0700)
This replaces the sketchy cmake invocation we had inside configure

The libs are always built and always used in unit tests, but only
included in libtor and tor when --enable-gpl is set.

Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
.gitignore
Makefile.am
configure.ac
src/ext/equix/.gitmodules [deleted file]
src/ext/equix/build.sh [deleted file]
src/ext/equix/hashx/.gitignore [deleted file]
src/ext/include.am

index 737ab72bf50bb0ad8ad233d1501208e09786b0b9..94988ed9825c3c62eccaab20c73acdc1b51c19ad 100644 (file)
@@ -152,7 +152,6 @@ core.*
 # /src/ext/
 /src/ext/ed25519/ref10/libed25519_ref10.lib
 /src/ext/ed25519/donna/libed25519_donna.lib
-/src/ext/equix/build
 /src/ext/keccak-tiny/libkeccak-tiny.lib
 
 # /src/app
index 28a1c8e57d7405db5b68854f43a73078d82bdafa..21f71e2e054a164939462a9468fd077a78f0f086 100644 (file)
@@ -114,6 +114,10 @@ TOR_CRYPTO_LIBS = \
        $(LIBKECCAK_TINY) \
        $(LIBDONNA)
 
+if BUILD_MODULE_POW
+TOR_CRYPTO_LIBS += $(EQUIX_LIBS)
+endif
+
 # Variants of the above for linking the testing variant of tor (for coverage
 # and tests)
 if UNITTESTS_ENABLED
@@ -121,13 +125,10 @@ TOR_CRYPTO_TESTING_LIBS = \
        src/lib/libtor-tls-testing.a \
        src/lib/libtor-crypt-ops-testing.a \
        $(LIBKECCAK_TINY) \
-       $(LIBDONNA)
+       $(LIBDONNA) \
+       $(EQUIX_LIBS)
 endif
 
-EQUIX_LIBS = \
-  src/ext/equix/build/libequix.a \
-  src/ext/equix/build/hashx/libhashx.a
-
 # All static libraries used to link tor.
 TOR_INTERNAL_LIBS = \
        src/core/libtor-app.a \
@@ -136,8 +137,7 @@ TOR_INTERNAL_LIBS = \
        $(TOR_CRYPTO_LIBS) \
        $(TOR_UTIL_LIBS) \
        src/trunnel/libor-trunnel.a \
-       src/lib/libtor-trace.a \
-       $(EQUIX_LIBS)
+       src/lib/libtor-trace.a
 
 libtor.a: $(TOR_INTERNAL_LIBS)
        $(AM_V_AR) export AR="$(AR)"; \
@@ -157,8 +157,7 @@ TOR_INTERNAL_TESTING_LIBS = \
        $(TOR_CRYPTO_TESTING_LIBS) \
        $(TOR_UTIL_TESTING_LIBS) \
        src/trunnel/libor-trunnel-testing.a \
-       src/lib/libtor-trace.a \
-       $(EQUIX_LIBS)
+       src/lib/libtor-trace.a
 
 src/test/libtor-testing.a: $(TOR_INTERNAL_TESTING_LIBS)
        $(AM_V_AR) export AR="$(AR)"; \
index 2b20965d68fe67b3e32dc7f82b86075ce7f7d5ff..7f01e5b0765a13e7424a9ee5cb5360ccb04bf8fd 100644 (file)
@@ -31,8 +31,6 @@ tor_incr_n_warnings() {
   tor_ac_n_warnings=`expr $tor_ac_n_warnings + 1`
 }
 
-AC_CONFIG_COMMANDS([equix], [./src/ext/equix/build.sh])
-
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 AC_CONFIG_HEADERS([orconfig.h])
 
@@ -2602,6 +2600,17 @@ if test "$enable_coverage" = "yes" && test "$have_clang" = "no"; then
    esac
 fi
 
+# These HashX parameter definitions are needed in CPPFLAGS when compiling
+# the equix and hashx ext modules, but elsewhere in tor we can use orconfig.h
+
+m4_define([equix_hashx_size], [8])
+[HASHX_SIZE=]equix_hashx_size
+AC_SUBST([HASHX_SIZE])
+AC_DEFINE([HASHX_SIZE], equix_hashx_size,
+          [Output size in bytes for the internal customization of HashX])
+AC_DEFINE([HASHX_STATIC], [1], [We statically link with HashX])
+AC_DEFINE([EQUIX_STATIC], [1], [We statically link with EquiX])
+
 CPPFLAGS="$CPPFLAGS $TOR_CPPFLAGS_libevent $TOR_CPPFLAGS_openssl $TOR_CPPFLAGS_zlib"
 
 AC_CONFIG_FILES([
diff --git a/src/ext/equix/.gitmodules b/src/ext/equix/.gitmodules
deleted file mode 100644 (file)
index 6f1277e..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "hashx"]
-       path = hashx
-       url = https://github.com/tevador/hashx
diff --git a/src/ext/equix/build.sh b/src/ext/equix/build.sh
deleted file mode 100755 (executable)
index 753e3a1..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-cd ./src/ext/equix
-mkdir build
-cd build
-cmake ..
-make
diff --git a/src/ext/equix/hashx/.gitignore b/src/ext/equix/hashx/.gitignore
deleted file mode 100644 (file)
index ec94c2c..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-bin/
-obj/
-*.user
-*.suo
-.vs
-x64/
-Release/
-Debug/
-build/
index dea8e4419b026bd95aeb1289b65796c937899b50..dad6a592b7bf8305cb288ade94885dd109b75186 100644 (file)
@@ -1,14 +1,8 @@
 
 AM_CPPFLAGS += \
   -I$(srcdir)/src/ext/ \
-  -I$(srcdir)/src/ext/equix/include/ \
   -I$(srcdir)/src/ext/equix/hashx/include/
 
-# TODO: put this with other equix/hashx ext defs when those happen,
-# and also add it to the autoconf config header. For now this is here
-# just for test_crypto's benefit.
-AM_CPPFLAGS += -DHASHX_SIZE=8
-
 EXTRA_DIST += src/ext/ext.md
 
 EXTHEADERS = \
@@ -152,6 +146,60 @@ noinst_HEADERS += $(ED25519_DONNA_HDRS)
 LIBED25519_DONNA=src/ext/ed25519/donna/libed25519_donna.a
 noinst_LIBRARIES += $(LIBED25519_DONNA)
 
+src_ext_equix_libhashx_a_CPPFLAGS = \
+       -I$(srcdir)/src/ext/equix/hashx/include/ \
+       -I$(srcdir)/src/ext/equix/hashx/src/ \
+       -DHASHX_SIZE=@HASHX_SIZE@ \
+       -DEQUIX_STATIC=1 -DHASHX_STATIC=1
+
+src_ext_equix_libhashx_a_SOURCES = \
+       src/ext/equix/hashx/src/blake2.c \
+       src/ext/equix/hashx/src/compiler.c \
+       src/ext/equix/hashx/src/compiler_a64.c \
+       src/ext/equix/hashx/src/compiler_x86.c \
+       src/ext/equix/hashx/src/context.c \
+       src/ext/equix/hashx/src/hashx.c \
+       src/ext/equix/hashx/src/program.c \
+       src/ext/equix/hashx/src/program_exec.c \
+       src/ext/equix/hashx/src/siphash.c \
+       src/ext/equix/hashx/src/siphash_rng.c \
+       src/ext/equix/hashx/src/virtual_memory.c
+
+src_ext_equix_libequix_a_CPPFLAGS = \
+       -I$(srcdir)/src/ext/equix/include/ \
+       -I$(srcdir)/src/ext/equix/src/ \
+       $(src_ext_equix_libhashx_a_CPPFLAGS)
+
+src_ext_equix_libequix_a_SOURCES = \
+       src/ext/equix/src/context.c \
+       src/ext/equix/src/equix.c \
+       src/ext/equix/src/solver.c
+
+EQUIX_HDRS = \
+       src/ext/equix/hashx/include/hashx.h \
+       src/ext/equix/hashx/src/blake2.h \
+       src/ext/equix/hashx/src/compiler.h \
+       src/ext/equix/hashx/src/context.h \
+       src/ext/equix/hashx/src/force_inline.h \
+       src/ext/equix/hashx/src/hashx_endian.h \
+       src/ext/equix/hashx/src/instruction.h \
+       src/ext/equix/hashx/src/program.h \
+       src/ext/equix/hashx/src/siphash_rng.h \
+       src/ext/equix/hashx/src/siphash.h \
+       src/ext/equix/hashx/src/unreachable.h \
+       src/ext/equix/hashx/src/virtual_memory.h \
+       src/ext/equix/include/equix.h \
+       src/ext/equix/src/context.h \
+       src/ext/equix/src/solver_heap.h \
+       src/ext/equix/src/solver.h
+
+EQUIX_LIBS = \
+    src/ext/equix/libhashx.a \
+    src/ext/equix/libequix.a
+
+noinst_HEADERS += $(EQUIX_HDRS)
+noinst_LIBRARIES += $(EQUIX_LIBS)
+
 if BUILD_KECCAK_TINY
 src_ext_keccak_tiny_libkeccak_tiny_a_CFLAGS=\
   @CFLAGS_CONSTTIME@