From 1a7a3a7ecf03aa548e4e3d18c5d2065cc303367b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Robert=20F=C3=B6rster?= <Dessa@gmake.de>
Date: Fri, 13 Dec 2024 15:42:56 +0100
Subject: [PATCH] [dev-db/mongodb] sync with tree, untested

---
 dev-db/mongodb/Manifest                       |  6 +-
 ...0.26-mozjs-remove-unused-constructor.patch | 25 +++++++
 .../mongodb/files/mongodb-5.0.26-scons.patch  | 27 +++++++
 dev-db/mongodb/metadata.xml                   |  1 -
 dev-db/mongodb/mongodb-5.0.30.ebuild          |  4 +-
 dev-db/mongodb/mongodb-6.0.19.ebuild          | 73 ++-----------------
 dev-db/mongodb/mongodb-7.0.15.ebuild          | 73 ++-----------------
 7 files changed, 68 insertions(+), 141 deletions(-)
 create mode 100644 dev-db/mongodb/files/mongodb-5.0.26-mozjs-remove-unused-constructor.patch
 create mode 100644 dev-db/mongodb/files/mongodb-5.0.26-scons.patch

diff --git a/dev-db/mongodb/Manifest b/dev-db/mongodb/Manifest
index 45b698e..5bfdd39 100644
--- a/dev-db/mongodb/Manifest
+++ b/dev-db/mongodb/Manifest
@@ -1,3 +1,3 @@
-DIST mongodb-5.0.30.tar.gz 57312372 BLAKE2B 72b026115cf3c8b1b81857bc5bffcd5b72bae4b581a7ada598bc7bbe594f264f581212159788113c5709ab751dd8a57943a3cc9b78f0d31aeb50375fa1da2c28 SHA512 97642da12cf199fa3f17825b1eb20e4d9bc1f65c8950f54b36347af11b6964cdd2007d11b01147d0c253077ef14121de52517c1739b433b49a9cbbe2596d9d05
-DIST mongodb-6.0.19.tar.gz 87631425 BLAKE2B 94951b278273ecf8e091bdb9cebd9592f579ed9fe630ef7864a91b1ca95a2df20c9080ebfaa6ebffb4c07c002cdc21a2da62575292f9295293b1c25e2d3fb1e9 SHA512 6b53616c25a8a6ff5beca00df6e8bd8f032d17647aab8fd896d1376d4a60030ed9f6db620682308076719ead181931610d9447567f09e7dec2d4005814e1133b
-DIST mongodb-7.0.15.tar.gz 87140137 BLAKE2B e569fa4bbfdc631060071868872da57258ee1b43a6d79efb431baa33c88da405bc52f9b2b95290dbc93bc09b49cb0413b6013bdefba37a4e9acd75fccfe85e77 SHA512 79c7c3651944e37c624f8bfeb79d161b3f3f67ed8243f114f0ed943ced5f9734ef464b15a575ee6d83892728fb2b584fd943ff0dc8576c290a170c374331e6d8
+DIST mongodb-5.0.30.gh.tar.gz 57312372 BLAKE2B 72b026115cf3c8b1b81857bc5bffcd5b72bae4b581a7ada598bc7bbe594f264f581212159788113c5709ab751dd8a57943a3cc9b78f0d31aeb50375fa1da2c28 SHA512 97642da12cf199fa3f17825b1eb20e4d9bc1f65c8950f54b36347af11b6964cdd2007d11b01147d0c253077ef14121de52517c1739b433b49a9cbbe2596d9d05
+DIST mongodb-6.0.19.gh.tar.gz 87631425 BLAKE2B 94951b278273ecf8e091bdb9cebd9592f579ed9fe630ef7864a91b1ca95a2df20c9080ebfaa6ebffb4c07c002cdc21a2da62575292f9295293b1c25e2d3fb1e9 SHA512 6b53616c25a8a6ff5beca00df6e8bd8f032d17647aab8fd896d1376d4a60030ed9f6db620682308076719ead181931610d9447567f09e7dec2d4005814e1133b
+DIST mongodb-7.0.15.gh.tar.gz 87140137 BLAKE2B e569fa4bbfdc631060071868872da57258ee1b43a6d79efb431baa33c88da405bc52f9b2b95290dbc93bc09b49cb0413b6013bdefba37a4e9acd75fccfe85e77 SHA512 79c7c3651944e37c624f8bfeb79d161b3f3f67ed8243f114f0ed943ced5f9734ef464b15a575ee6d83892728fb2b584fd943ff0dc8576c290a170c374331e6d8
diff --git a/dev-db/mongodb/files/mongodb-5.0.26-mozjs-remove-unused-constructor.patch b/dev-db/mongodb/files/mongodb-5.0.26-mozjs-remove-unused-constructor.patch
new file mode 100644
index 0000000..0b5058c
--- /dev/null
+++ b/dev-db/mongodb/files/mongodb-5.0.26-mozjs-remove-unused-constructor.patch
@@ -0,0 +1,25 @@
+https://phabricator.services.mozilla.com/D209108
+https://github.com/mozilla/gecko-dev/commit/33cdc6655b0de44cb7a431216dcbb0d5a552aec6
+
+clang 19 will report error if w/o this patch:
+
+  src/third_party/mozjs-60/extract/js/src/threading/ExclusiveData.h:124:33: error: reference to non-static member function must be called
+
+diff --git a/src/third_party/mozjs-60/extract/js/src/threading/ExclusiveData.h b/src/third_party/mozjs-60/extract/js/src/threading/ExclusiveData.h
+index 25b977e..379a509 100644
+--- a/src/third_party/mozjs-60/extract/js/src/threading/ExclusiveData.h
++++ b/src/third_party/mozjs-60/extract/js/src/threading/ExclusiveData.h
+@@ -120,13 +120,6 @@ class ExclusiveData
+         release();
+     }
+ 
+-    ExclusiveData(ExclusiveData&& rhs)
+-      : lock_(mozilla::Move(rhs.lock))
+-    {
+-        MOZ_ASSERT(&rhs != this, "self-move disallowed!");
+-        new (mozilla::KnownNotNull, value_.addr()) T(mozilla::Move(*rhs.value_.addr()));
+-    }
+-
+     ExclusiveData& operator=(ExclusiveData&& rhs) {
+         this->~ExclusiveData();
+         new (mozilla::KnownNotNull, this) ExclusiveData(mozilla::Move(rhs));
diff --git a/dev-db/mongodb/files/mongodb-5.0.26-scons.patch b/dev-db/mongodb/files/mongodb-5.0.26-scons.patch
new file mode 100644
index 0000000..2bb9c52
--- /dev/null
+++ b/dev-db/mongodb/files/mongodb-5.0.26-scons.patch
@@ -0,0 +1,27 @@
+https://jira.mongodb.org/browse/SERVER-94430 Upstream respond:
+
+> we intentionally do not ingest the environment PATH as this makes build
+> reproducibility and hermiticity much harder. Instead, you should set the
+> absolute paths to the tools you want to use on the command line, instead of
+> relying on the PATH.
+
+Gentoo bug https://bugs.gentoo.org/829340
+
+In Gentoo, we have LLVM slotted and we put clang in /usr/lib/llvm/18/bin (or
+whatever), not in /usr/bin, and if upstream strip PATH and construct it
+themselves, they surely won't contain this location.
+
+So we add PATH backup for scons.
+diff --git a/SConstruct b/SConstruct
+index 3d831c9..f07feeb 100644
+--- a/SConstruct
++++ b/SConstruct
+@@ -1201,7 +1201,7 @@ envDict = dict(BUILD_ROOT=buildDir,
+ if get_option('build-tools') == 'next':
+     SCons.Tool.DefaultToolpath.insert(0, os.path.abspath('site_scons/site_tools/next'))
+ 
+-env = Environment(variables=env_vars, **envDict)
++env = Environment(variables=env_vars, ENV={'PATH': os.environ['PATH']}, **envDict)
+ del envDict
+ 
+ if get_option('cache-signature-mode') == 'validate':
diff --git a/dev-db/mongodb/metadata.xml b/dev-db/mongodb/metadata.xml
index d770d31..c8d28f3 100644
--- a/dev-db/mongodb/metadata.xml
+++ b/dev-db/mongodb/metadata.xml
@@ -14,7 +14,6 @@
 	and powerful queries).
 	</longdescription>
 	<use>
-		<flag name="clang">Use clang compiler instead of GCC</flag>
 		<flag name="mongosh">Install the MongoDB shell from <pkg>app-admin/mongosh-bin</pkg></flag>
 		<flag name="tools">Install the MongoDB tools (mongoimport, mongodump...) from <pkg>app-admin/mongo-tools</pkg></flag>
 	</use>
diff --git a/dev-db/mongodb/mongodb-5.0.30.ebuild b/dev-db/mongodb/mongodb-5.0.30.ebuild
index 52073bf..a361c09 100644
--- a/dev-db/mongodb/mongodb-5.0.30.ebuild
+++ b/dev-db/mongodb/mongodb-5.0.30.ebuild
@@ -17,7 +17,7 @@ MY_P=mongo-${MY_PV}
 
 DESCRIPTION="A high-performance, open source, schema-free document-oriented database"
 HOMEPAGE="https://www.mongodb.com"
-SRC_URI="https://github.com/mongodb/mongo/archive/refs/tags/${MY_PV}.tar.gz -> ${P}.tar.gz"
+SRC_URI="https://github.com/mongodb/mongo/archive/refs/tags/${MY_PV}.tar.gz -> ${P}.gh.tar.gz"
 S="${WORKDIR}/${MY_P}"
 
 LICENSE="Apache-2.0 SSPL-1"
@@ -78,6 +78,8 @@ PATCHES=(
 	"${FILESDIR}/${PN}-5.0.26-boost-1.85.patch"
 	"${FILESDIR}/${PN}-5.0.26-boost-1.85-extra.patch"
 	"${FILESDIR}/${PN}-5.0.30-gcc-15.patch"
+	"${FILESDIR}/${PN}-5.0.26-scons.patch"
+	"${FILESDIR}/${PN}-5.0.26-mozjs-remove-unused-constructor.patch"
 )
 
 python_check_deps() {
diff --git a/dev-db/mongodb/mongodb-6.0.19.ebuild b/dev-db/mongodb/mongodb-6.0.19.ebuild
index 2953004..d531103 100644
--- a/dev-db/mongodb/mongodb-6.0.19.ebuild
+++ b/dev-db/mongodb/mongodb-6.0.19.ebuild
@@ -3,9 +3,6 @@
 
 EAPI=8
 
-LLVM_COMPAT=( 18 )
-LLVM_OPTIONAL=1
-
 PYTHON_COMPAT=( python3_{10..13} )
 
 SCONS_MIN_VERSION="3.3.1"
@@ -13,22 +10,21 @@ CHECKREQS_DISK_BUILD="2400M"
 CHECKREQS_DISK_USR="512M"
 CHECKREQS_MEMORY="1024M"
 
-inherit check-reqs flag-o-matic llvm-r1 multiprocessing optfeature pax-utils python-any-r1 \
-		scons-utils systemd tmpfiles toolchain-funcs
+inherit check-reqs flag-o-matic multiprocessing pax-utils python-any-r1 scons-utils systemd toolchain-funcs
 
 MY_PV=r${PV/_rc/-rc}
 MY_P=mongo-${MY_PV}
 
 DESCRIPTION="A high-performance, open source, schema-free document-oriented database"
 HOMEPAGE="https://www.mongodb.com"
-SRC_URI="https://github.com/mongodb/mongo/archive/refs/tags/${MY_PV}.tar.gz -> ${P}.tar.gz"
+SRC_URI="https://github.com/mongodb/mongo/archive/refs/tags/${MY_PV}.tar.gz -> ${P}.gh.tar.gz"
 S="${WORKDIR}/${MY_P}"
 
 LICENSE="Apache-2.0 SSPL-1"
 SLOT="0"
 KEYWORDS="~amd64 ~arm64 -riscv"
 CPU_FLAGS="cpu_flags_x86_avx"
-IUSE="clang debug kerberos ssl ${CPU_FLAGS}"
+IUSE="debug kerberos ssl ${CPU_FLAGS}"
 
 # https://github.com/mongodb/mongo/wiki/Test-The-Mongodb-Server
 # resmoke needs python packages not yet present in Gentoo
@@ -54,12 +50,6 @@ DEPEND="${RDEPEND}
 	sys-libs/readline:0=
 	debug? ( dev-debug/valgrind )"
 BDEPEND="
-	clang? (
-		$(llvm_gen_dep "
-			sys-devel/clang:\${LLVM_SLOT}
-			sys-devel/llvm:\${LLVM_SLOT}
-		")
-	)
 	$(python_gen_any_dep '
 		>=dev-build/scons-3.1.1[${PYTHON_USEDEP}]
 		dev-python/cheetah3[${PYTHON_USEDEP}]
@@ -85,6 +75,8 @@ PATCHES=(
 	"${FILESDIR}/${PN}-5.0.26-boost-1.85.patch"
 	"${FILESDIR}/${PN}-6.0.18-boost-1.85.patch"
 	"${FILESDIR}/${PN}-5.0.30-gcc-15.patch"
+	"${FILESDIR}/${PN}-5.0.26-scons.patch"
+	"${FILESDIR}/${PN}-5.0.26-mozjs-remove-unused-constructor.patch"
 )
 
 python_check_deps() {
@@ -117,13 +109,6 @@ pkg_pretend() {
 	fi
 }
 
-pkg_setup() {
-	python-any-r1_pkg_setup
-	if use clang; then
-		llvm-r1_pkg_setup
-	fi
-}
-
 src_prepare() {
 	default
 
@@ -155,54 +140,6 @@ src_configure() {
 		--use-system-zstd
 	)
 
-	local have_switched_compiler=
-	if use clang && ! tc-is-clang || tc-is-clang; then
-		# Force clang
-		local version_clang=$(clang --version 2>/dev/null | grep -F -- 'clang version' | awk '{ print $3 }')
-		[[ -n ${version_clang} ]] && version_clang=$(ver_cut 1 "${version_clang}")
-		[[ -z ${version_clang} ]] && die "Failed to read clang version!"
-
-		if tc-is-gcc; then
-			have_switched_compiler=yes
-		fi
-
-		AR=llvm-ar
-		CC=${CHOST}-clang-${version_clang}
-		CXX=${CHOST}-clang++-${version_clang}
-
-		scons_opts+=(
-			AR="$(get_llvm_prefix)/bin/${AR}"
-			CC="$(get_llvm_prefix)/bin/${CC}"
-			CXX="$(get_llvm_prefix)/bin/${CXX}"
-		)
-	elif ! use clang && ! tc-is-gcc ; then
-		# Force gcc
-		have_switched_compiler=yes
-		AR=gcc-ar
-		CC=${CHOST}-gcc
-		CXX=${CHOST}-g++
-		scons_opts+=(
-			AR="${AR}"
-			CC="${CC}"
-			CXX="${CXX}"
-		)
-	else
-		scons_opts+=(
-			AR="$(tc-getAR)"
-			CC="$(tc-getCC)"
-			CXX="$(tc-getCXX)"
-		)
-	fi
-
-	if [[ -n "${have_switched_compiler}" ]] ; then
-		# Because we switched active compiler we have to ensure
-		# that no unsupported flags are set
-		strip-unsupported-flags
-		scons_opts+=(
-			CCFLAGS="${CXXFLAGS}"
-		)
-	fi
-
 	use arm64 && scons_opts+=( --use-hardware-crc32=off ) # Bug 701300
 	use amd64 && scons_opts+=( --experimental-optimization=-sandybridge ) # Bug 890294
 	use debug && scons_opts+=( --dbg=on )
diff --git a/dev-db/mongodb/mongodb-7.0.15.ebuild b/dev-db/mongodb/mongodb-7.0.15.ebuild
index 414db31..3f6226b 100644
--- a/dev-db/mongodb/mongodb-7.0.15.ebuild
+++ b/dev-db/mongodb/mongodb-7.0.15.ebuild
@@ -3,9 +3,6 @@
 
 EAPI=8
 
-LLVM_COMPAT=( 18 )
-LLVM_OPTIONAL=1
-
 PYTHON_COMPAT=( python3_{10..13} )
 
 SCONS_MIN_VERSION="3.3.1"
@@ -13,22 +10,21 @@ CHECKREQS_DISK_BUILD="2400M"
 CHECKREQS_DISK_USR="512M"
 CHECKREQS_MEMORY="1024M"
 
-inherit check-reqs flag-o-matic llvm-r1 multiprocessing optfeature pax-utils python-any-r1 \
-		scons-utils systemd tmpfiles toolchain-funcs
+inherit check-reqs flag-o-matic multiprocessing pax-utils python-any-r1 scons-utils systemd toolchain-funcs
 
 MY_PV=r${PV/_rc/-rc}
 MY_P=mongo-${MY_PV}
 
 DESCRIPTION="A high-performance, open source, schema-free document-oriented database"
 HOMEPAGE="https://www.mongodb.com"
-SRC_URI="https://github.com/mongodb/mongo/archive/refs/tags/${MY_PV}.tar.gz -> ${P}.tar.gz"
+SRC_URI="https://github.com/mongodb/mongo/archive/refs/tags/${MY_PV}.tar.gz -> ${P}.gh.tar.gz"
 S="${WORKDIR}/${MY_P}"
 
 LICENSE="Apache-2.0 SSPL-1"
 SLOT="0"
 KEYWORDS="~amd64 ~arm64 -riscv"
 CPU_FLAGS="cpu_flags_x86_avx"
-IUSE="clang debug kerberos ssl ${CPU_FLAGS}"
+IUSE="debug kerberos ssl ${CPU_FLAGS}"
 
 # https://github.com/mongodb/mongo/wiki/Test-The-Mongodb-Server
 # resmoke needs python packages not yet present in Gentoo
@@ -54,12 +50,6 @@ DEPEND="${RDEPEND}
 	sys-libs/readline:0=
 	debug? ( dev-debug/valgrind )"
 BDEPEND="
-	clang? (
-		$(llvm_gen_dep "
-			sys-devel/clang:\${LLVM_SLOT}
-			sys-devel/llvm:\${LLVM_SLOT}
-		")
-	)
 	$(python_gen_any_dep '
 		>=dev-build/scons-3.1.1[${PYTHON_USEDEP}]
 		dev-python/cheetah3[${PYTHON_USEDEP}]
@@ -78,6 +68,8 @@ PATCHES=(
 	"${FILESDIR}/${PN}-4.4.29-no-enterprise.patch"
 	"${FILESDIR}/${PN}-7.0.15-system-boost.patch"
 	"${FILESDIR}/${PN}-7.0.15-gcc-15.patch"
+	"${FILESDIR}/${PN}-5.0.26-scons.patch"
+	"${FILESDIR}/${PN}-5.0.26-mozjs-remove-unused-constructor.patch"
 )
 
 python_check_deps() {
@@ -110,13 +102,6 @@ pkg_pretend() {
 	fi
 }
 
-pkg_setup() {
-	python-any-r1_pkg_setup
-	if use clang; then
-		llvm-r1_pkg_setup
-	fi
-}
-
 src_prepare() {
 	default
 
@@ -148,54 +133,6 @@ src_configure() {
 		--use-system-zstd
 	)
 
-	local have_switched_compiler=
-	if use clang && ! tc-is-clang || tc-is-clang; then
-		# Force clang
-		local version_clang=$(clang --version 2>/dev/null | grep -F -- 'clang version' | awk '{ print $3 }')
-		[[ -n ${version_clang} ]] && version_clang=$(ver_cut 1 "${version_clang}")
-		[[ -z ${version_clang} ]] && die "Failed to read clang version!"
-
-		if tc-is-gcc; then
-			have_switched_compiler=yes
-		fi
-
-		AR=llvm-ar
-		CC=${CHOST}-clang-${version_clang}
-		CXX=${CHOST}-clang++-${version_clang}
-
-		scons_opts+=(
-			AR="$(get_llvm_prefix)/bin/${AR}"
-			CC="$(get_llvm_prefix)/bin/${CC}"
-			CXX="$(get_llvm_prefix)/bin/${CXX}"
-		)
-	elif ! use clang && ! tc-is-gcc ; then
-		# Force gcc
-		have_switched_compiler=yes
-		AR=gcc-ar
-		CC=${CHOST}-gcc
-		CXX=${CHOST}-g++
-		scons_opts+=(
-			AR="${AR}"
-			CC="${CC}"
-			CXX="${CXX}"
-		)
-	else
-		scons_opts+=(
-			AR="$(tc-getAR)"
-			CC="$(tc-getCC)"
-			CXX="$(tc-getCXX)"
-		)
-	fi
-
-	if [[ -n "${have_switched_compiler}" ]] ; then
-		# Because we switched active compiler we have to ensure
-		# that no unsupported flags are set
-		strip-unsupported-flags
-		scons_opts+=(
-			CCFLAGS="${CXXFLAGS}"
-		)
-	fi
-
 	use arm64 && scons_opts+=( --use-hardware-crc32=off ) # Bug 701300
 	use amd64 && scons_opts+=( --experimental-optimization=-sandybridge ) # Bug 890294
 	use debug && scons_opts+=( --dbg=on )