Skip to content

Commit

Permalink
partial merge bitcoin#19761: improve sed robustness by not using sed
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed Aug 27, 2021
1 parent 40fa0a5 commit 409bf19
Show file tree
Hide file tree
Showing 15 changed files with 404 additions and 17 deletions.
4 changes: 2 additions & 2 deletions depends/packages/bdb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $(package)_download_path=http://download.oracle.com/berkeley-db
$(package)_file_name=db-$($(package)_version).NC.tar.gz
$(package)_sha256_hash=12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef
$(package)_build_subdir=build_unix
$(package)_patches=clang_cxx_11.patch

define $(package)_set_vars
$(package)_config_opts=--disable-shared --enable-cxx --disable-replication
Expand All @@ -16,8 +17,7 @@ $(package)_cppflags_mingw32=-DUNICODE -D_UNICODE
endef

define $(package)_preprocess_cmds
sed -i.old 's/__atomic_compare_exchange/__atomic_compare_exchange_db/' dbinc/atomic.h && \
sed -i.old 's/atomic_init/atomic_init_db/' dbinc/atomic.h mp/mp_region.c mp/mp_mvcc.c mp/mp_fget.c mutex/mut_method.c mutex/mut_tas.c && \
patch -p1 < $($(package)_patch_dir)/clang_cxx_11.patch && \
cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub dist
endef

Expand Down
4 changes: 2 additions & 2 deletions depends/packages/boost.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ $(package)_version=1_70_0
$(package)_download_path=https://boostorg.jfrog.io/artifactory/main/release/1.70.0/source/
$(package)_file_name=$(package)_$($(package)_version).tar.bz2
$(package)_sha256_hash=430ae8354789de4fd19ee52f3b1f739e1fba576f0aded0897c3c2bc00fb38778
$(package)_patches=unused_var_in_process.patch

define $(package)_set_vars
$(package)_config_opts_release=variant=release
Expand All @@ -23,9 +24,8 @@ $(package)_cxxflags=-std=c++11 -fvisibility=hidden
$(package)_cxxflags_linux=-fPIC
endef

# Fix unused variable in boost_process, can be removed after upgrading to 1.72
define $(package)_preprocess_cmds
sed -i.old "s/int ret_sig = 0;//" boost/process/detail/posix/wait_group.hpp && \
patch -p1 < $($(package)_patch_dir)/unused_var_in_process.patch && \
echo "using $($(package)_toolset_$(host_os)) : : $($(package)_cxx) : <cxxflags>\"$($(package)_cxxflags) $($(package)_cppflags)\" <linkflags>\"$($(package)_ldflags)\" <archiver>\"$($(package)_archiver_$(host_os))\" <striper>\"$(host_STRIP)\" <ranlib>\"$(host_RANLIB)\" <rc>\"$(host_WINDRES)\" : ;" > user-config.jam
endef

Expand Down
12 changes: 6 additions & 6 deletions depends/packages/fontconfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ $(package)_download_path=http://www.freedesktop.org/software/fontconfig/release/
$(package)_file_name=$(package)-$($(package)_version).tar.bz2
$(package)_sha256_hash=b449a3e10c47e1d1c7a6ec6e2016cca73d3bd68fbbd4f0ae5cc6b573f7d6c7f3
$(package)_dependencies=freetype expat
$(package)_patches=remove_char_width_usage.patch gperf_header_regen.patch

define $(package)_set_vars
$(package)_config_opts=--disable-docs --disable-static --disable-libxml2 --disable-iconv
endef

define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/remove_char_width_usage.patch && \
patch -p1 < $($(package)_patch_dir)/gperf_header_regen.patch
endef

define $(package)_config_cmds
$($(package)_autoconf)
endef

# 2.12.1 uses CHAR_WIDTH which is reserved and clashes with some glibc versions, but newer versions of fontconfig
# have broken makefiles which needlessly attempt to re-generate headers with gperf.
# Instead, change all uses of CHAR_WIDTH, and disable the rule that forces header re-generation.
# This can be removed once the upstream build is fixed.
define $(package)_build_cmds
sed -i 's/CHAR_WIDTH/CHARWIDTH/g' fontconfig/fontconfig.h src/fcobjshash.gperf src/fcobjs.h src/fcobjshash.h && \
sed -i 's/fcobjshash.h: fcobjshash.gperf/fcobjshash.h:/' src/Makefile && \
$(MAKE)
endef

Expand Down
3 changes: 2 additions & 1 deletion depends/packages/miniupnpc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ $(package)_version=2.0.20180203
$(package)_download_path=https://miniupnp.tuxfamily.org/files
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=90dda8c7563ca6cd4a83e23b3c66dbbea89603a1675bfdb852897c2c9cc220b7
$(package)_patches=dont_use_wingen.patch

define $(package)_set_vars
$(package)_build_opts=CC="$($(package)_cc)"
Expand All @@ -14,7 +15,7 @@ endef
define $(package)_preprocess_cmds
mkdir dll && \
sed -e 's|MINIUPNPC_VERSION_STRING \"version\"|MINIUPNPC_VERSION_STRING \"$($(package)_version)\"|' -e 's|OS/version|$(host)|' miniupnpcstrings.h.in > miniupnpcstrings.h && \
sed -i.old "s|miniupnpcstrings.h: miniupnpcstrings.h.in wingenminiupnpcstrings|miniupnpcstrings.h: miniupnpcstrings.h.in|" Makefile.mingw
patch -p1 < $($(package)_patch_dir)/dont_use_wingen.patch
endef

define $(package)_build_cmds
Expand Down
4 changes: 3 additions & 1 deletion depends/packages/native_cctools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ $(package)_download_path=https://github.com/tpoechtrager/cctools-port/archive
$(package)_file_name=$($(package)_version).tar.gz
$(package)_sha256_hash=e51995a843533a3dac155dd0c71362dd471597a2d23f13dff194c6285362f875
$(package)_build_subdir=cctools
$(package)_patches=ld64_disable_threading.patch

ifeq ($(strip $(FORCE_USE_SYSTEM_CLANG)),)
$(package)_clang_version=8.0.0
$(package)_clang_download_path=https://releases.llvm.org/$($(package)_clang_version)
Expand Down Expand Up @@ -78,7 +80,7 @@ endef
define $(package)_preprocess_cmds
CC=$($(package)_cc) CXX=$($(package)_cxx) INSTALLPREFIX=$($(package)_extract_dir) ./libtapi/build.sh && \
CC=$($(package)_cc) CXX=$($(package)_cxx) INSTALLPREFIX=$($(package)_extract_dir) ./libtapi/install.sh && \
sed -i.old "/define HAVE_PTHREADS/d" $($(package)_build_subdir)/ld64/src/ld/InputFiles.h
patch -p1 < $($(package)_patch_dir)/ld64_disable_threading.patch
endef

define $(package)_config_cmds
Expand Down
12 changes: 7 additions & 5 deletions depends/packages/qt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ $(package)_sha256_hash=36dd9574f006eaa1e5af780e4b33d11fe39d09fd7c12f3b9d83294174
$(package)_dependencies=openssl zlib
$(package)_linux_dependencies=freetype fontconfig libxcb
$(package)_qt_libs=corelib network widgets gui plugins testlib
$(package)_patches=fix_qt_pkgconfig.patch mac-qmake.conf fix_configure_mac.patch fix_no_printer.patch fix_rcc_determinism.patch xkb-default.patch no-xlib.patch
$(package)_patches=fix_qt_pkgconfig.patch mac-qmake.conf fix_configure_mac.patch fix_no_printer.patch
$(package)_patches+= fix_rcc_determinism.patch xkb-default.patch no-xlib.patch
$(package)_patches+= dont_hardcode_pwd.patch
$(package)_patches+= freetype_back_compat.patch drop_lrelease_dependency.patch

# Update OSX_QT_TRANSLATIONS when this is updated
$(package)_qttranslations_file_name=qttranslations-$($(package)_suffix)
Expand Down Expand Up @@ -136,11 +139,10 @@ define $(package)_extract_cmds
endef

define $(package)_preprocess_cmds
sed -i.old "s|FT_Get_Font_Format|FT_Get_X11_Font_Format|" qtbase/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp && \
patch -p1 -i $($(package)_patch_dir)/freetype_back_compat.patch && \
sed -i.old "s|updateqm.commands = \$$$$\$$$$LRELEASE|updateqm.commands = $($(package)_extract_dir)/qttools/bin/lrelease|" qttranslations/translations/translations.pro && \
sed -i.old "/updateqm.depends =/d" qttranslations/translations/translations.pro && \
sed -i.old "s/src_plugins.depends = src_sql src_network/src_plugins.depends = src_network/" qtbase/src/src.pro && \
sed -i.old -e 's/if \[ "$$$$XPLATFORM_MAC" = "yes" \]; then xspecvals=$$$$(macSDKify/if \[ "$$$$BUILD_ON_MAC" = "yes" \]; then xspecvals=$$$$(macSDKify/' -e 's|/bin/pwd|pwd|' qtbase/configure && \
patch -p1 -i $($(package)_patch_dir)/drop_lrelease_dependency.patch && \
patch -p1 -i $($(package)_patch_dir)/dont_hardcode_pwd.patch &&\
mkdir -p qtbase/mkspecs/macx-clang-linux &&\
cp -f qtbase/mkspecs/macx-clang/Info.plist.lib qtbase/mkspecs/macx-clang-linux/ &&\
cp -f qtbase/mkspecs/macx-clang/Info.plist.app qtbase/mkspecs/macx-clang-linux/ &&\
Expand Down
147 changes: 147 additions & 0 deletions depends/patches/bdb/clang_cxx_11.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
commit 3311d68f11d1697565401eee6efc85c34f022ea7
Author: fanquake <fanquake@gmail.com>
Date: Mon Aug 17 20:03:56 2020 +0800

Fix C++11 compatibility

diff --git a/dbinc/atomic.h b/dbinc/atomic.h
index 0034dcc..7c11d4a 100644
--- a/dbinc/atomic.h
+++ b/dbinc/atomic.h
@@ -70,7 +70,7 @@ typedef struct {
* These have no memory barriers; the caller must include them when necessary.
*/
#define atomic_read(p) ((p)->value)
-#define atomic_init(p, val) ((p)->value = (val))
+#define atomic_init_db(p, val) ((p)->value = (val))

#ifdef HAVE_ATOMIC_SUPPORT

@@ -144,7 +144,7 @@ typedef LONG volatile *interlocked_val;
#define atomic_inc(env, p) __atomic_inc(p)
#define atomic_dec(env, p) __atomic_dec(p)
#define atomic_compare_exchange(env, p, o, n) \
- __atomic_compare_exchange((p), (o), (n))
+ __atomic_compare_exchange_db((p), (o), (n))
static inline int __atomic_inc(db_atomic_t *p)
{
int temp;
@@ -176,7 +176,7 @@ static inline int __atomic_dec(db_atomic_t *p)
* http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html
* which configure could be changed to use.
*/
-static inline int __atomic_compare_exchange(
+static inline int __atomic_compare_exchange_db(
db_atomic_t *p, atomic_value_t oldval, atomic_value_t newval)
{
atomic_value_t was;
@@ -206,7 +206,7 @@ static inline int __atomic_compare_exchange(
#define atomic_dec(env, p) (--(p)->value)
#define atomic_compare_exchange(env, p, oldval, newval) \
(DB_ASSERT(env, atomic_read(p) == (oldval)), \
- atomic_init(p, (newval)), 1)
+ atomic_init_db(p, (newval)), 1)
#else
#define atomic_inc(env, p) __atomic_inc(env, p)
#define atomic_dec(env, p) __atomic_dec(env, p)
diff --git a/mp/mp_fget.c b/mp/mp_fget.c
index 5fdee5a..0b75f57 100644
--- a/mp/mp_fget.c
+++ b/mp/mp_fget.c
@@ -617,7 +617,7 @@ alloc: /* Allocate a new buffer header and data space. */

/* Initialize enough so we can call __memp_bhfree. */
alloc_bhp->flags = 0;
- atomic_init(&alloc_bhp->ref, 1);
+ atomic_init_db(&alloc_bhp->ref, 1);
#ifdef DIAGNOSTIC
if ((uintptr_t)alloc_bhp->buf & (sizeof(size_t) - 1)) {
__db_errx(env,
@@ -911,7 +911,7 @@ alloc: /* Allocate a new buffer header and data space. */
MVCC_MPROTECT(bhp->buf, mfp->stat.st_pagesize,
PROT_READ);

- atomic_init(&alloc_bhp->ref, 1);
+ atomic_init_db(&alloc_bhp->ref, 1);
MUTEX_LOCK(env, alloc_bhp->mtx_buf);
alloc_bhp->priority = bhp->priority;
alloc_bhp->pgno = bhp->pgno;
diff --git a/mp/mp_mvcc.c b/mp/mp_mvcc.c
index 34467d2..f05aa0c 100644
--- a/mp/mp_mvcc.c
+++ b/mp/mp_mvcc.c
@@ -276,7 +276,7 @@ __memp_bh_freeze(dbmp, infop, hp, bhp, need_frozenp)
#else
memcpy(frozen_bhp, bhp, SSZA(BH, buf));
#endif
- atomic_init(&frozen_bhp->ref, 0);
+ atomic_init_db(&frozen_bhp->ref, 0);
if (mutex != MUTEX_INVALID)
frozen_bhp->mtx_buf = mutex;
else if ((ret = __mutex_alloc(env, MTX_MPOOL_BH,
@@ -428,7 +428,7 @@ __memp_bh_thaw(dbmp, infop, hp, frozen_bhp, alloc_bhp)
#endif
alloc_bhp->mtx_buf = mutex;
MUTEX_LOCK(env, alloc_bhp->mtx_buf);
- atomic_init(&alloc_bhp->ref, 1);
+ atomic_init_db(&alloc_bhp->ref, 1);
F_CLR(alloc_bhp, BH_FROZEN);
}

diff --git a/mp/mp_region.c b/mp/mp_region.c
index e6cece9..ddbe906 100644
--- a/mp/mp_region.c
+++ b/mp/mp_region.c
@@ -224,7 +224,7 @@ __memp_init(env, dbmp, reginfo_off, htab_buckets, max_nreg)
MTX_MPOOL_FILE_BUCKET, 0, &htab[i].mtx_hash)) != 0)
return (ret);
SH_TAILQ_INIT(&htab[i].hash_bucket);
- atomic_init(&htab[i].hash_page_dirty, 0);
+ atomic_init_db(&htab[i].hash_page_dirty, 0);
}

/*
@@ -269,7 +269,7 @@ __memp_init(env, dbmp, reginfo_off, htab_buckets, max_nreg)
hp->mtx_hash = (mtx_base == MUTEX_INVALID) ? MUTEX_INVALID :
mtx_base + i;
SH_TAILQ_INIT(&hp->hash_bucket);
- atomic_init(&hp->hash_page_dirty, 0);
+ atomic_init_db(&hp->hash_page_dirty, 0);
#ifdef HAVE_STATISTICS
hp->hash_io_wait = 0;
hp->hash_frozen = hp->hash_thawed = hp->hash_frozen_freed = 0;
diff --git a/mutex/mut_method.c b/mutex/mut_method.c
index 2588763..5c6d516 100644
--- a/mutex/mut_method.c
+++ b/mutex/mut_method.c
@@ -426,7 +426,7 @@ atomic_compare_exchange(env, v, oldval, newval)
MUTEX_LOCK(env, mtx);
ret = atomic_read(v) == oldval;
if (ret)
- atomic_init(v, newval);
+ atomic_init_db(v, newval);
MUTEX_UNLOCK(env, mtx);

return (ret);
diff --git a/mutex/mut_tas.c b/mutex/mut_tas.c
index f3922e0..e40fcdf 100644
--- a/mutex/mut_tas.c
+++ b/mutex/mut_tas.c
@@ -46,7 +46,7 @@ __db_tas_mutex_init(env, mutex, flags)

#ifdef HAVE_SHARED_LATCHES
if (F_ISSET(mutexp, DB_MUTEX_SHARED))
- atomic_init(&mutexp->sharecount, 0);
+ atomic_init_db(&mutexp->sharecount, 0);
else
#endif
if (MUTEX_INIT(&mutexp->tas)) {
@@ -486,7 +486,7 @@ __db_tas_mutex_unlock(env, mutex)
F_CLR(mutexp, DB_MUTEX_LOCKED);
/* Flush flag update before zeroing count */
MEMBAR_EXIT();
- atomic_init(&mutexp->sharecount, 0);
+ atomic_init_db(&mutexp->sharecount, 0);
} else {
DB_ASSERT(env, sharecount > 0);
MEMBAR_EXIT();
22 changes: 22 additions & 0 deletions depends/patches/boost/unused_var_in_process.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
commit dbd95cdaefdea95307d004f019a1c394cf9389f0
Author: fanquake <fanquake@gmail.com>
Date: Mon Aug 17 20:15:17 2020 +0800

Remove unused variable in Boost Process

This causes issues with our linters / CI.

Can be removed once depends Boost is 1.71.0 or later.

diff --git a/boost/process/detail/posix/wait_group.hpp b/boost/process/detail/posix/wait_group.hpp
index 9dc249803..2502d9772 100644
--- a/boost/process/detail/posix/wait_group.hpp
+++ b/boost/process/detail/posix/wait_group.hpp
@@ -137,7 +137,6 @@ inline bool wait_until(

do
{
- int ret_sig = 0;
int status;
if ((::waitpid(timeout_pid, &status, WNOHANG) != 0)
&& (WIFEXITED(status) || WIFSIGNALED(status)))
24 changes: 24 additions & 0 deletions depends/patches/fontconfig/gperf_header_regen.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
commit 7b6eb33ecd88768b28c67ce5d2d68a7eed5936b6
Author: fanquake <fanquake@gmail.com>
Date: Tue Aug 25 14:34:53 2020 +0800

Remove rule that causes inadvertant header regeneration

Otherwise the makefile will needlessly attempt to re-generate the
headers with gperf. This can be dropped once the upstream build is fixed.

See #10851.

diff --git a/src/Makefile.in b/src/Makefile.in
index f4626ad..4ae1b00 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -903,7 +903,7 @@ fcobjshash.gperf: fcobjshash.gperf.h fcobjs.h
' - > $@.tmp && \
mv -f $@.tmp $@ || ( $(RM) $@.tmp && false )

-fcobjshash.h: fcobjshash.gperf
+fcobjshash.h:
$(AM_V_GEN) $(GPERF) -m 100 $< > $@.tmp && \
mv -f $@.tmp $@ || ( $(RM) $@.tmp && false )

62 changes: 62 additions & 0 deletions depends/patches/fontconfig/remove_char_width_usage.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
commit 28165a9b078583dc8e9e5c344510e37582284cef
Author: fanquake <fanquake@gmail.com>
Date: Mon Aug 17 20:35:42 2020 +0800

Remove usage of CHAR_WIDTH

CHAR_WIDTH which is reserved and clashes with glibc 2.25+

See #10851.

diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h
index 5c72b22..843c532 100644
--- a/fontconfig/fontconfig.h
+++ b/fontconfig/fontconfig.h
@@ -128,7 +128,7 @@ typedef int FcBool;
#define FC_USER_CACHE_FILE ".fonts.cache-" FC_CACHE_VERSION

/* Adjust outline rasterizer */
-#define FC_CHAR_WIDTH "charwidth" /* Int */
+#define FC_CHARWIDTH "charwidth" /* Int */
#define FC_CHAR_HEIGHT "charheight"/* Int */
#define FC_MATRIX "matrix" /* FcMatrix */

diff --git a/src/fcobjs.h b/src/fcobjs.h
index 1fc4f65..d27864b 100644
--- a/src/fcobjs.h
+++ b/src/fcobjs.h
@@ -51,7 +51,7 @@ FC_OBJECT (DPI, FcTypeDouble, NULL)
FC_OBJECT (RGBA, FcTypeInteger, NULL)
FC_OBJECT (SCALE, FcTypeDouble, NULL)
FC_OBJECT (MINSPACE, FcTypeBool, NULL)
-FC_OBJECT (CHAR_WIDTH, FcTypeInteger, NULL)
+FC_OBJECT (CHARWIDTH, FcTypeInteger, NULL)
FC_OBJECT (CHAR_HEIGHT, FcTypeInteger, NULL)
FC_OBJECT (MATRIX, FcTypeMatrix, NULL)
FC_OBJECT (CHARSET, FcTypeCharSet, FcCompareCharSet)
diff --git a/src/fcobjshash.gperf b/src/fcobjshash.gperf
index 80a0237..eb4ad84 100644
--- a/src/fcobjshash.gperf
+++ b/src/fcobjshash.gperf
@@ -44,7 +44,7 @@ int id;
"rgba",FC_RGBA_OBJECT
"scale",FC_SCALE_OBJECT
"minspace",FC_MINSPACE_OBJECT
-"charwidth",FC_CHAR_WIDTH_OBJECT
+"charwidth",FC_CHARWIDTH_OBJECT
"charheight",FC_CHAR_HEIGHT_OBJECT
"matrix",FC_MATRIX_OBJECT
"charset",FC_CHARSET_OBJECT
diff --git a/src/fcobjshash.h b/src/fcobjshash.h
index 5a4d1ea..4e66bb0 100644
--- a/src/fcobjshash.h
+++ b/src/fcobjshash.h
@@ -284,7 +284,7 @@ FcObjectTypeLookup (register const char *str, register unsigned int len)
{(int)(long)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str43,FC_CHARSET_OBJECT},
{-1},
#line 47 "fcobjshash.gperf"
- {(int)(long)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str45,FC_CHAR_WIDTH_OBJECT},
+ {(int)(long)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str45,FC_CHARWIDTH_OBJECT},
#line 48 "fcobjshash.gperf"
{(int)(long)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str46,FC_CHAR_HEIGHT_OBJECT},
#line 55 "fcobjshash.gperf"
Loading

0 comments on commit 409bf19

Please sign in to comment.