Skip to content

Commit bb79184

Browse files
committed
Build secp256k1 as an external
Bundle our secp256k1 library as an external. This removes one external dependency (making it a little easier for packaging and future updates), makes the build of secp256k1 use same compiler & flags as the main applications, and fixes a bug where the configure script on macOS wasn’t enabling x86_64 asm operations.
1 parent 05d5aee commit bb79184

11 files changed

+3
-291
lines changed

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ if ("${OPENSSL_ROOT_DIR}" STREQUAL "")
7474
endif()
7575
endif()
7676

77-
find_package(Secp256k1 REQUIRED)
78-
7977
if(UNIX)
8078
if(APPLE)
8179
set(whole_archive_flag "-force_load")

CMakeModules/EosioTester.cmake.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ find_library(liboscrypto crypto @OPENSSL_ROOT_DIR@/lib)
5959
find_library(libosssl ssl @OPENSSL_ROOT_DIR@/lib)
6060
find_library(libchainbase chainbase @CMAKE_INSTALL_FULL_LIBDIR@)
6161
find_library(libbuiltins builtins @CMAKE_INSTALL_FULL_LIBDIR@)
62-
find_library(libsecp256k1 secp256k1 @Secp256k1_ROOT_DIR@/lib)
6362

6463
macro(add_eosio_test test_name)
6564
add_executable( ${test_name} ${ARGN} )

CMakeModules/EosioTesterBuild.cmake.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ find_library(liboscrypto crypto @OPENSSL_ROOT_DIR@/lib)
5959
find_library(libosssl ssl @OPENSSL_ROOT_DIR@/lib)
6060
find_library(libchainbase chainbase @CMAKE_BINARY_DIR@/libraries/chainbase)
6161
find_library(libbuiltins builtins @CMAKE_BINARY_DIR@/libraries/builtins)
62-
find_library(libsecp256k1 secp256k1 @Secp256k1_ROOT_DIR@/lib)
6362

6463
macro(add_eosio_test test_name)
6564
add_executable( ${test_name} ${ARGN} )

Docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ARG symbol=SYS
55
RUN git clone -b $branch https://github.com/EOSIO/eos.git --recursive \
66
&& cd eos && echo "$branch:$(git rev-parse HEAD)" > /etc/eosio-version \
77
&& cmake -H. -B"/tmp/build" -GNinja -DCMAKE_BUILD_TYPE=Release -DWASM_ROOT=/opt/wasm -DCMAKE_CXX_COMPILER=clang++ \
8-
-DCMAKE_C_COMPILER=clang -DCMAKE_INSTALL_PREFIX=/tmp/build -DSecp256k1_ROOT_DIR=/usr/local -DBUILD_MONGO_DB_PLUGIN=true -DCORE_SYMBOL_NAME=$symbol \
8+
-DCMAKE_C_COMPILER=clang -DCMAKE_INSTALL_PREFIX=/tmp/build -DBUILD_MONGO_DB_PLUGIN=true -DCORE_SYMBOL_NAME=$symbol \
99
&& cmake --build /tmp/build --target install && rm /tmp/build/bin/eosiocpp
1010

1111

Docker/dev/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ARG symbol=SYS
55
RUN git clone -b $branch https://github.com/EOSIO/eos.git --recursive \
66
&& cd eos && echo "$branch:$(git rev-parse HEAD)" > /etc/eosio-version \
77
&& cmake -H. -B"/opt/eosio" -GNinja -DCMAKE_BUILD_TYPE=Release -DWASM_ROOT=/opt/wasm -DCMAKE_CXX_COMPILER=clang++ \
8-
-DCMAKE_C_COMPILER=clang -DCMAKE_INSTALL_PREFIX=/opt/eosio -DSecp256k1_ROOT_DIR=/usr/local -DBUILD_MONGO_DB_PLUGIN=true -DCORE_SYMBOL_NAME=$symbol \
8+
-DCMAKE_C_COMPILER=clang -DCMAKE_INSTALL_PREFIX=/opt/eosio -DBUILD_MONGO_DB_PLUGIN=true -DCORE_SYMBOL_NAME=$symbol \
99
&& cmake --build /opt/eosio --target install \
1010
&& cp /eos/Docker/config.ini / && ln -s /opt/eosio/contracts /contracts && cp /eos/Docker/nodeosd.sh /opt/eosio/bin/nodeosd.sh && ln -s /eos/tutorials /tutorials
1111

scripts/eosio_build_amazon.sh

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -528,63 +528,6 @@ fi
528528
printf "\\tMongo C++ driver found at /usr/local/lib64/libmongocxx-static.a.\\n"
529529
fi
530530

531-
printf "\\n\\tChecking secp256k1-zkp installation.\\n"
532-
# install secp256k1-zkp (Cryptonomex branch)
533-
if [ ! -e "/usr/local/lib/libsecp256k1.a" ]; then
534-
printf "\\tInstalling secp256k1-zkp (Cryptonomex branch).\\n"
535-
if ! cd "${TEMP_DIR}"
536-
then
537-
printf "\\n\\tUnable to enter directory %s.\\n" "${TEMP_DIR}"
538-
printf "\\n\\tExiting now.\\n"
539-
exit 1;
540-
fi
541-
if ! git clone https://github.com/cryptonomex/secp256k1-zkp.git
542-
then
543-
printf "\\tUnable to clone repo secp256k1-zkp @ https://github.com/cryptonomex/secp256k1-zkp.git.\\n"
544-
printf "\\tExiting now.\\n\\n"
545-
exit 1;
546-
fi
547-
if ! cd "${TEMP_DIR}/secp256k1-zkp"
548-
then
549-
printf "\\n\\tUnable to cd into directory %s/secp256k1-zkp.\\n" "${TEMP_DIR}"
550-
printf "\\n\\tExiting now.\\n"
551-
exit 1;
552-
fi
553-
if ! ./autogen.sh
554-
then
555-
printf "\\tError running autogen for secp256k1-zkp.\\n"
556-
printf "\\tExiting now.\\n\\n"
557-
exit 1;
558-
fi
559-
if ! ./configure
560-
then
561-
printf "\\tError running configure for secp256k1-zkp.\\n"
562-
printf "\\tExiting now.\\n\\n"
563-
exit 1;
564-
fi
565-
if ! make -j"${JOBS}"
566-
then
567-
printf "\\tError compiling secp256k1-zkp.\\n"
568-
printf "\\tExiting now.\\n\\n"
569-
exit 1;
570-
fi
571-
if ! sudo make install
572-
then
573-
printf "\\tError installing secp256k1-zkp.\\n"
574-
printf "\\tExiting now.\\n\\n"
575-
exit 1;
576-
fi
577-
if ! rm -rf "${TEMP_DIR}/secp256k1-zkp"
578-
then
579-
printf "\\tError removing directory %s/secp256k1-zkp.\\n" "${TEMP_DIR}"
580-
printf "\\tExiting now.\\n\\n"
581-
exit 1;
582-
fi
583-
printf "\\tsecp256k1 successfully installed @ /usr/local/lib/libsecp256k1.a.\\n"
584-
else
585-
printf "\\tsecp256k1 found @ /usr/local/lib/libsecp256k1.a.\\n"
586-
fi
587-
588531
printf "\\n\\tChecking LLVM with WASM support.\\n"
589532
if [ ! -d "${HOME}/opt/wasm/bin" ]; then
590533
printf "\\tInstalling LLVM & WASM.\\n"

scripts/eosio_build_centos.sh

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -618,63 +618,6 @@ mongodconf
618618
printf "\\tMongo C++ driver found at /usr/local/lib64/libmongocxx-static.a.\\n"
619619
fi
620620

621-
printf "\\n\\tChecking secp256k1-zkp installation.\\n"
622-
# install secp256k1-zkp (Cryptonomex branch)
623-
if [ ! -e "/usr/local/lib/libsecp256k1.a" ]; then
624-
printf "\\tInstalling secp256k1-zkp (Cryptonomex branch).\\n"
625-
if ! cd "${TEMP_DIR}"
626-
then
627-
printf "\\n\\tUnable to enter directory %s.\\n" "${TEMP_DIR}"
628-
printf "\\n\\tExiting now.\\n"
629-
exit 1;
630-
fi
631-
if ! git clone https://github.com/cryptonomex/secp256k1-zkp.git
632-
then
633-
printf "\\tUnable to clone repo secp256k1-zkp @ https://github.com/cryptonomex/secp256k1-zkp.git.\\n"
634-
printf "\\tExiting now.\\n\\n"
635-
exit 1;
636-
fi
637-
if ! cd "${TEMP_DIR}/secp256k1-zkp"
638-
then
639-
printf "\\n\\tUnable to cd into directory %s/secp256k1-zkp.\\n" "${TEMP_DIR}"
640-
printf "\\n\\tExiting now.\\n"
641-
exit 1;
642-
fi
643-
if ! ./autogen.sh
644-
then
645-
printf "\\tError running autogen for secp256k1-zkp.\\n"
646-
printf "\\tExiting now.\\n\\n"
647-
exit 1;
648-
fi
649-
if ! ./configure
650-
then
651-
printf "\\tError running configure for secp256k1-zkp.\\n"
652-
printf "\\tExiting now.\\n\\n"
653-
exit 1;
654-
fi
655-
if ! make -j"${JOBS}"
656-
then
657-
printf "\\tError compiling secp256k1-zkp.\\n"
658-
printf "\\tExiting now.\\n\\n"
659-
exit 1;
660-
fi
661-
if ! sudo make install
662-
then
663-
printf "\\tError installing secp256k1-zkp.\\n"
664-
printf "\\tExiting now.\\n\\n"
665-
exit 1;
666-
fi
667-
if ! rm -rf "${TEMP_DIR}/secp256k1-zkp"
668-
then
669-
printf "\\tError removing directory %s/secp256k1-zkp.\\n" "${TEMP_DIR}"
670-
printf "\\tExiting now.\\n\\n"
671-
exit 1;
672-
fi
673-
printf "\\n\\tsecp256k1 successfully installed @ /usr/local/lib.\\n\\n"
674-
else
675-
printf "\\tsecp256k1 found @ /usr/local/lib.\\n"
676-
fi
677-
678621
printf "\\n\\tChecking LLVM with WASM support installation.\\n"
679622
if [ ! -d "${HOME}/opt/wasm/bin" ]; then
680623
printf "\\n\\tInstalling LLVM with WASM\\n"

scripts/eosio_build_darwin.sh

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -396,62 +396,6 @@
396396
printf "\\tMongo C++ driver found at /usr/local/lib/libmongocxx-static.a.\\n"
397397
fi
398398

399-
printf "\\n\\tChecking secp256k1-zkp installation.\\n"
400-
# install secp256k1-zkp (Cryptonomex branch)
401-
if [ ! -e "/usr/local/lib/libsecp256k1.a" ]; then
402-
if ! cd "${TEMP_DIR}"
403-
then
404-
printf "\\tUnable to enter directory %s.\\n" "${TEMP_DIR}"
405-
printf "\\tExiting now.\\n\\n"
406-
exit 1;
407-
fi
408-
if ! git clone https://github.com/cryptonomex/secp256k1-zkp.git
409-
then
410-
printf "\\tUnable to clone repo secp256k1-zkp @ https://github.com/cryptonomex/secp256k1-zkp.git.\\n"
411-
printf "\\tExiting now.\\n\\n"
412-
exit 1;
413-
fi
414-
if ! cd "${TEMP_DIR}/secp256k1-zkp"
415-
then
416-
printf "\\tUnable to enter directory %s/secp256k1-zkp.\\n" "${TEMP_DIR}"
417-
printf "\\tExiting now.\\n\\n"
418-
exit 1;
419-
fi
420-
if ! ./autogen.sh
421-
then
422-
printf "\\tError running autogen.\\n"
423-
printf "\\tExiting now.\\n\\n"
424-
exit 1;
425-
fi
426-
if ! ./configure
427-
then
428-
printf "\\tConfiguring secp256k1-zkp has returned the above error.\\n"
429-
printf "\\tExiting now.\\n\\n"
430-
exit 1;
431-
fi
432-
if ! make -j"${CPU_CORE}"
433-
then
434-
printf "\\tError compiling secp256k1-zkp.\\n"
435-
printf "\\tExiting now.\\n\\n"
436-
exit 1;
437-
fi
438-
if ! sudo make install
439-
then
440-
printf "\\tInstalling secp256k1-zkp has returned the above error.\\n"
441-
printf "\\tExiting now.\\n\\n"
442-
exit 1;
443-
fi
444-
if ! rm -rf "${TEMP_DIR}/secp256k1-zkp"
445-
then
446-
printf "\\tUnable to remove directory %s/secp256k1-zkp56k1-zkp.\\n" "${TEMP_DIR}"
447-
printf "\\tExiting now.\\n\\n"
448-
exit 1;
449-
fi
450-
printf "\\n\\n\\tSuccessffully installed secp256k1 @ /usr/local/lib/.\\n\\n"
451-
else
452-
printf "\\tsecp256k1 found at /usr/local/lib/.\\n"
453-
fi
454-
455399
printf "\\n\\tChecking LLVM with WASM support.\\n"
456400
if [ ! -d /usr/local/wasm/bin ]; then
457401
if ! cd "${TEMP_DIR}"

scripts/eosio_build_fedora.sh

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -393,63 +393,6 @@
393393
printf "\\tMongo C++ driver found at /usr/local/lib64/libmongocxx-static.a.\\n"
394394
fi
395395

396-
printf "\\n\\tChecking secp256k1-zkp installation.\\n"
397-
# install secp256k1-zkp (Cryptonomex branch)
398-
if [ ! -e "/usr/local/lib/libsecp256k1.a" ]; then
399-
printf "\\tInstalling secp256k1-zkp (Cryptonomex branch).\\n"
400-
if ! cd "${TEMP_DIR}"
401-
then
402-
printf "\\n\\tUnable to cd into directory %s.\\n" "${TEMP_DIR}"
403-
printf "\\n\\tExiting now.\\n"
404-
exit 1;
405-
fi
406-
if ! git clone https://github.com/cryptonomex/secp256k1-zkp.git
407-
then
408-
printf "\\tUnable to clone repo secp256k1-zkp @ https://github.com/cryptonomex/secp256k1-zkp.git.\\n"
409-
printf "\\tExiting now.\\n\\n"
410-
exit 1;
411-
fi
412-
if ! cd "${TEMP_DIR}/secp256k1-zkp"
413-
then
414-
printf "\\n\\tUnable to cd into directory %s.\\n" "${TEMP_DIR}/secp256k1-zkp"
415-
printf "\\n\\tExiting now.\\n"
416-
exit 1;
417-
fi
418-
if ! ./autogen.sh
419-
then
420-
printf "\\tError running autogen for secp256k1-zkp.\\n"
421-
printf "\\tExiting now.\\n\\n"
422-
exit 1;
423-
fi
424-
if ! ./configure
425-
then
426-
printf "\\tError running configure for secp256k1-zkp.\\n"
427-
printf "\\tExiting now.\\n\\n"
428-
exit 1;
429-
fi
430-
if ! make -j"${JOBS}"
431-
then
432-
printf "\\tError compiling secp256k1-zkp.\\n"
433-
printf "\\tExiting now.\\n\\n"
434-
exit 1;
435-
fi
436-
if ! sudo make install
437-
then
438-
printf "\\tError installing secp256k1-zkp.\\n"
439-
printf "\\tExiting now.\\n\\n"
440-
exit 1;
441-
fi
442-
if ! rm -rf "${TEMP_DIR}/secp256k1-zkp"
443-
then
444-
printf "\\tError removing directory %s.\\n" "${TEMP_DIR}/secp256k1-zkp"
445-
printf "\\tExiting now.\\n\\n"
446-
exit 1;
447-
fi
448-
printf "\\n\\tsecp256k1 successfully installed @ /usr/local/lib.\\n\\n"
449-
else
450-
printf "\\tsecp256k1 found @ /usr/local/lib.\\n"
451-
fi
452-
453396
printf "\\n\\tChecking LLVM with WASM support installation.\\n"
454397
if [ ! -d "${HOME}/opt/wasm/bin" ]; then
455398
printf "\\tInstalling LLVM & WASM\\n"

scripts/eosio_build_ubuntu.sh

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -421,63 +421,6 @@ mongodconf
421421
printf "\\tMongo C++ driver found at /usr/local/lib/libmongocxx-static.a.\\n"
422422
fi
423423

424-
printf "\\n\\tChecking secp256k1-zkp installation.\\n"
425-
# install secp256k1-zkp (Cryptonomex branch)
426-
if [ ! -e "/usr/local/lib/libsecp256k1.a" ]; then
427-
printf "\\tInstalling secp256k1-zkp (Cryptonomex branch).\\n"
428-
if ! cd "${TEMP_DIR}"
429-
then
430-
printf "\\n\\tUnable to cd into directory %s.\\n" "${TEMP_DIR}"
431-
printf "\\n\\tExiting now.\\n"
432-
exit 1;
433-
fi
434-
if ! git clone https://github.com/cryptonomex/secp256k1-zkp.git
435-
then
436-
printf "\\tUnable to clone repo secp256k1-zkp @ https://github.com/cryptonomex/secp256k1-zkp.git.\\n"
437-
printf "\\tExiting now.\\n\\n"
438-
exit 1;
439-
fi
440-
if ! cd "${TEMP_DIR}/secp256k1-zkp"
441-
then
442-
printf "\\n\\tUnable to cd into directory %s.\\n" "${TEMP_DIR}/secp256k1-zkp"
443-
printf "\\n\\tExiting now.\\n"
444-
exit 1;
445-
fi
446-
if ! ./autogen.sh
447-
then
448-
printf "\\tError running autogen for secp256k1-zkp.\\n"
449-
printf "\\tExiting now.\\n\\n"
450-
exit 1;
451-
fi
452-
if ! ./configure
453-
then
454-
printf "\\tError running configure for secp256k1-zkp.\\n"
455-
printf "\\tExiting now.\\n\\n"
456-
exit 1;
457-
fi
458-
if ! make -j"${JOBS}"
459-
then
460-
printf "\\tError compiling secp256k1-zkp.\\n"
461-
printf "\\tExiting now.\\n\\n"
462-
exit 1;
463-
fi
464-
if ! sudo make install
465-
then
466-
printf "\\tError installing secp256k1-zkp.\\n"
467-
printf "\\tExiting now.\\n\\n"
468-
exit 1;
469-
fi
470-
if ! rm -rf "${TEMP_DIR}/secp256k1-zkp"
471-
then
472-
printf "\\tError removing directory %s.\\n" "${TEMP_DIR}/secp256k1-zkp"
473-
printf "\\tExiting now.\\n\\n"
474-
exit 1;
475-
fi
476-
printf "\\n\\tsecp256k1 successfully installed @ /usr/local/lib.\\n\\n"
477-
else
478-
printf "\\tsecp256k1 found @ /usr/local/lib.\\n"
479-
fi
480-
481424
printf "\\n\\tChecking for LLVM with WASM support.\\n"
482425
if [ ! -d "${HOME}/opt/wasm/bin" ]; then
483426
# Build LLVM and clang with WASM support:

0 commit comments

Comments
 (0)