build/ci: Fix --enable-glibc-back-compat and its usage (#4592)

* build: Fix `--enable-glibc-back-compat`

Compiling on Ubuntu 20.04 results in binaries that can't be run on older systems we still support (e.g. Ubuntu 16.04) and `contrib/devtools/symbol-check.py` complains about it.

Available versions for `log` for example:
$ objdump -T /lib/x86_64-linux-gnu/libm.so.6 | egrep -w 'log'
00000000000431b0 g    DF .text	0000000000000039  GLIBC_2.29  log
0000000000012360 g    DF .text	0000000000000066 (GLIBC_2.2.5) log

(i.e. the default one is 2.29)

This commit fixes the issue by picking the version we support instead of the default one.

Before:
$ objdump -T dashd | egrep -w 'log'
0000000000000000      DF *UND*	0000000000000000  GLIBC_2.29  log

After:
$ objdump -T dashd | egrep -w 'log'
0000000000000000      DF *UND*	0000000000000000  GLIBC_2.2.5 log

* ci: Add `make check-symbols` to the `build` step

* ci: Do not specify `--enable-glibc-back-compat` for non-release builds

* ci: Set correct LDFLAGS for the release build

* doc: Update docs to mention the need for `LDFLAGS=-static-libstdc++` when compiling for same host but different distro

* ci: Add `--with-sanitizers=undefined` back to `linux64` build
This commit is contained in:
UdjinM6 2021-11-30 14:13:18 +03:00 committed by GitHub
parent d6b9958310
commit 9718bb394b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 15 deletions

View File

@ -52,3 +52,4 @@ cd dashcore-$BUILD_TARGET
./configure --cache-file=../config.cache $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( cat config.log && false) ./configure --cache-file=../config.cache $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( cat config.log && false)
make $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && make $GOAL V=1 ; false ) make $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && make $GOAL V=1 ; false )
make $MAKEJOBS -C src check-symbols

View File

@ -40,7 +40,7 @@ if [ "$BUILD_TARGET" = "arm-linux" ]; then
export CHECK_DOC=1 export CHECK_DOC=1
# -Wno-psabi is to disable ABI warnings: "note: parameter passing for argument of type ... changed in GCC 7.1" # -Wno-psabi is to disable ABI warnings: "note: parameter passing for argument of type ... changed in GCC 7.1"
# This could be removed once the ABI change warning does not show up by default # This could be removed once the ABI change warning does not show up by default
export BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports --enable-suppress-external-warnings --enable-werror CXXFLAGS=-Wno-psabi" export BITCOIN_CONFIG="--enable-reduce-exports --enable-suppress-external-warnings --enable-werror CXXFLAGS=-Wno-psabi"
export RUN_UNITTESTS=false export RUN_UNITTESTS=false
export RUN_INTEGRATIONTESTS=false export RUN_INTEGRATIONTESTS=false
elif [ "$BUILD_TARGET" = "win64" ]; then elif [ "$BUILD_TARGET" = "win64" ]; then
@ -50,30 +50,30 @@ elif [ "$BUILD_TARGET" = "win64" ]; then
export DIRECT_WINE_EXEC_TESTS=true export DIRECT_WINE_EXEC_TESTS=true
elif [ "$BUILD_TARGET" = "linux32" ]; then elif [ "$BUILD_TARGET" = "linux32" ]; then
export HOST=i686-pc-linux-gnu export HOST=i686-pc-linux-gnu
export BITCOIN_CONFIG="--enable-zmq --disable-bip70 --enable-glibc-back-compat --enable-reduce-exports --enable-crash-hooks LDFLAGS=-static-libstdc++" export BITCOIN_CONFIG="--enable-zmq --disable-bip70 --enable-reduce-exports --enable-crash-hooks"
export USE_SHELL="/bin/dash" export USE_SHELL="/bin/dash"
export PYZMQ=true export PYZMQ=true
elif [ "$BUILD_TARGET" = "linux64" ]; then elif [ "$BUILD_TARGET" = "linux64" ]; then
export HOST=x86_64-unknown-linux-gnu export HOST=x86_64-unknown-linux-gnu
export DEP_OPTS="NO_UPNP=1 DEBUG=1" export DEP_OPTS="NO_UPNP=1 DEBUG=1"
export BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports --enable-crash-hooks --with-sanitizers=undefined" export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports --enable-crash-hooks --with-sanitizers=undefined"
export CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG -DARENA_DEBUG" export CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG -DARENA_DEBUG"
export PYZMQ=true export PYZMQ=true
elif [ "$BUILD_TARGET" = "linux64_cxx17" ]; then elif [ "$BUILD_TARGET" = "linux64_cxx17" ]; then
export HOST=x86_64-unknown-linux-gnu export HOST=x86_64-unknown-linux-gnu
export DEP_OPTS="NO_UPNP=1 DEBUG=1" export DEP_OPTS="NO_UPNP=1 DEBUG=1"
export BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports --enable-crash-hooks --enable-c++17 --enable-suppress-external-warnings --enable-werror --with-sanitizers=undefined" export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports --enable-crash-hooks --enable-c++17 --enable-suppress-external-warnings --enable-werror --with-sanitizers=undefined"
export CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG -DARENA_DEBUG" export CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG -DARENA_DEBUG"
export PYZMQ=true export PYZMQ=true
export RUN_INTEGRATIONTESTS=false export RUN_INTEGRATIONTESTS=false
elif [ "$BUILD_TARGET" = "linux64_nowallet" ]; then elif [ "$BUILD_TARGET" = "linux64_nowallet" ]; then
export HOST=x86_64-unknown-linux-gnu export HOST=x86_64-unknown-linux-gnu
export DEP_OPTS="NO_WALLET=1" export DEP_OPTS="NO_WALLET=1"
export BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports" export BITCOIN_CONFIG="--enable-reduce-exports"
elif [ "$BUILD_TARGET" = "linux64_release" ]; then elif [ "$BUILD_TARGET" = "linux64_release" ]; then
export HOST=x86_64-unknown-linux-gnu export HOST=x86_64-unknown-linux-gnu
export DEP_OPTS="NO_UPNP=1" export DEP_OPTS="NO_UPNP=1"
export BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports" export BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports LDFLAGS=-static-libstdc++"
export PYZMQ=true export PYZMQ=true
elif [ "$BUILD_TARGET" = "mac" ]; then elif [ "$BUILD_TARGET" = "mac" ]; then
export HOST=x86_64-apple-darwin19 export HOST=x86_64-apple-darwin19

View File

@ -55,7 +55,7 @@ Please replace `<host>` with your local system's `host-platform-triplet`. The fo
If you want to cross-compile for another platform, choose the appropriate `<host>` and make sure to build the If you want to cross-compile for another platform, choose the appropriate `<host>` and make sure to build the
dependencies with the same host before. dependencies with the same host before.
If you want to build for the same host but different distro, add `--enable-glibc-back-compat` when calling `./configure`. If you want to build for the same host but different distro, add `--enable-glibc-back-compat LDFLAGS=-static-libstdc++` when calling `./configure`.
ccache ccache

View File

@ -685,6 +685,8 @@ libdash_util_a_SOURCES = \
if GLIBC_BACK_COMPAT if GLIBC_BACK_COMPAT
libdash_util_a_SOURCES += compat/glibc_compat.cpp libdash_util_a_SOURCES += compat/glibc_compat.cpp
AM_LDFLAGS += -Wl,--wrap=log2f -Wl,--wrap=__divmoddi4 AM_LDFLAGS += -Wl,--wrap=log2f -Wl,--wrap=__divmoddi4
AM_LDFLAGS += -Wl,--wrap=exp -Wl,--wrap=exp2 -Wl,--wrap=fcntl
AM_LDFLAGS += -Wl,--wrap=log -Wl,--wrap=log2 -Wl,--wrap=pow
endif endif
# cli: shared between dash-cli and dash-qt # cli: shared between dash-cli and dash-qt

View File

@ -6,6 +6,7 @@
#include <config/dash-config.h> #include <config/dash-config.h>
#endif #endif
#include <cstdarg>
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
@ -58,19 +59,59 @@ extern "C" int64_t __wrap___divmoddi4(int64_t u, int64_t v, int64_t* rp)
} }
#endif #endif
extern "C" float exp_old(float x);
extern "C" float exp2_old(float x);
extern "C" float log_old(float x);
extern "C" float log2_old(float x);
extern "C" float log2f_old(float x); extern "C" float log2f_old(float x);
extern "C" float pow_old(float x, float y);
extern "C" int fcntl_old(int fd, int cmd, ...);
#ifdef __i386__ #ifdef __i386__
__asm(".symver log2f_old,log2f@GLIBC_2.1"); #define SYMVER "GLIBC_2.1"
#elif defined(__amd64__) #elif defined(__amd64__)
__asm(".symver log2f_old,log2f@GLIBC_2.2.5"); #define SYMVER "GLIBC_2.2.5"
#elif defined(__arm__) #elif defined(__arm__)
__asm(".symver log2f_old,log2f@GLIBC_2.4"); #define SYMVER "GLIBC_2.4"
#elif defined(__aarch64__) #elif defined(__aarch64__)
__asm(".symver log2f_old,log2f@GLIBC_2.17"); #define SYMVER "GLIBC_2.17"
#elif defined(__riscv) #elif defined(__riscv)
__asm(".symver log2f_old,log2f@GLIBC_2.27"); #define SYMVER "GLIBC_2.27"
#endif #endif // __i386__
extern "C" float __wrap_log2f(float x)
#define SYMVER_OLD(FUNC) __asm__(".symver " #FUNC "_old," #FUNC "@" SYMVER)
SYMVER_OLD(exp2);
SYMVER_OLD(log2);
SYMVER_OLD(log2f);
#ifdef __i386__
#undef SYMVER
#undef SYMVER_OLD
#define SYMVER "GLIBC_2.0"
#define SYMVER_OLD(FUNC) __asm__(".symver " #FUNC "_old," #FUNC "@" SYMVER)
#endif // __i386__
SYMVER_OLD(exp);
SYMVER_OLD(log);
SYMVER_OLD(pow);
SYMVER_OLD(fcntl);
extern "C" float __wrap_exp(float x) { return exp_old(x); }
extern "C" float __wrap_exp2(float x) { return exp2_old(x); }
extern "C" float __wrap_log(float x) { return log_old(x); }
extern "C" float __wrap_log2(float x) { return log2_old(x); }
extern "C" float __wrap_log2f(float x) { return log2f_old(x); }
extern "C" float __wrap_pow(float x, float y) { return pow_old(x, y); }
extern "C" int __wrap_fcntl(int fd, int cmd, ...)
{ {
return log2f_old(x); va_list va;
void *arg;
va_start(va, cmd);
arg = va_arg(va, void *);
va_end(va);
return fcntl_old(fd, cmd, arg);
} }