From 4598ec33fcd0f2e5b6f0bfeac90b6cbfcad4c906 Mon Sep 17 00:00:00 2001 From: Chun Kuan Lee Date: Sat, 5 May 2018 13:18:40 +0000 Subject: [PATCH 1/7] GCC-7 and glibc-2.27 compat code Cherry-picked from: 908c1d7 Note: fixes __divmoddi4 and log2f when compiling with gcc-7 --- configure.ac | 3 +++ src/Makefile.am | 3 +++ src/compat/glibc_compat.cpp | 45 +++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/configure.ac b/configure.ac index 9d1148e64..2f21427ae 100644 --- a/configure.ac +++ b/configure.ac @@ -487,6 +487,8 @@ if test x$use_glibc_compat != xno; then [ fdelt_type="long int"]) AC_MSG_RESULT($fdelt_type) AC_DEFINE_UNQUOTED(FDELT_TYPE, $fdelt_type,[parameter and return value type for __fdelt_chk]) + AX_CHECK_LINK_FLAG([[-Wl,--wrap=__divmoddi4]], [COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=__divmoddi4"]) + AX_CHECK_LINK_FLAG([[-Wl,--wrap=log2f]], [COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=log2f"]) else AC_SEARCH_LIBS([clock_gettime],[rt]) fi @@ -1090,6 +1092,7 @@ AC_SUBST(BITCOIN_CLI_NAME) AC_SUBST(BITCOIN_TX_NAME) AC_SUBST(RELDFLAGS) +AC_SUBST(COMPAT_LDFLAGS) AC_SUBST(ERROR_CXXFLAGS) AC_SUBST(HARDENED_CXXFLAGS) AC_SUBST(HARDENED_CPPFLAGS) diff --git a/src/Makefile.am b/src/Makefile.am index f438235ee..2e7ebb299 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -356,7 +356,10 @@ libdogecoin_util_a_SOURCES = \ $(BITCOIN_CORE_H) if GLIBC_BACK_COMPAT + libdogecoin_util_a_SOURCES += compat/glibc_compat.cpp +AM_LDFLAGS += $(COMPAT_LDFLAGS) + endif # cli: shared between bitcoin-cli and bitcoin-qt diff --git a/src/compat/glibc_compat.cpp b/src/compat/glibc_compat.cpp index 3b9c70df7..0815f530c 100644 --- a/src/compat/glibc_compat.cpp +++ b/src/compat/glibc_compat.cpp @@ -7,6 +7,7 @@ #endif #include +#include #if defined(HAVE_SYS_SELECT_H) #include @@ -27,3 +28,47 @@ extern "C" FDELT_TYPE __fdelt_warn(FDELT_TYPE a) return a / __NFDBITS; } extern "C" FDELT_TYPE __fdelt_chk(FDELT_TYPE) __attribute__((weak, alias("__fdelt_warn"))); + +#if defined(__i386__) || defined(__arm__) + +extern "C" int64_t __udivmoddi4(uint64_t u, uint64_t v, uint64_t* rp); + +extern "C" int64_t __wrap___divmoddi4(int64_t u, int64_t v, int64_t* rp) +{ + int32_t c1 = 0, c2 = 0; + int64_t uu = u, vv = v; + int64_t w; + int64_t r; + + if (uu < 0) { + c1 = ~c1, c2 = ~c2, uu = -uu; + } + if (vv < 0) { + c1 = ~c1, vv = -vv; + } + + w = __udivmoddi4(uu, vv, (uint64_t*)&r); + if (c1) + w = -w; + if (c2) + r = -r; + + *rp = r; + return w; +} +#endif + +extern "C" float log2f_old(float x); +#ifdef __i386__ +__asm(".symver log2f_old,log2f@GLIBC_2.1"); +#elif defined(__amd64__) +__asm(".symver log2f_old,log2f@GLIBC_2.2.5"); +#elif defined(__arm__) +__asm(".symver log2f_old,log2f@GLIBC_2.4"); +#elif defined(__aarch64__) +__asm(".symver log2f_old,log2f@GLIBC_2.17"); +#endif +extern "C" float __wrap_log2f(float x) +{ + return log2f_old(x); +} From a7ed71e78fa3291789072c42abe1654b41b8dc32 Mon Sep 17 00:00:00 2001 From: Chun Kuan Lee Date: Sat, 2 Jun 2018 17:30:16 +0000 Subject: [PATCH 2/7] Add stdin, stdout, stderr to ignored export list Cherry-picked from: 253f592 --- contrib/devtools/symbol-check.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/devtools/symbol-check.py b/contrib/devtools/symbol-check.py index 34ff16009..cee7ff269 100755 --- a/contrib/devtools/symbol-check.py +++ b/contrib/devtools/symbol-check.py @@ -48,7 +48,8 @@ MAX_VERSIONS = { # Ignore symbols that are exported as part of every executable IGNORE_EXPORTS = { -b'_edata', b'_end', b'_init', b'__bss_start', b'_fini', b'_IO_stdin_used' + b'_edata', b'_end', b'_init', b'__bss_start', b'_fini', b'_IO_stdin_used', + b'stdin', b'stdout', b'stderr' } READELF_CMD = os.getenv('READELF', '/usr/bin/readelf') CPPFILT_CMD = os.getenv('CPPFILT', '/usr/bin/c++filt') From d8809182e6f3cd6acf321787a88d0cd6f5052936 Mon Sep 17 00:00:00 2001 From: Patrick Lodder Date: Sun, 29 Aug 2021 02:39:10 +0200 Subject: [PATCH 3/7] Change in6addr_any to IN6ADDR_ANY_INIT This prevents glibc export of in6addr_any. Inspired by: fc6a9f2 Original Author: Cory Fields --- src/init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index dd1942133..8bf514dcc 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1347,7 +1347,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) if (!mapMultiArgs.count("-bind") && !mapMultiArgs.count("-whitebind")) { struct in_addr inaddr_any; inaddr_any.s_addr = INADDR_ANY; - fBound |= Bind(connman, CService(in6addr_any, GetListenPort()), BF_NONE); + fBound |= Bind(connman, CService((in6_addr)IN6ADDR_ANY_INIT, GetListenPort()), BF_NONE); fBound |= Bind(connman, CService(inaddr_any, GetListenPort()), !fBound ? BF_REPORT_ERROR : BF_NONE); } if (!fBound) From 5dd1a6283bc08fe325f9d5010772522a9f8df62a Mon Sep 17 00:00:00 2001 From: Patrick Lodder Date: Sat, 28 Aug 2021 21:24:26 +0200 Subject: [PATCH 4/7] qa: change CI and CodeQL to use bionic for all builds - change host os for all builds - change i686 wine to wine-stable --- .github/workflows/ci.yml | 14 +++++++------- .github/workflows/codeql-analysis.yml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb7614f8a..25cefd992 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: include: - name: i686-linux host: i686-pc-linux-gnu - os: ubuntu-20.04 + os: ubuntu-18.04 packages: g++-multilib bc python3-zmq run-tests: true dep-opts: "NO_QT=1" @@ -46,7 +46,7 @@ jobs: goal: install - name: armhf-linux host: arm-linux-gnueabihf - os: ubuntu-20.04 + os: ubuntu-18.04 packages: g++-arm-linux-gnueabihf run-tests: false dep-opts: "NO_QT=1" @@ -54,7 +54,7 @@ jobs: goal: install - name: x86_64-linux-nowallet host: x86_64-unknown-linux-gnu - os: ubuntu-20.04 + os: ubuntu-18.04 packages: python3 run-tests: true dep-opts: "NO_WALLET=1" @@ -62,7 +62,7 @@ jobs: goal: install - name: x86_64-linux-dbg host: x86_64-unknown-linux-gnu - os: ubuntu-20.04 + os: ubuntu-18.04 packages: bc python3-zmq run-tests: true dep-opts: "DEBUG=1" @@ -71,8 +71,8 @@ jobs: - name: i686-win host: i686-w64-mingw32 arch: "i386" - os: ubuntu-20.04 - packages: python3 nsis g++-mingw-w64-i686 wine bc wine-binfmt + os: ubuntu-18.04 + packages: python3 nsis g++-mingw-w64-i686 wine-stable bc wine-binfmt postinstall: | sudo update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-posix sudo update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix @@ -84,7 +84,7 @@ jobs: - name: x86_64-win host: x86_64-w64-mingw32 arch: "i386" - os: ubuntu-20.04 + os: ubuntu-18.04 packages: python3 nsis g++-mingw-w64-x86-64 wine64 bc wine-binfmt postinstall: | sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 05e718c10..2e4224a22 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -21,7 +21,7 @@ on: jobs: analyze: name: Analyze - runs-on: ubuntu-latest + runs-on: ubuntu-18.04 permissions: actions: read contents: read From 0c92645c9c5ba4b22888a2e573d737710a75bde5 Mon Sep 17 00:00:00 2001 From: Patrick Lodder Date: Sat, 28 Aug 2021 21:44:20 +0200 Subject: [PATCH 5/7] build: change gitian descriptors to use bionic - all: change suite to bionic instead of trusty - linux: change gcc version to 7 - win: remove g++ from faketime_progs - win: wrap *-posix compilers rather than plain mingw - win: install 'rename' --- contrib/gitian-descriptors/gitian-linux.yml | 14 +++++++------- contrib/gitian-descriptors/gitian-osx-signer.yml | 2 +- contrib/gitian-descriptors/gitian-osx.yml | 2 +- contrib/gitian-descriptors/gitian-win-signer.yml | 2 +- contrib/gitian-descriptors/gitian-win.yml | 7 ++++--- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/contrib/gitian-descriptors/gitian-linux.yml b/contrib/gitian-descriptors/gitian-linux.yml index c43a28089..4458bb98a 100644 --- a/contrib/gitian-descriptors/gitian-linux.yml +++ b/contrib/gitian-descriptors/gitian-linux.yml @@ -2,21 +2,21 @@ name: "dogecoin-linux-1.14" enable_cache: true suites: -- "trusty" +- "bionic" architectures: - "amd64" packages: - "curl" - "g++-aarch64-linux-gnu" -- "g++-4.8-aarch64-linux-gnu" -- "gcc-4.8-aarch64-linux-gnu" +- "g++-7-aarch64-linux-gnu" +- "gcc-7-aarch64-linux-gnu" - "binutils-aarch64-linux-gnu" - "g++-arm-linux-gnueabihf" -- "g++-4.8-arm-linux-gnueabihf" -- "gcc-4.8-arm-linux-gnueabihf" +- "g++-7-arm-linux-gnueabihf" +- "gcc-7-arm-linux-gnueabihf" - "binutils-arm-linux-gnueabihf" -- "g++-4.8-multilib" -- "gcc-4.8-multilib" +- "g++-7-multilib" +- "gcc-7-multilib" - "binutils-gold" - "git-core" - "pkg-config" diff --git a/contrib/gitian-descriptors/gitian-osx-signer.yml b/contrib/gitian-descriptors/gitian-osx-signer.yml index 2eb39e569..755f93eb2 100644 --- a/contrib/gitian-descriptors/gitian-osx-signer.yml +++ b/contrib/gitian-descriptors/gitian-osx-signer.yml @@ -1,7 +1,7 @@ --- name: "dogecoin-dmg-signer" suites: -- "trusty" +- "bionic" architectures: - "amd64" packages: diff --git a/contrib/gitian-descriptors/gitian-osx.yml b/contrib/gitian-descriptors/gitian-osx.yml index e1ae624ed..f3b0346c5 100644 --- a/contrib/gitian-descriptors/gitian-osx.yml +++ b/contrib/gitian-descriptors/gitian-osx.yml @@ -2,7 +2,7 @@ name: "dogecoin-osx-1.14" enable_cache: true suites: -- "trusty" +- "bionic" architectures: - "amd64" packages: diff --git a/contrib/gitian-descriptors/gitian-win-signer.yml b/contrib/gitian-descriptors/gitian-win-signer.yml index 9c11bc89f..8262e462b 100644 --- a/contrib/gitian-descriptors/gitian-win-signer.yml +++ b/contrib/gitian-descriptors/gitian-win-signer.yml @@ -1,7 +1,7 @@ --- name: "dogecoin-win-signer" suites: -- "trusty" +- "bionic" architectures: - "amd64" packages: diff --git a/contrib/gitian-descriptors/gitian-win.yml b/contrib/gitian-descriptors/gitian-win.yml index 9ad12cc25..fec5150d4 100644 --- a/contrib/gitian-descriptors/gitian-win.yml +++ b/contrib/gitian-descriptors/gitian-win.yml @@ -2,7 +2,7 @@ name: "dogecoin-win-1.14" enable_cache: true suites: -- "trusty" +- "bionic" architectures: - "amd64" packages: @@ -21,6 +21,7 @@ packages: - "zip" - "ca-certificates" - "python" +- "rename" remotes: - "url": "https://github.com/dogecoin/dogecoin.git" "dir": "dogecoin" @@ -29,7 +30,7 @@ script: | WRAP_DIR=$HOME/wrapped HOSTS="i686-w64-mingw32 x86_64-w64-mingw32" CONFIGFLAGS="--enable-reduce-exports --disable-bench --disable-gui-tests" - FAKETIME_HOST_PROGS="g++ ar ranlib nm windres strip objcopy" + FAKETIME_HOST_PROGS="ar ranlib nm windres strip objcopy" FAKETIME_PROGS="date makensis zip" HOST_CFLAGS="-O2 -g" HOST_CXXFLAGS="-O2 -g" @@ -84,7 +85,7 @@ script: | done for prog in gcc g++; do echo '#!/bin/bash' > ${WRAP_DIR}/${i}-${prog} - echo "REAL=\`which -a ${i}-${prog} | grep -v ${WRAP_DIR}/${i}-${prog} | head -1\`" >> ${WRAP_DIR}/${i}-${prog} + echo "REAL=\`which -a ${i}-${prog}-posix | grep -v ${WRAP_DIR}/${i}-${prog} | head -1\`" >> ${WRAP_DIR}/${i}-${prog} echo 'export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1' >> ${WRAP_DIR}/${i}-${prog} echo "export FAKETIME=\"$1\"" >> ${WRAP_DIR}/${i}-${prog} echo "export COMPILER_PATH=${WRAP_DIR}/${i}" >> ${WRAP_DIR}/${i}-${prog} From aae64a9937d032b76ce9c2278426c87c35b8bb98 Mon Sep 17 00:00:00 2001 From: fanquake Date: Tue, 20 Aug 2019 15:42:19 +0800 Subject: [PATCH 6/7] build: remove mingw linker workaround from win gitian descriptor This workaround was added as part of the switch to gitian building using Ubuntu 14.04 (#6900). However, it should no longer be required, as we have switched to Bionic (#13171), and that has a far newer version of binutils. binutils patch: https://sourceware.org/bugzilla/show_bug.cgi?id=16192 Cherry-picked from: bd3f5a90 --- contrib/gitian-descriptors/gitian-win.yml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/contrib/gitian-descriptors/gitian-win.yml b/contrib/gitian-descriptors/gitian-win.yml index fec5150d4..1b691c519 100644 --- a/contrib/gitian-descriptors/gitian-win.yml +++ b/contrib/gitian-descriptors/gitian-win.yml @@ -71,18 +71,10 @@ script: | done } - function create_per-host_linker_wrapper { - # This is only needed for trusty, as the mingw linker leaks a few bytes of - # heap, causing non-determinism. See discussion in https://github.com/bitcoin/bitcoin/pull/6900 + function create_per-host_compiler_wrapper { + # -posix variant is required for c++11 threading. for i in $HOSTS; do mkdir -p ${WRAP_DIR}/${i} - for prog in collect2; do - echo '#!/bin/bash' > ${WRAP_DIR}/${i}/${prog} - REAL=$(${i}-gcc -print-prog-name=${prog}) - echo "export MALLOC_PERTURB_=255" >> ${WRAP_DIR}/${i}/${prog} - echo "${REAL} \$@" >> $WRAP_DIR/${i}/${prog} - chmod +x ${WRAP_DIR}/${i}/${prog} - done for prog in gcc g++; do echo '#!/bin/bash' > ${WRAP_DIR}/${i}-${prog} echo "REAL=\`which -a ${i}-${prog}-posix | grep -v ${WRAP_DIR}/${i}-${prog} | head -1\`" >> ${WRAP_DIR}/${i}-${prog} @@ -99,7 +91,7 @@ script: | export PATH_orig=${PATH} create_global_faketime_wrappers "2000-01-01 12:00:00" create_per-host_faketime_wrappers "2000-01-01 12:00:00" - create_per-host_linker_wrapper "2000-01-01 12:00:00" + create_per-host_compiler_wrapper "2000-01-01 12:00:00" export PATH=${WRAP_DIR}:${PATH} cd dogecoin @@ -113,7 +105,7 @@ script: | export PATH=${PATH_orig} create_global_faketime_wrappers "${REFERENCE_DATETIME}" create_per-host_faketime_wrappers "${REFERENCE_DATETIME}" - create_per-host_linker_wrapper "${REFERENCE_DATETIME}" + create_per-host_compiler_wrapper "${REFERENCE_DATETIME}" export PATH=${WRAP_DIR}:${PATH} # Create the release tarball using (arbitrarily) the first host From a8c035e88f10d7185a2a824ee0c3bff00ad1b6eb Mon Sep 17 00:00:00 2001 From: Patrick Lodder Date: Sun, 29 Aug 2021 22:40:33 +0200 Subject: [PATCH 7/7] remove zmq trusty-only patch --- depends/packages/zeromq.mk | 2 -- depends/patches/zeromq/trusty-add-win32-inethdr.patch | 11 ----------- 2 files changed, 13 deletions(-) delete mode 100644 depends/patches/zeromq/trusty-add-win32-inethdr.patch diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk index 0e76eb5a5..ac9d1eac5 100644 --- a/depends/packages/zeromq.mk +++ b/depends/packages/zeromq.mk @@ -4,7 +4,6 @@ $(package)_download_path=https://github.com/zeromq/libzmq/releases/download/v$($ $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=c593001a89f5a85dd2ddf564805deb860e02471171b3f204944857336295c3e5 $(package)_patches=remove_libstd_link.patch clock-unused-nsecs.patch 0002-disable-pthread_set_name_np.patch -$(package)_patches+=trusty-add-win32-inethdr.patch define $(package)_set_vars $(package)_config_opts=--without-documentation --disable-shared --without-libsodium --disable-curve @@ -16,7 +15,6 @@ define $(package)_preprocess_cmds patch -p1 < $($(package)_patch_dir)/clock-unused-nsecs.patch && \ patch -p1 < $($(package)_patch_dir)/remove_libstd_link.patch && \ patch -p1 < $($(package)_patch_dir)/0002-disable-pthread_set_name_np.patch && \ - patch -p1 < $($(package)_patch_dir)/trusty-add-win32-inethdr.patch && \ cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub config endef diff --git a/depends/patches/zeromq/trusty-add-win32-inethdr.patch b/depends/patches/zeromq/trusty-add-win32-inethdr.patch deleted file mode 100644 index 65845a0f5..000000000 --- a/depends/patches/zeromq/trusty-add-win32-inethdr.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -dur a/src/windows.hpp b/src/windows.hpp ---- a/src/windows.hpp 2021-07-16 20:31:22.997078113 +0000 -+++ b/src/windows.hpp 2021-07-16 20:33:21.525281189 +0000 -@@ -52,6 +52,7 @@ - #endif - - #include -+#include - #include - #include - #include