Skip to content

Conversation

gruve-p
Copy link
Contributor

@gruve-p gruve-p commented Dec 15, 2020

Move away from gist patch to an embedded patch in the script with a heredoc.

@laanwj
Copy link
Member

laanwj commented Dec 16, 2020

Diff between old and new patch
--- clang.patch	2020-12-16 16:55:03.987104506 +0100
+++ clang_cxx_11.patch	2020-12-16 16:54:47.747154861 +0100
@@ -1,7 +1,13 @@
-diff --git a/src/dbinc/atomic.h b/src/dbinc/atomic.h
-index 6a858f7..9f338dc 100644
---- a/src/dbinc/atomic.h
-+++ b/src/dbinc/atomic.h
+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.
   */
@@ -38,11 +44,11 @@
  #else
  #define atomic_inc(env, p)	__atomic_inc(env, p)
  #define atomic_dec(env, p)	__atomic_dec(env, p)
-diff --git a/src/mp/mp_fget.c b/src/mp/mp_fget.c
-index 16de695..d0dcc29 100644
---- a/src/mp/mp_fget.c
-+++ b/src/mp/mp_fget.c
-@@ -649,7 +649,7 @@ alloc:		/* Allocate a new buffer header and data space. */
+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;
@@ -50,9 +56,9 @@
 +		atomic_init_db(&alloc_bhp->ref, 1);
  #ifdef DIAGNOSTIC
  		if ((uintptr_t)alloc_bhp->buf & (sizeof(size_t) - 1)) {
- 			__db_errx(env, DB_STR("3025",
-@@ -955,7 +955,7 @@ alloc:		/* Allocate a new buffer header and data space. */
- 			MVCC_MPROTECT(bhp->buf, mfp->pagesize,
+ 			__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);
@@ -60,10 +66,10 @@
  		MUTEX_LOCK(env, alloc_bhp->mtx_buf);
  		alloc_bhp->priority = bhp->priority;
  		alloc_bhp->pgno = bhp->pgno;
-diff --git a/src/mp/mp_mvcc.c b/src/mp/mp_mvcc.c
-index 770bad8..e28cce0 100644
---- a/src/mp/mp_mvcc.c
-+++ b/src/mp/mp_mvcc.c
+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));
@@ -82,11 +88,11 @@
  		F_CLR(alloc_bhp, BH_FROZEN);
  	}
  
-diff --git a/src/mp/mp_region.c b/src/mp/mp_region.c
-index 4952030..47645f8 100644
---- a/src/mp/mp_region.c
-+++ b/src/mp/mp_region.c
-@@ -245,7 +245,7 @@ __memp_init(env, dbmp, reginfo_off, htab_buckets, max_nreg)
+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);
@@ -95,20 +101,20 @@
  		}
  
  		/*
-@@ -302,7 +302,7 @@ no_prealloc:
- 		} else
- 			hp->mtx_hash = mtx_base + (i % dbenv->mp_mtxcount);
+@@ -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/src/mutex/mut_method.c b/src/mutex/mut_method.c
-index 09353b0..177353c 100644
---- a/src/mutex/mut_method.c
-+++ b/src/mutex/mut_method.c
-@@ -474,7 +474,7 @@ atomic_compare_exchange(env, v, oldval, newval)
+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)
@@ -117,11 +123,11 @@
  	MUTEX_UNLOCK(env, mtx);
  
  	return (ret);
-diff --git a/src/mutex/mut_tas.c b/src/mutex/mut_tas.c
-index 106b161..fc4de9d 100644
---- a/src/mutex/mut_tas.c
-+++ b/src/mutex/mut_tas.c
-@@ -47,7 +47,7 @@ __db_tas_mutex_init(env, mutex, flags)
+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))
@@ -130,7 +136,7 @@
  	else
  #endif
  	if (MUTEX_INIT(&mutexp->tas)) {
-@@ -536,7 +536,7 @@ __db_tas_mutex_unlock(env, mutex)
+@@ -486,7 +486,7 @@ __db_tas_mutex_unlock(env, mutex)
  			F_CLR(mutexp, DB_MUTEX_LOCKED);
  			/* Flush flag update before zeroing count */
  			MEMBAR_EXIT();
@@ -138,4 +144,4 @@
 +			atomic_init_db(&mutexp->sharecount, 0);
  		} else {
  			DB_ASSERT(env, sharecount > 0);
- 			MEMBAR_EXIT();
\ No newline at end of file
+ 			MEMBAR_EXIT();

@gruve-p gruve-p changed the title Build: update clang patch url and hash Build: update clang patch to use heredoc Jan 6, 2021
Copy link

@felipsoarez felipsoarez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

Copy link

@richardsonmark316 richardsonmark316 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fanquake
Copy link
Member

@gruve-p can you squash your commits.

@gruve-p gruve-p closed this Jan 10, 2021
@gruve-p
Copy link
Contributor Author

gruve-p commented Jan 10, 2021

@fanquake Squashed

@gruve-p gruve-p reopened this Jan 10, 2021
@gruve-p
Copy link
Contributor Author

gruve-p commented Jan 10, 2021

Ready for rereview @laanwj

@fanquake
Copy link
Member

When I asked you to squash I'd assumed you'd actually tested that this works. I've checked that this produces the same libdb_cxx-4.8.a & libdb-4.8.a, however, as is, the patch wont apply:

CFLAGS="-Wno-error=implicit-function-declaration" ./contrib/install_db4.sh $(pwd)
...
x db-4.8.30.NC/txn/txn_stat.c
x db-4.8.30.NC/txn/txn_util.c
can't find file to patch at input line 11
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|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
--------------------------
File to patch:

You'll need to fix the paths, something like:

diff --git a/contrib/install_db4.sh b/contrib/install_db4.sh
index 0a022229e..3c88de16e 100755
--- a/contrib/install_db4.sh
+++ b/contrib/install_db4.sh
@@ -75,10 +75,10 @@ Date:   Mon Aug 17 20:03:56 2020 +0800
 
     Fix C++11 compatibility
 
-diff --git a/dbinc/atomic.h b/dbinc/atomic.h
+diff --git a/src/dbinc/atomic.h b/src/dbinc/atomic.h
 index 0034dcc..7c11d4a 100644
---- a/dbinc/atomic.h
-+++ b/dbinc/atomic.h
+--- a/src/dbinc/atomic.h
++++ b/src/dbinc/atomic.h
 @@ -70,7 +70,7 @@ typedef struct {
   * These have no memory barriers; the caller must include them when necessary.
   */
@@ -115,10 +115,10 @@ index 0034dcc..7c11d4a 100644
  #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
+diff --git a/src/mp/mp_fget.c b/src/mp/mp_fget.c
 index 5fdee5a..0b75f57 100644
---- a/mp/mp_fget.c
-+++ b/mp/mp_fget.c
+--- a/src/mp/mp_fget.c
++++ b/src/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. */
@@ -137,10 +137,10 @@ index 5fdee5a..0b75f57 100644
  		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
+diff --git a/src/mp/mp_mvcc.c b/src/mp/mp_mvcc.c
 index 34467d2..f05aa0c 100644
---- a/mp/mp_mvcc.c
-+++ b/mp/mp_mvcc.c
+--- a/src/mp/mp_mvcc.c
++++ b/src/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));
@@ -159,10 +159,10 @@ index 34467d2..f05aa0c 100644
  		F_CLR(alloc_bhp, BH_FROZEN);
  	}
 
-diff --git a/mp/mp_region.c b/mp/mp_region.c
+diff --git a/src/mp/mp_region.c b/src/mp/mp_region.c
 index e6cece9..ddbe906 100644
---- a/mp/mp_region.c
-+++ b/mp/mp_region.c
+--- a/src/mp/mp_region.c
++++ b/src/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);
@@ -181,10 +181,10 @@ index e6cece9..ddbe906 100644
  #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
+diff --git a/src/mutex/mut_method.c b/src/mutex/mut_method.c
 index 2588763..5c6d516 100644
---- a/mutex/mut_method.c
-+++ b/mutex/mut_method.c
+--- a/src/mutex/mut_method.c
++++ b/src/mutex/mut_method.c
 @@ -426,7 +426,7 @@ atomic_compare_exchange(env, v, oldval, newval)
  	MUTEX_LOCK(env, mtx);
  	ret = atomic_read(v) == oldval;
@@ -194,10 +194,10 @@ index 2588763..5c6d516 100644
  	MUTEX_UNLOCK(env, mtx);
 
  	return (ret);
-diff --git a/mutex/mut_tas.c b/mutex/mut_tas.c
+diff --git a/src/mutex/mut_tas.c b/src/mutex/mut_tas.c
 index f3922e0..e40fcdf 100644
---- a/mutex/mut_tas.c
-+++ b/mutex/mut_tas.c
+--- a/src/mutex/mut_tas.c
++++ b/src/mutex/mut_tas.c
 @@ -46,7 +46,7 @@ __db_tas_mutex_init(env, mutex, flags)
 
  #ifdef HAVE_SHARED_LATCHES

Once you're done fixing the changes, make sure you've squashed to a single commit, and write a more meaningful commit message, i.e: "contrib: embed C++11 patch in install_db4.sh" & explain why it's being done.

Also, in future, please don't open new PRs for the same change.

@gruve-p gruve-p closed this Jan 11, 2021
@gruve-p gruve-p changed the title Build: update clang patch to use heredoc contrib: embed C++11 patch in install_db4.sh Jan 11, 2021
@gruve-p
Copy link
Contributor Author

gruve-p commented Jan 11, 2021

@fanquake Fixed, squashed, changed commit message, force pushed then the PR closed again. Can you reopen it?

@fanquake
Copy link
Member

It's no longer possible to reopen this PR, probably because you force pushed to the branch while the PR was closed, so you will actually have to open another now.

@gruve-p
Copy link
Contributor Author

gruve-p commented Jan 11, 2021

New one opened

laanwj added a commit to bitcoin-core/gui that referenced this pull request Jan 19, 2021
9237003 contrib: embed C++11 patch in install_db4.sh (jackielove4u)

Pull request description:

  This is a continuation of bitcoin/bitcoin#20665.

  Closes #20722.

ACKs for top commit:
  laanwj:
    ACK 9237003
  fanquake:
    ACK 9237003.

Tree-SHA512: ebfd16f5301158de1acc1b8eeca43b3d94f0a6d438832133a30648e5e8a88268b4af983be0bb57f3018e3af8459f32f0de676c1b4e8942e199a4497c776631c5
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jan 20, 2021
9237003 contrib: embed C++11 patch in install_db4.sh (jackielove4u)

Pull request description:

  This is a continuation of bitcoin#20665.

  Closes bitcoin#20722.

ACKs for top commit:
  laanwj:
    ACK 9237003
  fanquake:
    ACK 9237003.

Tree-SHA512: ebfd16f5301158de1acc1b8eeca43b3d94f0a6d438832133a30648e5e8a88268b4af983be0bb57f3018e3af8459f32f0de676c1b4e8942e199a4497c776631c5
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants