From 8b4136bad571d970f67925966667436eac40e671 Mon Sep 17 00:00:00 2001 From: Jon Griffiths Date: Tue, 23 May 2023 08:38:35 +1200 Subject: [PATCH] build: remove gmp Core and secp have not used gmp for a very long time now (core disabled it in 2015). Signed-off-by: Jon Griffiths --- .github/scripts/build.sh | 10 ---------- .github/scripts/setup.sh | 3 +-- .github/workflows/bsd.yml | 1 - .github/workflows/macos.yaml | 2 +- Dockerfile | 7 ------- Makefile | 6 +++--- configure | 2 +- contrib/docker/Dockerfile.alpine | 1 - contrib/docker/Dockerfile.builder | 1 - contrib/docker/Dockerfile.builder.fedora | 1 - contrib/docker/Dockerfile.tester | 1 - contrib/docker/linuxarm32v7.Dockerfile | 7 ------- contrib/docker/linuxarm64v8.Dockerfile | 6 ------ contrib/docker/scripts/build.sh | 10 ---------- contrib/docker/scripts/setup.sh | 1 - contrib/reprobuild/Dockerfile.focal | 1 - contrib/reprobuild/Dockerfile.jammy | 1 - doc/INSTALL.md | 25 +++++++----------------- tools/headerversions.c | 14 ------------- tools/repro-build.sh | 10 +++------- 20 files changed, 16 insertions(+), 94 deletions(-) diff --git a/.github/scripts/build.sh b/.github/scripts/build.sh index eaab2b827..698c1c7f7 100755 --- a/.github/scripts/build.sh +++ b/.github/scripts/build.sh @@ -79,16 +79,6 @@ then rm sqlite-src-3260000.zip rm -rf sqlite-src-3260000 - wget -q https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz - tar xf gmp-6.1.2.tar.xz - cd gmp-6.1.2 || exit 1 - ./configure --disable-assembly --prefix="$QEMU_LD_PREFIX" --host="$TARGET_HOST" - make - sudo make install - cd .. - rm gmp-6.1.2.tar.xz - rm -rf gmp-6.1.2 - ./configure CC="$TARGET_HOST-gcc" --enable-static make -s -j32 CC="$TARGET_HOST-gcc" diff --git a/.github/scripts/setup.sh b/.github/scripts/setup.sh index 10a38791e..f81bb0ae1 100755 --- a/.github/scripts/setup.sh +++ b/.github/scripts/setup.sh @@ -24,7 +24,6 @@ sudo apt-get -qq install --no-install-recommends --allow-unauthenticated -yy \ git \ libc6-dev-arm64-cross \ libc6-dev-armhf-cross \ - libgmp-dev \ libpq-dev \ libprotobuf-c-dev \ libsqlite3-dev \ @@ -82,4 +81,4 @@ sudo chmod a+x /usr/local/bin/protoc export PROTOC=/usr/local/bin/protoc export PATH=$PATH:/usr/local/bin env -ls -lha /usr/local/bin \ No newline at end of file +ls -lha /usr/local/bin diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml index ebfb8830d..1f58ebac5 100644 --- a/.github/workflows/bsd.yml +++ b/.github/workflows/bsd.yml @@ -35,7 +35,6 @@ jobs: autoconf \ automake \ libtool \ - gmp \ bash \ gettext \ sqlite3 \ diff --git a/.github/workflows/macos.yaml b/.github/workflows/macos.yaml index 3457fd388..1969a381c 100644 --- a/.github/workflows/macos.yaml +++ b/.github/workflows/macos.yaml @@ -22,7 +22,7 @@ jobs: export PATH="/usr/local/opt:/Users/runner/.local/bin:/Users/runner/Library/Python/3.10/bin:$PATH" export BITCOIN_VERSION=24.1 - brew install wget autoconf automake libtool python@3.10 gmp gnu-sed gettext libsodium + brew install wget autoconf automake libtool python@3.10 gnu-sed gettext libsodium ( cd /tmp/ diff --git a/Dockerfile b/Dockerfile index 4cd3c6ae2..1af5d1595 100644 --- a/Dockerfile +++ b/Dockerfile @@ -86,13 +86,6 @@ RUN apt-get install -y --no-install-recommends unzip tclsh \ && make \ && make install && cd .. && rm sqlite-src-3290000.zip && rm -rf sqlite-src-3290000 -RUN wget -q https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz \ - && tar xvf gmp-6.1.2.tar.xz \ - && cd gmp-6.1.2 \ - && ./configure --disable-assembly \ - && make \ - && make install && cd .. && rm gmp-6.1.2.tar.xz && rm -rf gmp-6.1.2 - ENV RUST_PROFILE=release ENV PATH=$PATH:/root/.cargo/bin/ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y diff --git a/Makefile b/Makefile index eb26d515b..8e03c449a 100644 --- a/Makefile +++ b/Makefile @@ -258,11 +258,11 @@ LDFLAGS += $(PIE_LDFLAGS) $(CSANFLAGS) $(COPTFLAGS) ifeq ($(STATIC),1) # For MacOS, Jacob Rapoport changed this to: -# -L/usr/local/lib -Wl,-lgmp -lsqlite3 -lz -Wl,-lm -lpthread -ldl $(COVFLAGS) +# -L/usr/local/lib -lsqlite3 -lz -Wl,-lm -lpthread -ldl $(COVFLAGS) # But that doesn't static link. -LDLIBS = -L$(CPATH) -Wl,-dn -lgmp $(SQLITE3_LDLIBS) -lz -Wl,-dy -lm -lpthread -ldl $(COVFLAGS) +LDLIBS = -L$(CPATH) -Wl,-dn $(SQLITE3_LDLIBS) -lz -Wl,-dy -lm -lpthread -ldl $(COVFLAGS) else -LDLIBS = -L$(CPATH) -lm -lgmp $(SQLITE3_LDLIBS) -lz $(COVFLAGS) +LDLIBS = -L$(CPATH) -lm $(SQLITE3_LDLIBS) -lz $(COVFLAGS) endif # If we have the postgres client library we need to link against it as well diff --git a/configure b/configure index f3c537da6..52a4a4e86 100755 --- a/configure +++ b/configure @@ -202,7 +202,7 @@ usage() usage_with_default "--enable/disable-valgrind" "(autodetect)" echo " Run tests with Valgrind" usage_with_default "--enable/disable-static" "$STATIC" "enable" "disable" - echo " Static link sqlite3, gmp and zlib libraries" + echo " Static link sqlite3 and zlib libraries" usage_with_default "--enable/disable-address-sanitizer" "$ASAN" "enable" "disable" echo " Compile with address-sanitizer" usage_with_default "--enable/disable-ub-sanitizer" "$UBSAN" "enable" "disable" diff --git a/contrib/docker/Dockerfile.alpine b/contrib/docker/Dockerfile.alpine index 375de7faf..ddae6b2a1 100644 --- a/contrib/docker/Dockerfile.alpine +++ b/contrib/docker/Dockerfile.alpine @@ -12,7 +12,6 @@ RUN apk update && \ cargo \ gettext \ git \ - gmp-dev \ libsodium \ libtool \ net-tools \ diff --git a/contrib/docker/Dockerfile.builder b/contrib/docker/Dockerfile.builder index 26e3be204..2c717a907 100644 --- a/contrib/docker/Dockerfile.builder +++ b/contrib/docker/Dockerfile.builder @@ -22,7 +22,6 @@ RUN apt-get -qq update && \ libtool \ libprotobuf-c-dev \ libsqlite3-dev \ - libgmp-dev \ git \ python3 \ valgrind \ diff --git a/contrib/docker/Dockerfile.builder.fedora b/contrib/docker/Dockerfile.builder.fedora index 4a43c033e..f5fe4d420 100644 --- a/contrib/docker/Dockerfile.builder.fedora +++ b/contrib/docker/Dockerfile.builder.fedora @@ -9,7 +9,6 @@ RUN dnf update -y && \ 'Development Tools' && \ dnf install -y \ clang \ - gmp-devel \ libsq3-devel \ python3-devel \ python3-mako \ diff --git a/contrib/docker/Dockerfile.tester b/contrib/docker/Dockerfile.tester index 3b1e47b3e..6da1aad54 100644 --- a/contrib/docker/Dockerfile.tester +++ b/contrib/docker/Dockerfile.tester @@ -27,7 +27,6 @@ RUN apt-get -qq update && \ git \ libc6-dev-arm64-cross \ libc6-dev-armhf-cross \ - libgmp-dev \ libpq-dev \ libprotobuf-c-dev \ libsqlite3-dev \ diff --git a/contrib/docker/linuxarm32v7.Dockerfile b/contrib/docker/linuxarm32v7.Dockerfile index 8bea5cbfa..918d1d9b1 100644 --- a/contrib/docker/linuxarm32v7.Dockerfile +++ b/contrib/docker/linuxarm32v7.Dockerfile @@ -101,13 +101,6 @@ RUN apt-get install -y --no-install-recommends unzip tclsh \ && make \ && make install && cd .. && rm sqlite-src-3290000.zip && rm -rf sqlite-src-3290000 -RUN wget -q https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz \ -&& tar xvf gmp-6.1.2.tar.xz \ -&& cd gmp-6.1.2 \ -&& ./configure --disable-assembly --prefix=$QEMU_LD_PREFIX --host=${target_host} \ -&& make \ -&& make install && cd .. && rm gmp-6.1.2.tar.xz && rm -rf gmp-6.1.2 - COPY --from=downloader /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static WORKDIR /opt/lightningd COPY . /tmp/lightning diff --git a/contrib/docker/linuxarm64v8.Dockerfile b/contrib/docker/linuxarm64v8.Dockerfile index 79f3ed8ba..160120db4 100644 --- a/contrib/docker/linuxarm64v8.Dockerfile +++ b/contrib/docker/linuxarm64v8.Dockerfile @@ -102,12 +102,6 @@ RUN apt-get install -y --no-install-recommends unzip tclsh \ && make \ && make install && cd .. && rm sqlite-src-3290000.zip && rm -rf sqlite-src-3290000 -RUN wget -q https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz \ -&& tar xvf gmp-6.1.2.tar.xz \ -&& cd gmp-6.1.2 \ -&& ./configure --disable-assembly --prefix=$QEMU_LD_PREFIX --host=${target_host} \ -&& make \ -&& make install && cd .. && rm gmp-6.1.2.tar.xz && rm -rf gmp-6.1.2 COPY --from=downloader /usr/bin/qemu-aarch64-static /usr/bin/qemu-aarch64-static WORKDIR /opt/lightningd COPY . /tmp/lightning diff --git a/contrib/docker/scripts/build.sh b/contrib/docker/scripts/build.sh index c2752c8bf..61368321b 100755 --- a/contrib/docker/scripts/build.sh +++ b/contrib/docker/scripts/build.sh @@ -77,16 +77,6 @@ then rm sqlite-src-3260000.zip rm -rf sqlite-src-3260000 - wget -q https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz - tar xf gmp-6.1.2.tar.xz - cd gmp-6.1.2 || exit 1 - ./configure --disable-assembly --prefix="$QEMU_LD_PREFIX" --host="$TARGET_HOST" - make - sudo make install - cd .. - rm gmp-6.1.2.tar.xz - rm -rf gmp-6.1.2 - ./configure CC="$TARGET_HOST-gcc" --enable-static make -j32 CC="$TARGET_HOST-gcc" > /dev/null diff --git a/contrib/docker/scripts/setup.sh b/contrib/docker/scripts/setup.sh index 18cf124f3..6f9cbdb76 100755 --- a/contrib/docker/scripts/setup.sh +++ b/contrib/docker/scripts/setup.sh @@ -24,7 +24,6 @@ sudo apt-get -qq install --no-install-recommends --allow-unauthenticated -yy \ git \ libc6-dev-arm64-cross \ libc6-dev-armhf-cross \ - libgmp-dev \ libpq-dev \ libprotobuf-c-dev \ libsqlite3-dev \ diff --git a/contrib/reprobuild/Dockerfile.focal b/contrib/reprobuild/Dockerfile.focal index e8be966cf..942039645 100644 --- a/contrib/reprobuild/Dockerfile.focal +++ b/contrib/reprobuild/Dockerfile.focal @@ -17,7 +17,6 @@ RUN apt-get update \ file \ gettext \ git \ - libgmp-dev \ libpq-dev \ libsodium23 \ libtool \ diff --git a/contrib/reprobuild/Dockerfile.jammy b/contrib/reprobuild/Dockerfile.jammy index 9aed77177..81b14acec 100644 --- a/contrib/reprobuild/Dockerfile.jammy +++ b/contrib/reprobuild/Dockerfile.jammy @@ -17,7 +17,6 @@ RUN apt-get update \ file \ gettext \ git \ - libgmp-dev \ libsqlite3-dev \ libpq-dev \ libsodium23 \ diff --git a/doc/INSTALL.md b/doc/INSTALL.md index 5512c4a8c..906c47db5 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -20,7 +20,6 @@ Library Requirements You will need several development libraries: * libsqlite3: for database support. -* libgmp: for secp256k1 * zlib: for compression routines. For actually doing development and running the tests, you will also need: @@ -38,7 +37,7 @@ Get dependencies: sudo apt-get update sudo apt-get install -y \ - autoconf automake build-essential git libtool libgmp-dev libsqlite3-dev \ + autoconf automake build-essential git libtool libsqlite3-dev \ python3 python3-pip net-tools zlib1g-dev libsodium-dev gettext pip3 install --upgrade pip pip3 install --user poetry @@ -119,7 +118,6 @@ $ sudo dnf update -y && \ clang \ gettext \ git \ - gmp-devel \ libsq3-devel \ python3-devel \ python3-pip \ @@ -204,7 +202,7 @@ OS version: OpenBSD 6.7 Install dependencies: ``` -pkg_add git python gmake py3-pip libtool gmp +pkg_add git python gmake py3-pip libtool pkg_add automake # (select highest version, automake1.16.2 at time of writing) pkg_add autoconf # (select highest version, autoconf-2.69p2 at time of writing) ``` @@ -236,7 +234,7 @@ To Build on NixOS Use nix-shell launch a shell with a full clightning dev environment: ``` -$ nix-shell -Q -p gdb sqlite autoconf git clang libtool gmp sqlite autoconf \ +$ nix-shell -Q -p gdb sqlite autoconf git clang libtool sqlite autoconf \ autogen automake libsodium 'python3.withPackages (p: [p.bitcoinlib])' \ valgrind --run make ``` @@ -246,7 +244,7 @@ To Build on macOS Assuming you have Xcode and Homebrew installed. Install dependencies: - $ brew install autoconf automake libtool python3 gmp gnu-sed gettext libsodium protobuf + $ brew install autoconf automake libtool python3 gnu-sed gettext libsodium protobuf $ ln -s /usr/local/Cellar/gettext/0.20.1/bin/xgettext /usr/local/opt $ export PATH="/usr/local/opt:$PATH" @@ -407,7 +405,7 @@ Config the arm elf interpreter prefix: export QEMU_LD_PREFIX=/path/to/raspberry/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/arm-linux-gnueabihf/sysroot/ -Obtain and install cross-compiled versions of sqlite3, gmp and zlib: +Obtain and install cross-compiled versions of sqlite3 and zlib: Download and build zlib: @@ -427,15 +425,6 @@ Download and build sqlite3: make make install -Download and build gmp: - - wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz - tar xvf gmp-6.1.2.tar.xz - cd gmp-6.1.2 - ./configure --disable-assembly --host=$target_host --prefix=$QEMU_LD_PREFIX - make - make install - Then, build Core Lightning with the following commands: ./configure @@ -456,7 +445,7 @@ Get dependencies: ``` apk update apk add --virtual .build-deps ca-certificates alpine-sdk autoconf automake git libtool \ - gmp-dev sqlite-dev python3 py3-mako net-tools zlib-dev libsodium gettext + sqlite-dev python3 py3-mako net-tools zlib-dev libsodium gettext ``` Clone lightning: ``` @@ -477,7 +466,7 @@ apk del .build-deps ``` Install runtime dependencies: ``` -apk add gmp libgcc libsodium sqlite-libs zlib +apk add libgcc libsodium sqlite-libs zlib ``` Additional steps diff --git a/tools/headerversions.c b/tools/headerversions.c index 5e0056be5..00435e867 100644 --- a/tools/headerversions.c +++ b/tools/headerversions.c @@ -7,7 +7,6 @@ #include #include #include -#include #if HAVE_SQLITE3 # include # define IF_SQLITE3(...) __VA_ARGS__ @@ -19,17 +18,14 @@ static const char template[] = "/* Generated file by tools/headerversions, do not edit! */\n" - "/* GMP version: %s */\n" IF_SQLITE3("/* SQLITE3 version: %u */\n") "/* ZLIB version: %s */\n" "#include \n" - "#include \n" IF_SQLITE3("#include \n") "#include \n" "\n" "static inline void check_linked_library_versions(void)\n" "{\n" - " char compiled_gmp_version[100];\n" IF_SQLITE3( " /* Require at least the version we compiled with. */" " if (SQLITE_VERSION_NUMBER > sqlite3_libversion_number())\n" @@ -44,15 +40,6 @@ static const char template[] = " if (zlibVersion()[0] != ZLIB_VERSION[0])\n" " errx(1, \"zlib version mismatch: compiled %%s, now %%s\",\n" " ZLIB_VERSION, zlibVersion());\n" - " /* GMP doesn't say anything, and we have to assemble our own string. */\n" - " snprintf(compiled_gmp_version, sizeof(compiled_gmp_version),\n" - " \"%%u.%%u.%%u\",\n" - " __GNU_MP_VERSION,\n" - " __GNU_MP_VERSION_MINOR,\n" - " __GNU_MP_VERSION_PATCHLEVEL);\n" - " if (strcmp(compiled_gmp_version, gmp_version) != 0)\n" - " errx(1, \"gmp version mismatch: compiled %%s, now %%s\",\n" - " compiled_gmp_version, gmp_version);\n" "}\n"; int main(int argc, char *argv[]) @@ -70,7 +57,6 @@ int main(int argc, char *argv[]) err(1, "Reading %s", argv[1]); new = tal_fmt(NULL, template, - gmp_version, IF_SQLITE3(sqlite3_libversion_number(),) zlibVersion()); if (!file || !streq(new, file)) { diff --git a/tools/repro-build.sh b/tools/repro-build.sh index 9ff53937f..4a549af48 100755 --- a/tools/repro-build.sh +++ b/tools/repro-build.sh @@ -70,7 +70,7 @@ case "$PLATFORM" in exit 1 fi DOWNLOAD='sudo apt -y --no-install-recommends --reinstall -d install' - PKGS='autoconf automake libtool make gcc libgmp-dev libsqlite3-dev zlib1g-dev libsodium-dev' + PKGS='autoconf automake libtool make gcc libsqlite3-dev zlib1g-dev libsodium-dev' INST='sudo dpkg -i' cat > /tmp/SHASUMS < /tmp/SHASUMS < /tmp/SHASUMS <