diff --git a/depends/packages/bdb.mk b/depends/packages/bdb.mk index 13929f2174f..350816eeb5e 100644 --- a/depends/packages/bdb.mk +++ b/depends/packages/bdb.mk @@ -4,7 +4,7 @@ $(package)_download_path=https://download.oracle.com/berkeley-db $(package)_file_name=db-$($(package)_version).tar.gz $(package)_sha256_hash=47612c8991aa9ac2f6be721267c8d3cdccf5ac83105df8e50809daea24e95dc7 $(package)_build_subdir=build_unix -$(package)_patches=winioctl-and-atomic_init_db.patch +$(package)_patches=clang-12-stpcpy-issue.diff winioctl-and-atomic_init_db.patch ifneq ($(host_os),darwin) $(package)_dependencies=libcxx @@ -30,6 +30,7 @@ endif endef define $(package)_preprocess_cmds + patch -p1 <$($(package)_patch_dir)/clang-12-stpcpy-issue.diff && \ patch -p1 <$($(package)_patch_dir)/winioctl-and-atomic_init_db.patch endef diff --git a/depends/patches/bdb/clang-12-stpcpy-issue.diff b/depends/patches/bdb/clang-12-stpcpy-issue.diff new file mode 100644 index 00000000000..4af13de0d0e --- /dev/null +++ b/depends/patches/bdb/clang-12-stpcpy-issue.diff @@ -0,0 +1,25 @@ +diff -ur db-6.2.23-orig/src/blob/blob_util.c db-6.2.23/src/blob/blob_util.c +--- db-6.2.23-orig/src/blob/blob_util.c 2016-03-28 20:45:53.000000000 +0100 ++++ db-6.2.23/src/blob/blob_util.c 2021-07-30 18:07:29.942811600 +0100 +@@ -544,7 +544,20 @@ + goto err; + + memset(path, 0, len); +- name_len += sprintf(path, "%s", blob_sub_dir); ++ // name_len += sprintf(path, "%s", blob_sub_dir); ++ { ++ // Clang 12 introduced an "libcall optimization" that lowers the above ++ // to stpcpy to avoid the machinery involved in parsing format strings. ++ // This causes build problems when cross-compiling to Windows with the ++ // version of mingw-w64 that Zcash supports. We haven't figured out why ++ // but in the meantime we replace this with an inlined stpcpy impl from ++ // https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=5934637641c863cc2c1765a0d01c5b6f53ecc4fc ++ char *dest = path; ++ const char *src = blob_sub_dir; ++ while ((*dest++ = *src++) != '\0') ++ /* nothing */; ++ name_len += (--dest - path); ++ } + + __blob_calculate_dirs(blob_id, path, &name_len, &depth); +