forked from zcash/zcash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
depends: Fix issue cross-compiling BDB to Windows with Clang 12
- Loading branch information
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
|