public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: dev-util/llvm-mingw64/
@ 2025-06-08 12:03 Sam James
  0 siblings, 0 replies; 5+ messages in thread
From: Sam James @ 2025-06-08 12:03 UTC (permalink / raw
  To: gentoo-commits

commit:     1484b937cec57edf859690e82c2b2e2ba9ee2e9e
Author:     Sasha Finkelstein <fnkl.kernel <AT> gmail <DOT> com>
AuthorDate: Thu May  1 12:29:07 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jun  8 12:02:49 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1484b937

dev-util/llvm-mingw64: New package, add 12.0.0

Signed-off-by: Sasha Finkelstein <fnkl.kernel <AT> gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/42493
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-util/llvm-mingw64/Manifest                   |   2 +
 dev-util/llvm-mingw64/llvm-mingw64-12.0.0.ebuild | 287 +++++++++++++++++++++++
 dev-util/llvm-mingw64/metadata.xml               |  11 +
 3 files changed, 300 insertions(+)

diff --git a/dev-util/llvm-mingw64/Manifest b/dev-util/llvm-mingw64/Manifest
new file mode 100644
index 000000000000..10a2abfb4144
--- /dev/null
+++ b/dev-util/llvm-mingw64/Manifest
@@ -0,0 +1,2 @@
+DIST llvm-project-20.1.6.src.tar.xz 147239668 BLAKE2B ccd86730fdea3dd40ebf054661b854b9332204389db2205e1e7b2a7f140fc187cacb34de68aa9a63c15c1e17b1d0976c080cfdee7e2cb6b0dd5570001d84be12 SHA512 aae652fdc61bda3f80b1340a3270b687355bfb6817f4bc05dac2268a2f8c5fc677eadb515cda7c8518005f1dc39e7ce5d1c34bbc5a25f106ef8e6c8f1ecfdf6d
+DIST mingw-w64-v12.0.0.tar.bz2 10474283 BLAKE2B 6500045f7d77f7de01dea0f4e03f3e4ddf6154586c5e3ee9718ee2c7ef1cc83ce3cbd644b6f1dc293ae6e0bfb55a6b68d439622bd1cfdefefc4cc547317f1943 SHA512 949b2bfab8763ab10ec4e9fdfdaf5361517a4ab787fb98ab419b38d02694061c2e821ebbf6e2e4b39d92bdf17419d116daa8e63afd9e01d11592f39df4da69d7

diff --git a/dev-util/llvm-mingw64/llvm-mingw64-12.0.0.ebuild b/dev-util/llvm-mingw64/llvm-mingw64-12.0.0.ebuild
new file mode 100644
index 000000000000..013b5556f50b
--- /dev/null
+++ b/dev-util/llvm-mingw64/llvm-mingw64-12.0.0.ebuild
@@ -0,0 +1,287 @@
+# Copyright 2022-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit edo ninja-utils flag-o-matic toolchain-funcs
+
+MINGW_PV=$(ver_cut 1-3)
+LLVM_PV=20.1.6
+LLVM_MAJOR=$(ver_cut 1 ${LLVM_PV})
+
+DESCRIPTION="Clang/LLVM based mingw64 toolchain"
+HOMEPAGE="
+	https://www.mingw-w64.org/
+"
+SRC_URI="
+	https://downloads.sourceforge.net/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v${MINGW_PV}.tar.bz2
+	https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_PV}/llvm-project-${LLVM_PV}.src.tar.xz
+"
+S="${WORKDIR}"
+
+LICENSE="
+	Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )
+	ZPL BSD BSD-2 ISC LGPL-2+ LGPL-2.1+ MIT public-domain
+"
+SLOT="0"
+KEYWORDS="~arm64"
+IUSE="custom-cflags +strip"
+
+BDEPEND="
+	dev-build/cmake
+"
+
+RDEPEND="
+	llvm-core/clang:${LLVM_MAJOR}
+	llvm-core/llvm:${LLVM_MAJOR}
+	llvm-core/lld:${LLVM_MAJOR}
+"
+DEPEND="${RDEPEND}"
+
+HOSTS=(
+	aarch64-w64-mingw32
+#	i686-w64-mingw32
+)
+
+pkg_pretend() {
+	[[ ${MERGE_TYPE} == binary ]] && return
+
+	tc-is-cross-compiler &&
+		die "cross-compilation of the toolchain itself is unsupported"
+}
+
+src_prepare() {
+	# rename directories to simplify both patching and the ebuild
+	mv mingw-w64-v${MINGW_PV} mingw64 || die
+	mv llvm-project-${LLVM_PV}.src llvm-project || die
+	default
+}
+
+src_compile() {
+	# not great but do everything in src_compile given bootstrapping
+	# process needs to be done in steps of configure+compile+install
+	# (done modular to have most package-specific things in one place)
+
+	MWT_D=${T}/root # moved to ${D} in src_install
+	mwtdir=/usr/lib/${PN}
+	prefix=${EPREFIX}${mwtdir}
+	sysroot=${MWT_D}${prefix}
+	PATH=${sysroot}/bin:${PATH}
+
+	unset AR CC CPP CXX DLLTOOL LD NM OBJCOPY OBJDUMP RANLIB RC STRIP
+
+	export AR=llvm-ar
+	export CC=clang
+	export CXX=clang++
+	export NM=llvm-nm
+	export RANLIB=llvm-ranlib
+	export STRIP=llvm-strip
+
+	filter-flags '-fuse-ld=*'
+	filter-flags '-mfunction-return=thunk*' #878849
+
+	use custom-cflags || filter-flags '-fstack-protector*' #931512
+
+	filter-flags '-Wl,-z,*'
+	append-flags -mno-avx
+
+	filter-lto # requires setting up, and may be messy with mingw static libs
+	use custom-cflags || strip-flags # fancy flags are not realistic here
+
+	local -A lib_hosts=(
+		aarch64-w64-mingw32 "--disable-lib32 --disable-lib64 --enable-libarm64"
+		i686-w64-mingw32 "--enable-lib32 --disable-lib64 --disable-libarm64"
+	)
+	for CHOST in ${HOSTS[@]}; do
+		( per_host_compile ${lib_hosts[${CHOST}]} )
+
+		# portage doesn't know the right strip executable to use for CTARGET
+		# and it can lead to .a mangling, notably with 32bit (breaks toolchain)
+		dostrip -x ${mwtdir}/${CHOST}/lib{,32}
+		dostrip -x /usr/lib/llvm/${LLVM_MAJOR}/${CHOST}/lib/lib{c++,unwind}.dll.a
+	done
+}
+
+per_host_compile() {
+	CC="${CC} -target ${CHOST}" \
+	  CXX="${CXX} -target ${CHOST}" \
+	  LD="${LD} -target ${CHOST}" \
+	  strip-unsupported-flags
+
+	local conf_mingw64=(
+		--build=${CBUILD}
+		--prefix="${prefix}"/${CHOST}
+		--host=${CHOST}
+		--with-sysroot=no
+		--without-{crt,headers}
+
+		# mingw .dll aren't used by wine and packages wouldn't find them
+		# at runtime, use crossdev if need dll and proper search paths
+		--disable-shared
+	)
+
+	local conf_mingw64_headers=(
+		--enable-idl
+		--with-headers
+	)
+
+	local conf_mingw64_runtime=(
+		--with-crt $@
+	)
+
+	local conf_mingw64_libraries=( --with-libraries="winpthreads" )
+
+	mwt-build() {
+		local id=${1##*/}
+		local build_dir=${WORKDIR}/${1}${2+_${2}}-${CHOST}-build
+
+		# econf is not allowed in src_compile and its defaults are
+		# mostly unused here, so use configure directly
+		local conf=( "${WORKDIR}/${1}"/configure )
+
+		local -n conf_id=conf_${id} conf_id2=conf_${id}_${2}
+		[[ ${conf_id@a} == *a* ]] && conf+=( "${conf_id[@]}" )
+		[[ ${2} && ${conf_id2@a} == *a* ]] && conf+=( "${conf_id2[@]}" )
+
+		einfo "Building ${id}${2+ ${2}} in ${build_dir} ..."
+
+		mkdir -p "${build_dir}" || die
+		pushd "${build_dir}" >/dev/null || die
+
+		edo "${conf[@]}"
+		emake MAKEINFO=: V=1
+		# -j1 to match bug #906155, other packages may be fragile too
+		emake -j1 MAKEINFO=: V=1 DESTDIR="${MWT_D}" install
+
+		popd >/dev/null || die
+	}
+
+	cmake-build() {
+		local id1=${1/-/_}
+		local id2=${2/-/_}
+		local -n conf_id=conf_${id1} conf_id2=conf_${id1}_${id2}
+		local conf=( "${conf_id[@]}" )
+		[[ ${2} && ${conf_id2@a} == *a* ]] && conf+=( "${conf_id2[@]}" )
+		local build_dir=${WORKDIR}/${1}${2+_${2}}-${CHOST}-build
+
+		mkdir "${build_dir}" || die
+		pushd "${build_dir}" >/dev/null || die
+		cmake -GNinja \
+			  "${conf[@]}" "${WORKDIR}/$1/$2" || die
+		eninja
+		DESTDIR="${MWT_D}" eninja install
+		popd >/dev/null || die
+	}
+
+	CPPFLAGS="$CPPFLAGS -target ${CHOST}"
+	mwt-build mingw64 headers
+	CPPFLAGS="$CPPFLAGS -isystem ${MWT_D}${prefix}/${CHOST}/include"
+	export RCFLAGS="$RCFLAGS -I${MWT_D}${prefix}/${CHOST}/include"
+	LDFLAGS="$LDFLAGS -fuse-ld=lld"
+	mwt-build mingw64 runtime
+	local resource_dir="${T}/resource-dir-${CHOST}"
+	cp -a "${BROOT}/usr/lib/clang/${LLVM_MAJOR}" "${resource_dir}" || die
+	LDFLAGS="$LDFLAGS -rtlib=compiler-rt -stdlib=libc++ -L${MWT_D}${prefix}/${CHOST}/lib"
+	CPPFLAGS="$CPPFLAGS -resource-dir ${resource_dir}"
+	local conf_llvm_project=(
+		-DCMAKE_BUILD_TYPE=Release
+		-DCMAKE_C_COMPILER=clang
+		-DCMAKE_CXX_COMPILER=clang++
+		-DCMAKE_SYSTEM_NAME=Windows
+		-DCMAKE_C_COMPILER_WORKS=1
+		-DCMAKE_CXX_COMPILER_WORKS=1
+		-DCMAKE_C_COMPILER_TARGET="${CHOST}"
+		-DCMAKE_ASM_COMPILER_TARGET="${CHOST}"
+		-DCMAKE_CXX_COMPILER_TARGET="${CHOST}"
+		-DCMAKE_C_FLAGS_INIT="${CPPFLAGS}"
+		-DCMAKE_CXX_FLAGS_INIT="${CPPFLAGS}"
+	)
+	local comp_rt_install="${EPREFIX}/usr/lib/clang/${LLVM_MAJOR}"
+	local conf_llvm_project_compiler_rt=(
+		-DCOMPILER_RT_INSTALL_PATH="${comp_rt_install}"
+		-DCOMPILER_RT_BUILD_BUILTINS=TRUE
+		-DCOMPILER_RT_DEFAULT_TARGET_ONLY=TRUE
+		-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=FALSE
+		-DLLVM_CONFIG_PATH=""
+		-DCMAKE_FIND_ROOT_PATH="${prefix}/${CHOST}"
+		-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
+		-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY
+		-DCOMPILER_RT_BUILD_SANITIZERS=FALSE
+		-DCOMPILER_RT_BUILD_CTX_PROFILE=FALSE
+		-DCOMPILER_RT_BUILD_XRAY=FALSE
+		-DCOMPILER_RT_BUILD_ORC=FALSE
+		-DCOMPILER_RT_BUILD_PROFILE=FALSE
+		-DCOMPILER_RT_BUILD_MEMPROF=FALSE
+		-DCOMPILER_RT_BUILD_LIBFUZZER=FALSE
+	)
+	local conf_llvm_project_runtimes=(
+		-DLLVM_ENABLE_RUNTIMES="libunwind;libcxxabi;libcxx"
+		-DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/${CHOST}"
+		-DLIBUNWIND_USE_COMPILER_RT=TRUE
+		-DLIBUNWIND_ENABLE_SHARED=TRUE
+		-DLIBCXX_USE_COMPILER_RT=TRUE
+		-DLIBCXX_ENABLE_SHARED=TRUE
+		-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=TRUE
+		-DLIBCXX_CXX_ABI=libcxxabi
+		-DLIBCXX_LIBDIR_SUFFIX=""
+		-DLIBCXX_INCLUDE_TESTS=FALSE
+		-DLIBCXX_INSTALL_MODULES=TRUE
+		-DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=FALSE
+		-DLIBCXXABI_USE_COMPILER_RT=TRUE
+		-DLIBCXXABI_USE_LLVM_UNWINDER=TRUE
+		-DLIBCXXABI_ENABLE_SHARED=OFF
+		-DLIBCXXABI_LIBDIR_SUFFIX=""
+	)
+
+	cmake-build llvm-project compiler-rt
+
+	cp -a "${MWT_D}/${comp_rt_install}"/* "${resource_dir}/" || die
+
+	cmake-build llvm-project runtimes
+
+	mwt-build mingw64 libraries
+}
+
+src_install() {
+	mv -- "${MWT_D}${EPREFIX}"/* "${ED}" || die
+
+	find "${ED}" -type f -name '*.la' -delete || die
+	bindir="${ED}/usr/lib/llvm-mingw64/bin"
+	mkdir -p "${bindir}" || die
+	mkdir -p "${ED}/etc/clang/${LLVM_MAJOR}" || die
+
+	for CHOST in ${HOSTS[@]}; do
+		( per_host_install )
+	done
+}
+
+per_host_install() {
+	local cchost="${CHOST/mingw32/windows-gnu}"
+	for bin in clang clang++; do
+		ln -s "${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/bin/${bin}" "${bindir}/${CHOST}-${bin}" || die
+		echo "@${cchost}-common.cfg" >"${ED}/etc/clang/${LLVM_MAJOR}/${cchost}-${bin}.cfg" || die
+	done
+	cat >"${ED}/etc/clang/${LLVM_MAJOR}/${cchost}-common.cfg" <<-EOF
+	-Xclang=-internal-isystem
+	-Xclang=${EPREFIX}/usr/lib/${PN}/${CHOST}/include
+	-stdlib=libc++
+	-rtlib=compiler-rt
+	-unwindlib=libunwind
+	-L${EPREFIX}/usr/lib/${PN}/${CHOST}/lib/
+	EOF
+	for bin in dlltool windres ar; do
+		ln -s "${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/bin/llvm-${bin}" "${bindir}/${CHOST}-${bin}" || die
+	done
+}
+
+pkg_postinst() {
+	if [[ ! ${REPLACING_VERSIONS} ]]; then
+		elog "Note that this package is primarily intended for Wine and related"
+		elog "packages to depend on without needing a manual crossdev setup."
+		elog
+		elog "Settings are oriented only for what these need and simplicity."
+		elog "Use sys-devel/crossdev if need full toolchain/customization:"
+		elog "    https://wiki.gentoo.org/wiki/Mingw"
+		elog "    https://wiki.gentoo.org/wiki/Crossdev"
+	fi
+}

diff --git a/dev-util/llvm-mingw64/metadata.xml b/dev-util/llvm-mingw64/metadata.xml
new file mode 100644
index 000000000000..cd4af241c762
--- /dev/null
+++ b/dev-util/llvm-mingw64/metadata.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+	<maintainer type="project">
+		<email>asahi@gentoo.org</email>
+	</maintainer>
+	<upstream>
+		<remote-id type="sourceforge">mingw-w64</remote-id>
+		<remote-id type="github">llvm/llvm-project</remote-id>
+	</upstream>
+</pkgmetadata>


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-util/llvm-mingw64/
@ 2025-06-12 21:44 Sam James
  0 siblings, 0 replies; 5+ messages in thread
From: Sam James @ 2025-06-12 21:44 UTC (permalink / raw
  To: gentoo-commits

commit:     7abdec734f24e39070ebc60d8212c017c2f1a46e
Author:     Sasha Finkelstein <fnkl.kernel <AT> gmail <DOT> com>
AuthorDate: Thu Jun 12 16:33:57 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 12 21:42:25 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7abdec73

dev-util/llvm-mingw64: Add 13.0.0

Signed-off-by: Sasha Finkelstein <fnkl.kernel <AT> gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/42565
Closes: https://github.com/gentoo/gentoo/pull/42565
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-util/llvm-mingw64/Manifest                   |   1 +
 dev-util/llvm-mingw64/llvm-mingw64-13.0.0.ebuild | 287 +++++++++++++++++++++++
 2 files changed, 288 insertions(+)

diff --git a/dev-util/llvm-mingw64/Manifest b/dev-util/llvm-mingw64/Manifest
index 10a2abfb4144..66de7bb79c4e 100644
--- a/dev-util/llvm-mingw64/Manifest
+++ b/dev-util/llvm-mingw64/Manifest
@@ -1,2 +1,3 @@
 DIST llvm-project-20.1.6.src.tar.xz 147239668 BLAKE2B ccd86730fdea3dd40ebf054661b854b9332204389db2205e1e7b2a7f140fc187cacb34de68aa9a63c15c1e17b1d0976c080cfdee7e2cb6b0dd5570001d84be12 SHA512 aae652fdc61bda3f80b1340a3270b687355bfb6817f4bc05dac2268a2f8c5fc677eadb515cda7c8518005f1dc39e7ce5d1c34bbc5a25f106ef8e6c8f1ecfdf6d
 DIST mingw-w64-v12.0.0.tar.bz2 10474283 BLAKE2B 6500045f7d77f7de01dea0f4e03f3e4ddf6154586c5e3ee9718ee2c7ef1cc83ce3cbd644b6f1dc293ae6e0bfb55a6b68d439622bd1cfdefefc4cc547317f1943 SHA512 949b2bfab8763ab10ec4e9fdfdaf5361517a4ab787fb98ab419b38d02694061c2e821ebbf6e2e4b39d92bdf17419d116daa8e63afd9e01d11592f39df4da69d7
+DIST mingw-w64-v13.0.0.tar.bz2 10868704 BLAKE2B 60f041e9a03f70e78217d169dc0f892fef1be3d242237f842f09cc755e8bd8efc9586f6a05475b427dc46bdef3d30619ad33e9c959775b22e27fad7dff93c677 SHA512 39a22bd92465f571df1d90ac80b88dc6846998f71e4b7db79d1c9aa6e04cb3e41b632990a7238fc2c384ea67e4a77d103230db2c0d741869340d24ea79b6dda8

diff --git a/dev-util/llvm-mingw64/llvm-mingw64-13.0.0.ebuild b/dev-util/llvm-mingw64/llvm-mingw64-13.0.0.ebuild
new file mode 100644
index 000000000000..8bb6d2fa7087
--- /dev/null
+++ b/dev-util/llvm-mingw64/llvm-mingw64-13.0.0.ebuild
@@ -0,0 +1,287 @@
+# Copyright 2022-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit edo ninja-utils flag-o-matic toolchain-funcs
+
+MINGW_PV=$(ver_cut 1-3)
+LLVM_PV=20.1.6
+LLVM_MAJOR=$(ver_cut 1 ${LLVM_PV})
+
+DESCRIPTION="Clang/LLVM based mingw64 toolchain"
+HOMEPAGE="
+	https://www.mingw-w64.org/
+"
+SRC_URI="
+	https://downloads.sourceforge.net/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v${MINGW_PV}.tar.bz2
+	https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_PV}/llvm-project-${LLVM_PV}.src.tar.xz
+"
+S="${WORKDIR}"
+
+LICENSE="
+	Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )
+	ZPL BSD BSD-2 ISC LGPL-2+ LGPL-2.1+ MIT public-domain
+"
+SLOT="0"
+KEYWORDS="~arm64"
+IUSE="custom-cflags +strip"
+
+BDEPEND="
+	dev-build/cmake
+"
+
+RDEPEND="
+	llvm-core/clang:${LLVM_MAJOR}
+	llvm-core/llvm:${LLVM_MAJOR}
+	llvm-core/lld:${LLVM_MAJOR}
+"
+DEPEND="${RDEPEND}"
+
+HOSTS=(
+	aarch64-w64-mingw32
+#	i686-w64-mingw32
+)
+
+pkg_pretend() {
+	[[ ${MERGE_TYPE} == binary ]] && return
+
+	tc-is-cross-compiler &&
+		die "cross-compilation of the toolchain itself is unsupported"
+}
+
+src_prepare() {
+	# rename directories to simplify both patching and the ebuild
+	mv mingw-w64-v${MINGW_PV} mingw64 || die
+	mv llvm-project-${LLVM_PV}.src llvm-project || die
+	default
+}
+
+src_compile() {
+	# not great but do everything in src_compile given bootstrapping
+	# process needs to be done in steps of configure+compile+install
+	# (done modular to have most package-specific things in one place)
+
+	MWT_D=${T}/root # moved to ${D} in src_install
+	mwtdir=/usr/lib/${PN}
+	prefix=${EPREFIX}${mwtdir}
+	sysroot=${MWT_D}${prefix}
+	PATH=${sysroot}/bin:${PATH}
+
+	unset AR CC CPP CXX DLLTOOL LD NM OBJCOPY OBJDUMP RANLIB RC STRIP
+
+	export AR=llvm-ar
+	export CC=clang
+	export CXX=clang++
+	export NM=llvm-nm
+	export RANLIB=llvm-ranlib
+	export STRIP=llvm-strip
+
+	filter-flags '-fuse-ld=*'
+	filter-flags '-mfunction-return=thunk*' #878849
+
+	use custom-cflags || filter-flags '-fstack-protector*' #931512
+
+	filter-flags '-Wl,-z,*'
+	append-flags -mno-avx
+
+	filter-lto # requires setting up, and may be messy with mingw static libs
+	use custom-cflags || strip-flags # fancy flags are not realistic here
+
+	local -A lib_hosts=(
+		aarch64-w64-mingw32 "--disable-lib32 --disable-lib64 --enable-libarm64"
+		i686-w64-mingw32 "--enable-lib32 --disable-lib64 --disable-libarm64"
+	)
+	for CHOST in ${HOSTS[@]}; do
+		( per_host_compile ${lib_hosts[${CHOST}]} )
+
+		# portage doesn't know the right strip executable to use for CTARGET
+		# and it can lead to .a mangling, notably with 32bit (breaks toolchain)
+		dostrip -x ${mwtdir}/${CHOST}/lib{,32}
+		dostrip -x /usr/lib/llvm/${LLVM_MAJOR}/${CHOST}/lib/lib{c++,unwind}.dll.a
+	done
+}
+
+per_host_compile() {
+	CC="${CC} -target ${CHOST}" \
+	  CXX="${CXX} -target ${CHOST}" \
+	  LD="${LD} -target ${CHOST}" \
+	  strip-unsupported-flags
+
+	local conf_mingw64=(
+		--build=${CBUILD}
+		--prefix="${prefix}"/${CHOST}
+		--host=${CHOST}
+		--with-sysroot=no
+		--without-{crt,headers}
+
+		# mingw .dll aren't used by wine and packages wouldn't find them
+		# at runtime, use crossdev if need dll and proper search paths
+		--disable-shared
+	)
+
+	local conf_mingw64_headers=(
+		--enable-idl
+		--with-headers
+	)
+
+	local conf_mingw64_runtime=(
+		--with-crt $@
+	)
+
+	local conf_mingw64_libraries=( --with-libraries="winpthreads" )
+
+	mwt-build() {
+		local id=${1##*/}
+		local build_dir=${WORKDIR}/${1}${2+_${2}}-${CHOST}-build
+
+		# econf is not allowed in src_compile and its defaults are
+		# mostly unused here, so use configure directly
+		local conf=( "${WORKDIR}/${1}"/configure )
+
+		local -n conf_id=conf_${id} conf_id2=conf_${id}_${2}
+		[[ ${conf_id@a} == *a* ]] && conf+=( "${conf_id[@]}" )
+		[[ ${2} && ${conf_id2@a} == *a* ]] && conf+=( "${conf_id2[@]}" )
+
+		einfo "Building ${id}${2+ ${2}} in ${build_dir} ..."
+
+		mkdir -p "${build_dir}" || die
+		pushd "${build_dir}" >/dev/null || die
+
+		edo "${conf[@]}"
+		emake MAKEINFO=: V=1
+		# -j1 to match bug #906155, other packages may be fragile too
+		emake -j1 MAKEINFO=: V=1 DESTDIR="${MWT_D}" install
+
+		popd >/dev/null || die
+	}
+
+	cmake-build() {
+		local id1=${1/-/_}
+		local id2=${2/-/_}
+		local -n conf_id=conf_${id1} conf_id2=conf_${id1}_${id2}
+		local conf=( "${conf_id[@]}" )
+		[[ ${2} && ${conf_id2@a} == *a* ]] && conf+=( "${conf_id2[@]}" )
+		local build_dir=${WORKDIR}/${1}${2+_${2}}-${CHOST}-build
+
+		mkdir "${build_dir}" || die
+		pushd "${build_dir}" >/dev/null || die
+		cmake -GNinja \
+			  "${conf[@]}" "${WORKDIR}/$1/$2" || die
+		eninja
+		DESTDIR="${MWT_D}" eninja install
+		popd >/dev/null || die
+	}
+
+	CPPFLAGS="$CPPFLAGS --no-default-config -target ${CHOST}"
+	mwt-build mingw64 headers
+	CPPFLAGS="$CPPFLAGS -isystem ${MWT_D}${prefix}/${CHOST}/include"
+	export RCFLAGS="$RCFLAGS -I${MWT_D}${prefix}/${CHOST}/include"
+	LDFLAGS="$LDFLAGS --no-default-config -fuse-ld=lld"
+	CPP="clang --no-default-config -E -target ${CHOST}" mwt-build mingw64 runtime
+	local resource_dir="${T}/resource-dir-${CHOST}"
+	cp -a "${BROOT}/usr/lib/clang/${LLVM_MAJOR}" "${resource_dir}" || die
+	LDFLAGS="$LDFLAGS -rtlib=compiler-rt -stdlib=libc++ -L${MWT_D}${prefix}/${CHOST}/lib"
+	CPPFLAGS="$CPPFLAGS -resource-dir ${resource_dir}"
+	local conf_llvm_project=(
+		-DCMAKE_BUILD_TYPE=Release
+		-DCMAKE_C_COMPILER=clang
+		-DCMAKE_CXX_COMPILER=clang++
+		-DCMAKE_SYSTEM_NAME=Windows
+		-DCMAKE_C_COMPILER_WORKS=1
+		-DCMAKE_CXX_COMPILER_WORKS=1
+		-DCMAKE_C_COMPILER_TARGET="${CHOST}"
+		-DCMAKE_ASM_COMPILER_TARGET="${CHOST}"
+		-DCMAKE_CXX_COMPILER_TARGET="${CHOST}"
+		-DCMAKE_C_FLAGS_INIT="${CPPFLAGS}"
+		-DCMAKE_CXX_FLAGS_INIT="${CPPFLAGS}"
+	)
+	local comp_rt_install="${EPREFIX}/usr/lib/clang/${LLVM_MAJOR}"
+	local conf_llvm_project_compiler_rt=(
+		-DCOMPILER_RT_INSTALL_PATH="${comp_rt_install}"
+		-DCOMPILER_RT_BUILD_BUILTINS=TRUE
+		-DCOMPILER_RT_DEFAULT_TARGET_ONLY=TRUE
+		-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=FALSE
+		-DLLVM_CONFIG_PATH=""
+		-DCMAKE_FIND_ROOT_PATH="${prefix}/${CHOST}"
+		-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
+		-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY
+		-DCOMPILER_RT_BUILD_SANITIZERS=FALSE
+		-DCOMPILER_RT_BUILD_CTX_PROFILE=FALSE
+		-DCOMPILER_RT_BUILD_XRAY=FALSE
+		-DCOMPILER_RT_BUILD_ORC=FALSE
+		-DCOMPILER_RT_BUILD_PROFILE=FALSE
+		-DCOMPILER_RT_BUILD_MEMPROF=FALSE
+		-DCOMPILER_RT_BUILD_LIBFUZZER=FALSE
+	)
+	local conf_llvm_project_runtimes=(
+		-DLLVM_ENABLE_RUNTIMES="libunwind;libcxxabi;libcxx"
+		-DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/${CHOST}"
+		-DLIBUNWIND_USE_COMPILER_RT=TRUE
+		-DLIBUNWIND_ENABLE_SHARED=TRUE
+		-DLIBCXX_USE_COMPILER_RT=TRUE
+		-DLIBCXX_ENABLE_SHARED=TRUE
+		-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=TRUE
+		-DLIBCXX_CXX_ABI=libcxxabi
+		-DLIBCXX_LIBDIR_SUFFIX=""
+		-DLIBCXX_INCLUDE_TESTS=FALSE
+		-DLIBCXX_INSTALL_MODULES=TRUE
+		-DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=FALSE
+		-DLIBCXXABI_USE_COMPILER_RT=TRUE
+		-DLIBCXXABI_USE_LLVM_UNWINDER=TRUE
+		-DLIBCXXABI_ENABLE_SHARED=OFF
+		-DLIBCXXABI_LIBDIR_SUFFIX=""
+	)
+
+	cmake-build llvm-project compiler-rt
+
+	cp -a "${MWT_D}/${comp_rt_install}"/* "${resource_dir}/" || die
+
+	cmake-build llvm-project runtimes
+
+	mwt-build mingw64 libraries
+}
+
+src_install() {
+	mv -- "${MWT_D}${EPREFIX}"/* "${ED}" || die
+
+	find "${ED}" -type f -name '*.la' -delete || die
+	bindir="${ED}/usr/lib/llvm-mingw64/bin"
+	mkdir -p "${bindir}" || die
+	mkdir -p "${ED}/etc/clang/${LLVM_MAJOR}" || die
+
+	for CHOST in ${HOSTS[@]}; do
+		( per_host_install )
+	done
+}
+
+per_host_install() {
+	local cchost="${CHOST/mingw32/windows-gnu}"
+	for bin in clang clang++; do
+		ln -s "${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/bin/${bin}" "${bindir}/${CHOST}-${bin}" || die
+		echo "@${cchost}-common.cfg" >"${ED}/etc/clang/${LLVM_MAJOR}/${cchost}-${bin}.cfg" || die
+	done
+	cat >"${ED}/etc/clang/${LLVM_MAJOR}/${cchost}-common.cfg" <<-EOF
+	-Xclang=-internal-isystem
+	-Xclang=${EPREFIX}/usr/lib/${PN}/${CHOST}/include
+	-stdlib=libc++
+	-rtlib=compiler-rt
+	-unwindlib=libunwind
+	-L${EPREFIX}/usr/lib/${PN}/${CHOST}/lib/
+	EOF
+	for bin in dlltool windres ar; do
+		ln -s "${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/bin/llvm-${bin}" "${bindir}/${CHOST}-${bin}" || die
+	done
+}
+
+pkg_postinst() {
+	if [[ ! ${REPLACING_VERSIONS} ]]; then
+		elog "Note that this package is primarily intended for Wine and related"
+		elog "packages to depend on without needing a manual crossdev setup."
+		elog
+		elog "Settings are oriented only for what these need and simplicity."
+		elog "Use sys-devel/crossdev if need full toolchain/customization:"
+		elog "    https://wiki.gentoo.org/wiki/Mingw"
+		elog "    https://wiki.gentoo.org/wiki/Crossdev"
+	fi
+}


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-util/llvm-mingw64/
@ 2025-06-13  0:15 Sam James
  0 siblings, 0 replies; 5+ messages in thread
From: Sam James @ 2025-06-13  0:15 UTC (permalink / raw
  To: gentoo-commits

commit:     d633b1438957d5e504695cb2eb8cf1e95f8e0fa5
Author:     Sasha Finkelstein <fnkl.kernel <AT> gmail <DOT> com>
AuthorDate: Mon Jun  9 13:35:28 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jun 13 00:11:28 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d633b143

dev-util/llvm-mingw64: Filter out -mbranch-protection=

Closes: https://bugs.gentoo.org/957683
Signed-off-by: Sasha Finkelstein <fnkl.kernel <AT> gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/42516
Closes: https://github.com/gentoo/gentoo/pull/42516
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-util/llvm-mingw64/llvm-mingw64-12.0.0.ebuild | 1 +
 dev-util/llvm-mingw64/llvm-mingw64-13.0.0.ebuild | 1 +
 2 files changed, 2 insertions(+)

diff --git a/dev-util/llvm-mingw64/llvm-mingw64-12.0.0.ebuild b/dev-util/llvm-mingw64/llvm-mingw64-12.0.0.ebuild
index 013b5556f50b..913a83d3d422 100644
--- a/dev-util/llvm-mingw64/llvm-mingw64-12.0.0.ebuild
+++ b/dev-util/llvm-mingw64/llvm-mingw64-12.0.0.ebuild
@@ -79,6 +79,7 @@ src_compile() {
 
 	filter-flags '-fuse-ld=*'
 	filter-flags '-mfunction-return=thunk*' #878849
+	filter-flags '-mbranch-protection=*' #957683
 
 	use custom-cflags || filter-flags '-fstack-protector*' #931512
 

diff --git a/dev-util/llvm-mingw64/llvm-mingw64-13.0.0.ebuild b/dev-util/llvm-mingw64/llvm-mingw64-13.0.0.ebuild
index 8bb6d2fa7087..8e5f5dcf48d5 100644
--- a/dev-util/llvm-mingw64/llvm-mingw64-13.0.0.ebuild
+++ b/dev-util/llvm-mingw64/llvm-mingw64-13.0.0.ebuild
@@ -79,6 +79,7 @@ src_compile() {
 
 	filter-flags '-fuse-ld=*'
 	filter-flags '-mfunction-return=thunk*' #878849
+	filter-flags '-mbranch-protection=*' #957683
 
 	use custom-cflags || filter-flags '-fstack-protector*' #931512
 


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-util/llvm-mingw64/
@ 2025-10-15  5:27 Sam James
  0 siblings, 0 replies; 5+ messages in thread
From: Sam James @ 2025-10-15  5:27 UTC (permalink / raw
  To: gentoo-commits

commit:     97bf4b3217f41d2275ba3fff9d9295ab316174a9
Author:     James Calligeros <jcalligeros99 <AT> gmail <DOT> com>
AuthorDate: Wed Oct 15 02:03:59 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Oct 15 05:24:43 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=97bf4b32

dev-util/llvm-mingw64: don't strip static stdlib and compiler builtins

Portage was still trying to strip the static stdlib archives and
compiler builtins, breaking the toolchain for anything trying
to statically link libc++ (e.g. app-emulation/fex-xtajit) or
where compiler-rt was being called for.

Signed-off-by: James Calligeros <jcalligeros99 <AT> gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/44183
Closes: https://github.com/gentoo/gentoo/pull/44183
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../llvm-mingw64/llvm-mingw64-13.0.0-r2.ebuild     | 306 +++++++++++++++++++++
 1 file changed, 306 insertions(+)

diff --git a/dev-util/llvm-mingw64/llvm-mingw64-13.0.0-r2.ebuild b/dev-util/llvm-mingw64/llvm-mingw64-13.0.0-r2.ebuild
new file mode 100644
index 000000000000..3af38989f680
--- /dev/null
+++ b/dev-util/llvm-mingw64/llvm-mingw64-13.0.0-r2.ebuild
@@ -0,0 +1,306 @@
+# Copyright 2022-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit autotools edo ninja-utils flag-o-matic toolchain-funcs
+
+MINGW_PV=$(ver_cut 1-3)
+LLVM_PV=21.1.0
+LLVM_MAJOR=$(ver_cut 1 ${LLVM_PV})
+
+DESCRIPTION="Clang/LLVM based mingw64 toolchain"
+HOMEPAGE="
+	https://www.mingw-w64.org/
+"
+SRC_URI="
+	https://downloads.sourceforge.net/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v${MINGW_PV}.tar.bz2
+	https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_PV}/llvm-project-${LLVM_PV}.src.tar.xz
+"
+S="${WORKDIR}"
+
+LICENSE="
+	Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )
+	ZPL BSD BSD-2 ISC LGPL-2+ LGPL-2.1+ MIT public-domain
+"
+SLOT="0"
+KEYWORDS="~arm64"
+IUSE="+arm64ec-pe custom-cflags +strip"
+
+PATCHES="
+	${FILESDIR}/${PN}-13.0.0-r1-exclude-arm64-cflags.patch
+"
+
+BDEPEND="
+	dev-build/cmake
+"
+
+RDEPEND="
+	llvm-core/clang:${LLVM_MAJOR}
+	llvm-core/llvm:${LLVM_MAJOR}
+	llvm-core/lld:${LLVM_MAJOR}
+"
+DEPEND="${RDEPEND}"
+
+pkg_pretend() {
+	[[ ${MERGE_TYPE} == binary ]] && return
+
+	tc-is-cross-compiler &&
+		die "cross-compilation of the toolchain itself is unsupported"
+}
+
+pkg_setup() {
+	HOSTS=(
+		aarch64-w64-mingw32
+#		$(usev i686-pe i686-w64-mingw32)
+		$(usev arm64ec-pe arm64ec-w64-mingw32)
+	)
+}
+
+src_prepare() {
+	# rename directories to simplify both patching and the ebuild
+	mv mingw-w64-v${MINGW_PV} mingw64 || die
+	mv llvm-project-${LLVM_PV}.src llvm-project || die
+	default
+
+	pushd mingw64 >/dev/null || die
+	eautoreconf
+	popd >/dev/null || die
+}
+
+src_compile() {
+	# not great but do everything in src_compile given bootstrapping
+	# process needs to be done in steps of configure+compile+install
+	# (done modular to have most package-specific things in one place)
+
+	MWT_D=${T}/root # moved to ${D} in src_install
+	mwtdir=/usr/lib/${PN}
+	prefix=${EPREFIX}${mwtdir}
+	sysroot=${MWT_D}${prefix}
+	PATH=${sysroot}/bin:${PATH}
+
+	unset AR CC CPP CXX DLLTOOL LD NM OBJCOPY OBJDUMP RANLIB RC STRIP
+
+	export AR=llvm-ar
+	export CC=clang
+	export CXX=clang++
+	export NM=llvm-nm
+	export RANLIB=llvm-ranlib
+	export STRIP=llvm-strip
+
+	filter-flags '-fuse-ld=*'
+	filter-flags '-mfunction-return=thunk*' #878849
+
+	use custom-cflags || filter-flags '-fstack-protector*' #931512
+
+	filter-flags '-Wl,-z,*'
+	append-flags -mno-avx
+
+	filter-lto # requires setting up, and may be messy with mingw static libs
+	use custom-cflags || strip-flags # fancy flags are not realistic here
+
+	local -A lib_hosts=(
+		aarch64-w64-mingw32 "--disable-lib32 --disable-lib64 --enable-libarm64"
+		arm64ec-w64-mingw32 "--disable-lib32 --disable-lib64 --enable-libarm64"
+		i686-w64-mingw32 "--enable-lib32 --disable-lib64 --disable-libarm64"
+	)
+	for CHOST in ${HOSTS[@]}; do
+		( per_host_compile ${lib_hosts[${CHOST}]} )
+	done
+}
+
+per_host_compile() {
+	CC="${CC} -target ${CHOST}" \
+	  CXX="${CXX} -target ${CHOST}" \
+	  LD="${LD} -target ${CHOST}" \
+	  strip-unsupported-flags
+
+	local conf_mingw64=(
+		--build=${CBUILD}
+		--prefix="${prefix}"/${CHOST}
+		--host=${CHOST}
+		--with-sysroot=no
+		--without-{crt,headers}
+
+		# mingw .dll aren't used by wine and packages wouldn't find them
+		# at runtime, use crossdev if need dll and proper search paths
+		--disable-shared
+	)
+
+	local conf_mingw64_headers=(
+		--enable-idl
+		--with-headers
+	)
+
+	local conf_mingw64_runtime=(
+		--with-crt $@
+	)
+
+	local conf_mingw64_libraries=( --with-libraries="winpthreads" )
+
+	mwt-build() {
+		local id=${1##*/}
+		local build_dir=${WORKDIR}/${1}${2+_${2}}-${CHOST}-build
+
+		# econf is not allowed in src_compile and its defaults are
+		# mostly unused here, so use configure directly
+		local conf=( "${WORKDIR}/${1}"/configure )
+
+		local -n conf_id=conf_${id} conf_id2=conf_${id}_${2}
+		[[ ${conf_id@a} == *a* ]] && conf+=( "${conf_id[@]}" )
+		[[ ${2} && ${conf_id2@a} == *a* ]] && conf+=( "${conf_id2[@]}" )
+
+		einfo "Building ${id}${2+ ${2}} in ${build_dir} ..."
+
+		mkdir -p "${build_dir}" || die
+		pushd "${build_dir}" >/dev/null || die
+
+		edo "${conf[@]}"
+		emake MAKEINFO=: V=1
+		# -j1 to match bug #906155, other packages may be fragile too
+		emake -j1 MAKEINFO=: V=1 DESTDIR="${MWT_D}" install
+
+		popd >/dev/null || die
+	}
+
+	cmake-build() {
+		local id1=${1/-/_}
+		local id2=${2/-/_}
+		local -n conf_id=conf_${id1} conf_id2=conf_${id1}_${id2}
+		local conf=( "${conf_id[@]}" )
+		[[ ${2} && ${conf_id2@a} == *a* ]] && conf+=( "${conf_id2[@]}" )
+		local build_dir=${WORKDIR}/${1}${2+_${2}}-${CHOST}-build
+
+		mkdir "${build_dir}" || die
+		pushd "${build_dir}" >/dev/null || die
+		cmake -GNinja \
+			  "${conf[@]}" "${WORKDIR}/$1/$2" || die
+		eninja
+		DESTDIR="${MWT_D}" eninja install
+		popd >/dev/null || die
+	}
+
+	CPPFLAGS="$CPPFLAGS --no-default-config -target ${CHOST}"
+	mwt-build mingw64 headers
+	CPPFLAGS="$CPPFLAGS -isystem ${MWT_D}${prefix}/${CHOST}/include"
+	export RCFLAGS="$RCFLAGS -I${MWT_D}${prefix}/${CHOST}/include"
+	LDFLAGS="$LDFLAGS --no-default-config -fuse-ld=lld"
+	CPP="clang --no-default-config -E -target ${CHOST}" mwt-build mingw64 runtime
+	local resource_dir="${T}/resource-dir-${CHOST}"
+	cp -a "${BROOT}/usr/lib/clang/${LLVM_MAJOR}" "${resource_dir}" || die
+	LDFLAGS="$LDFLAGS -rtlib=compiler-rt -stdlib=libc++ -L${MWT_D}${prefix}/${CHOST}/lib"
+	CPPFLAGS="$CPPFLAGS -resource-dir ${resource_dir}"
+	local conf_llvm_project=(
+		-DCMAKE_BUILD_TYPE=Release
+		-DCMAKE_C_COMPILER=clang
+		-DCMAKE_CXX_COMPILER=clang++
+		-DCMAKE_SYSTEM_NAME=Windows
+		-DCMAKE_C_COMPILER_WORKS=1
+		-DCMAKE_CXX_COMPILER_WORKS=1
+		-DCMAKE_C_COMPILER_TARGET="${CHOST}"
+		-DCMAKE_ASM_COMPILER_TARGET="${CHOST}"
+		-DCMAKE_CXX_COMPILER_TARGET="${CHOST}"
+		-DCMAKE_C_FLAGS_INIT="${CPPFLAGS}"
+		-DCMAKE_CXX_FLAGS_INIT="${CPPFLAGS}"
+	)
+	local comp_rt_install="${EPREFIX}/usr/lib/clang/${LLVM_MAJOR}"
+	local conf_llvm_project_compiler_rt=(
+		-DCOMPILER_RT_INSTALL_PATH="${comp_rt_install}"
+		-DCOMPILER_RT_BUILD_BUILTINS=TRUE
+		-DCOMPILER_RT_DEFAULT_TARGET_ONLY=TRUE
+		-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=FALSE
+		-DLLVM_CONFIG_PATH=""
+		-DCMAKE_FIND_ROOT_PATH="${prefix}/${CHOST}"
+		-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
+		-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY
+		-DCOMPILER_RT_BUILD_SANITIZERS=FALSE
+		-DCOMPILER_RT_BUILD_CTX_PROFILE=FALSE
+		-DCOMPILER_RT_BUILD_XRAY=FALSE
+		-DCOMPILER_RT_BUILD_ORC=FALSE
+		-DCOMPILER_RT_BUILD_PROFILE=FALSE
+		-DCOMPILER_RT_BUILD_MEMPROF=FALSE
+		-DCOMPILER_RT_BUILD_LIBFUZZER=FALSE
+	)
+	local conf_llvm_project_runtimes=(
+		-DLLVM_ENABLE_RUNTIMES="libunwind;libcxxabi;libcxx"
+		-DLLVM_DEFAULT_TARGET_TRIPLE="${CHOST}"
+		-DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/${CHOST}"
+		-DLIBUNWIND_USE_COMPILER_RT=TRUE
+		-DLIBUNWIND_ENABLE_SHARED=TRUE
+		-DLIBCXX_USE_COMPILER_RT=TRUE
+		-DLIBCXX_ENABLE_SHARED=TRUE
+		-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=TRUE
+		-DLIBCXX_CXX_ABI=libcxxabi
+		-DLIBCXX_LIBDIR_SUFFIX=""
+		-DLIBCXX_INCLUDE_TESTS=FALSE
+		-DLIBCXX_INSTALL_MODULES=TRUE
+		-DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=FALSE
+		-DLIBCXXABI_USE_COMPILER_RT=TRUE
+		-DLIBCXXABI_USE_LLVM_UNWINDER=TRUE
+		-DLIBCXXABI_ENABLE_SHARED=OFF
+		-DLIBCXXABI_LIBDIR_SUFFIX=""
+	)
+
+	cmake-build llvm-project compiler-rt
+	if [[ $CHOST == arm64ec-w64-mingw32 ]]; then
+		base="${MWT_D}/${comp_rt_install}/lib/windows"
+		llvm-ar -qL "${base}/libclang_rt.builtins-aarch64.a" "${base}/libclang_rt.builtins-arm64ec.a"
+	fi
+	cp -a "${MWT_D}/${comp_rt_install}"/* "${resource_dir}/" || die
+
+	cmake-build llvm-project runtimes
+
+	mwt-build mingw64 libraries
+}
+
+src_install() {
+	mv -- "${MWT_D}${EPREFIX}"/* "${ED}" || die
+
+	find "${ED}" -type f -name '*.la' -delete || die
+	bindir="${ED}/usr/lib/llvm-mingw64/bin"
+	mkdir -p "${bindir}" || die
+	mkdir -p "${ED}/etc/clang/${LLVM_MAJOR}" || die
+
+	for CHOST in ${HOSTS[@]}; do
+		( per_host_install )
+		# Portage doesn't know which strip executable to use for this
+		# CTARGET and will mangle the stdlib, breaking the toolchain.
+		dostrip -x ${mwtdir}/${CHOST}/lib/{,32}
+		dostrip -x /usr/lib/llvm/${LLVM_MAJOR}/${CHOST}/lib/lib{c++,unwind}.dll.a
+		dostrip -x /usr/lib/llvm/${LLVM_MAJOR}/lib/lib{c++,unwind}.a
+	done
+
+	# As above but for compiler builtins
+	dostrip -x /usr/lib/clang/${LLVM_MAJOR}/lib/windows
+}
+
+per_host_install() {
+	local cchost="${CHOST/mingw32/windows-gnu}"
+	for bin in clang clang++; do
+		ln -s "${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/bin/${bin}" "${bindir}/${CHOST}-${bin}" || die
+		echo "@${cchost}-common.cfg" >"${ED}/etc/clang/${LLVM_MAJOR}/${cchost}-${bin}.cfg" || die
+	done
+	cat >"${ED}/etc/clang/${LLVM_MAJOR}/${cchost}-common.cfg" <<-EOF
+	-Xclang=-internal-isystem
+	-Xclang=${EPREFIX}/usr/lib/${PN}/${CHOST}/include
+	-stdlib=libc++
+	-rtlib=compiler-rt
+	-unwindlib=libunwind
+	-L${EPREFIX}/usr/lib/${PN}/${CHOST}/lib/
+	EOF
+	for bin in dlltool windres ar; do
+		ln -s "${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/bin/llvm-${bin}" "${bindir}/${CHOST}-${bin}" || die
+	done
+}
+
+pkg_postinst() {
+	if [[ ! ${REPLACING_VERSIONS} ]]; then
+		elog "Note that this package is primarily intended for Wine and related"
+		elog "packages to depend on without needing a manual crossdev setup."
+		elog
+		elog "Settings are oriented only for what these need and simplicity."
+		elog "Use sys-devel/crossdev if need full toolchain/customization:"
+		elog "    https://wiki.gentoo.org/wiki/Mingw"
+		elog "    https://wiki.gentoo.org/wiki/Crossdev"
+	fi
+}


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-util/llvm-mingw64/
@ 2025-10-19 16:43 Sam James
  0 siblings, 0 replies; 5+ messages in thread
From: Sam James @ 2025-10-19 16:43 UTC (permalink / raw
  To: gentoo-commits

commit:     d8d4b059ebfd21e2356227b7478877c0db7ac0bc
Author:     Sasha Finkelstein <fnkl.kernel <AT> gmail <DOT> com>
AuthorDate: Tue Oct 14 17:12:47 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Oct 19 16:37:50 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d8d4b059

dev-util/llvm-mingw64: Fix arm64ec archives being broken by strip

Signed-off-by: Sasha Finkelstein <fnkl.kernel <AT> gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/44178
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../llvm-mingw64/llvm-mingw64-13.0.0-r3.ebuild     | 307 +++++++++++++++++++++
 1 file changed, 307 insertions(+)

diff --git a/dev-util/llvm-mingw64/llvm-mingw64-13.0.0-r3.ebuild b/dev-util/llvm-mingw64/llvm-mingw64-13.0.0-r3.ebuild
new file mode 100644
index 000000000000..6c51a427678e
--- /dev/null
+++ b/dev-util/llvm-mingw64/llvm-mingw64-13.0.0-r3.ebuild
@@ -0,0 +1,307 @@
+# Copyright 2022-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit autotools edo ninja-utils flag-o-matic toolchain-funcs
+
+MINGW_PV=$(ver_cut 1-3)
+LLVM_PV=21.1.0
+LLVM_MAJOR=$(ver_cut 1 ${LLVM_PV})
+
+DESCRIPTION="Clang/LLVM based mingw64 toolchain"
+HOMEPAGE="
+	https://www.mingw-w64.org/
+"
+SRC_URI="
+	https://downloads.sourceforge.net/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v${MINGW_PV}.tar.bz2
+	https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_PV}/llvm-project-${LLVM_PV}.src.tar.xz
+"
+S="${WORKDIR}"
+
+LICENSE="
+	Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )
+	ZPL BSD BSD-2 ISC LGPL-2+ LGPL-2.1+ MIT public-domain
+"
+SLOT="0"
+KEYWORDS="~arm64"
+IUSE="+arm64ec-pe custom-cflags +strip"
+
+PATCHES="
+	${FILESDIR}/${PN}-13.0.0-r1-exclude-arm64-cflags.patch
+"
+
+BDEPEND="
+	dev-build/cmake
+"
+
+RDEPEND="
+	llvm-core/clang:${LLVM_MAJOR}
+	llvm-core/llvm:${LLVM_MAJOR}
+	llvm-core/lld:${LLVM_MAJOR}
+"
+DEPEND="${RDEPEND}"
+
+# Stripping arm64ec archives breaks them.
+# Nothing we install can be stripped by host tools, so just skip everything.
+RESTRICT="strip"
+
+pkg_pretend() {
+	[[ ${MERGE_TYPE} == binary ]] && return
+
+	tc-is-cross-compiler &&
+		die "cross-compilation of the toolchain itself is unsupported"
+}
+
+pkg_setup() {
+	HOSTS=(
+		aarch64-w64-mingw32
+#		$(usev i686-pe i686-w64-mingw32)
+		$(usev arm64ec-pe arm64ec-w64-mingw32)
+	)
+}
+
+src_prepare() {
+	# rename directories to simplify both patching and the ebuild
+	mv mingw-w64-v${MINGW_PV} mingw64 || die
+	mv llvm-project-${LLVM_PV}.src llvm-project || die
+	default
+
+	pushd mingw64 >/dev/null || die
+	eautoreconf
+	popd >/dev/null || die
+}
+
+src_compile() {
+	# not great but do everything in src_compile given bootstrapping
+	# process needs to be done in steps of configure+compile+install
+	# (done modular to have most package-specific things in one place)
+
+	MWT_D=${T}/root # moved to ${D} in src_install
+	mwtdir=/usr/lib/${PN}
+	prefix=${EPREFIX}${mwtdir}
+	sysroot=${MWT_D}${prefix}
+	PATH=${sysroot}/bin:${PATH}
+
+	unset AR CC CPP CXX DLLTOOL LD NM OBJCOPY OBJDUMP RANLIB RC STRIP
+
+	export AR=llvm-ar
+	export CC=clang
+	export CXX=clang++
+	export NM=llvm-nm
+	export RANLIB=llvm-ranlib
+	export STRIP=llvm-strip
+
+	filter-flags '-fuse-ld=*'
+	filter-flags '-mfunction-return=thunk*' #878849
+
+	use custom-cflags || filter-flags '-fstack-protector*' #931512
+
+	filter-flags '-Wl,-z,*'
+	append-flags -mno-avx
+
+	filter-lto # requires setting up, and may be messy with mingw static libs
+	use custom-cflags || strip-flags # fancy flags are not realistic here
+
+	local -A lib_hosts=(
+		aarch64-w64-mingw32 "--disable-lib32 --disable-lib64 --enable-libarm64"
+		arm64ec-w64-mingw32 "--disable-lib32 --disable-lib64 --enable-libarm64"
+		i686-w64-mingw32 "--enable-lib32 --disable-lib64 --disable-libarm64"
+	)
+	for CHOST in ${HOSTS[@]}; do
+		( per_host_compile ${lib_hosts[${CHOST}]} )
+
+		# portage doesn't know the right strip executable to use for CTARGET
+		# and it can lead to .a mangling, notably with 32bit (breaks toolchain)
+		dostrip -x ${mwtdir}/${CHOST}/lib{,32}
+		dostrip -x /usr/lib/llvm/${LLVM_MAJOR}/${CHOST}/lib/lib{c++,unwind}.dll.a
+	done
+}
+
+per_host_compile() {
+	CC="${CC} -target ${CHOST}" \
+	  CXX="${CXX} -target ${CHOST}" \
+	  LD="${LD} -target ${CHOST}" \
+	  strip-unsupported-flags
+
+	local conf_mingw64=(
+		--build=${CBUILD}
+		--prefix="${prefix}"/${CHOST}
+		--host=${CHOST}
+		--with-sysroot=no
+		--without-{crt,headers}
+
+		# mingw .dll aren't used by wine and packages wouldn't find them
+		# at runtime, use crossdev if need dll and proper search paths
+		--disable-shared
+	)
+
+	local conf_mingw64_headers=(
+		--enable-idl
+		--with-headers
+	)
+
+	local conf_mingw64_runtime=(
+		--with-crt $@
+	)
+
+	local conf_mingw64_libraries=( --with-libraries="winpthreads" )
+
+	mwt-build() {
+		local id=${1##*/}
+		local build_dir=${WORKDIR}/${1}${2+_${2}}-${CHOST}-build
+
+		# econf is not allowed in src_compile and its defaults are
+		# mostly unused here, so use configure directly
+		local conf=( "${WORKDIR}/${1}"/configure )
+
+		local -n conf_id=conf_${id} conf_id2=conf_${id}_${2}
+		[[ ${conf_id@a} == *a* ]] && conf+=( "${conf_id[@]}" )
+		[[ ${2} && ${conf_id2@a} == *a* ]] && conf+=( "${conf_id2[@]}" )
+
+		einfo "Building ${id}${2+ ${2}} in ${build_dir} ..."
+
+		mkdir -p "${build_dir}" || die
+		pushd "${build_dir}" >/dev/null || die
+
+		edo "${conf[@]}"
+		emake MAKEINFO=: V=1
+		# -j1 to match bug #906155, other packages may be fragile too
+		emake -j1 MAKEINFO=: V=1 DESTDIR="${MWT_D}" install
+
+		popd >/dev/null || die
+	}
+
+	cmake-build() {
+		local id1=${1/-/_}
+		local id2=${2/-/_}
+		local -n conf_id=conf_${id1} conf_id2=conf_${id1}_${id2}
+		local conf=( "${conf_id[@]}" )
+		[[ ${2} && ${conf_id2@a} == *a* ]] && conf+=( "${conf_id2[@]}" )
+		local build_dir=${WORKDIR}/${1}${2+_${2}}-${CHOST}-build
+
+		mkdir "${build_dir}" || die
+		pushd "${build_dir}" >/dev/null || die
+		cmake -GNinja \
+			  "${conf[@]}" "${WORKDIR}/$1/$2" || die
+		eninja
+		DESTDIR="${MWT_D}" eninja install
+		popd >/dev/null || die
+	}
+
+	CPPFLAGS="$CPPFLAGS --no-default-config -target ${CHOST}"
+	mwt-build mingw64 headers
+	CPPFLAGS="$CPPFLAGS -isystem ${MWT_D}${prefix}/${CHOST}/include"
+	export RCFLAGS="$RCFLAGS -I${MWT_D}${prefix}/${CHOST}/include"
+	LDFLAGS="$LDFLAGS --no-default-config -fuse-ld=lld"
+	CPP="clang --no-default-config -E -target ${CHOST}" mwt-build mingw64 runtime
+	local resource_dir="${T}/resource-dir-${CHOST}"
+	cp -a "${BROOT}/usr/lib/clang/${LLVM_MAJOR}" "${resource_dir}" || die
+	LDFLAGS="$LDFLAGS -rtlib=compiler-rt -stdlib=libc++ -L${MWT_D}${prefix}/${CHOST}/lib"
+	CPPFLAGS="$CPPFLAGS -resource-dir ${resource_dir}"
+	local conf_llvm_project=(
+		-DCMAKE_BUILD_TYPE=Release
+		-DCMAKE_C_COMPILER=clang
+		-DCMAKE_CXX_COMPILER=clang++
+		-DCMAKE_SYSTEM_NAME=Windows
+		-DCMAKE_C_COMPILER_WORKS=1
+		-DCMAKE_CXX_COMPILER_WORKS=1
+		-DCMAKE_C_COMPILER_TARGET="${CHOST}"
+		-DCMAKE_ASM_COMPILER_TARGET="${CHOST}"
+		-DCMAKE_CXX_COMPILER_TARGET="${CHOST}"
+		-DCMAKE_C_FLAGS_INIT="${CPPFLAGS}"
+		-DCMAKE_CXX_FLAGS_INIT="${CPPFLAGS}"
+	)
+	local comp_rt_install="${EPREFIX}/usr/lib/clang/${LLVM_MAJOR}"
+	local conf_llvm_project_compiler_rt=(
+		-DCOMPILER_RT_INSTALL_PATH="${comp_rt_install}"
+		-DCOMPILER_RT_BUILD_BUILTINS=TRUE
+		-DCOMPILER_RT_DEFAULT_TARGET_ONLY=TRUE
+		-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=FALSE
+		-DLLVM_CONFIG_PATH=""
+		-DCMAKE_FIND_ROOT_PATH="${prefix}/${CHOST}"
+		-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
+		-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY
+		-DCOMPILER_RT_BUILD_SANITIZERS=FALSE
+		-DCOMPILER_RT_BUILD_CTX_PROFILE=FALSE
+		-DCOMPILER_RT_BUILD_XRAY=FALSE
+		-DCOMPILER_RT_BUILD_ORC=FALSE
+		-DCOMPILER_RT_BUILD_PROFILE=FALSE
+		-DCOMPILER_RT_BUILD_MEMPROF=FALSE
+		-DCOMPILER_RT_BUILD_LIBFUZZER=FALSE
+	)
+	local conf_llvm_project_runtimes=(
+		-DLLVM_ENABLE_RUNTIMES="libunwind;libcxxabi;libcxx"
+		-DLLVM_DEFAULT_TARGET_TRIPLE="${CHOST}"
+		-DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/${CHOST}"
+		-DLIBUNWIND_USE_COMPILER_RT=TRUE
+		-DLIBUNWIND_ENABLE_SHARED=TRUE
+		-DLIBCXX_USE_COMPILER_RT=TRUE
+		-DLIBCXX_ENABLE_SHARED=TRUE
+		-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=TRUE
+		-DLIBCXX_CXX_ABI=libcxxabi
+		-DLIBCXX_LIBDIR_SUFFIX=""
+		-DLIBCXX_INCLUDE_TESTS=FALSE
+		-DLIBCXX_INSTALL_MODULES=TRUE
+		-DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=FALSE
+		-DLIBCXXABI_USE_COMPILER_RT=TRUE
+		-DLIBCXXABI_USE_LLVM_UNWINDER=TRUE
+		-DLIBCXXABI_ENABLE_SHARED=OFF
+		-DLIBCXXABI_LIBDIR_SUFFIX=""
+	)
+
+	cmake-build llvm-project compiler-rt
+	if [[ $CHOST == arm64ec-w64-mingw32 ]]; then
+		base="${MWT_D}/${comp_rt_install}/lib/windows"
+		llvm-ar -qL "${base}/libclang_rt.builtins-aarch64.a" "${base}/libclang_rt.builtins-arm64ec.a"
+	fi
+	cp -a "${MWT_D}/${comp_rt_install}"/* "${resource_dir}/" || die
+
+	cmake-build llvm-project runtimes
+
+	mwt-build mingw64 libraries
+}
+
+src_install() {
+	mv -- "${MWT_D}${EPREFIX}"/* "${ED}" || die
+
+	find "${ED}" -type f -name '*.la' -delete || die
+	bindir="${ED}/usr/lib/llvm-mingw64/bin"
+	mkdir -p "${bindir}" || die
+	mkdir -p "${ED}/etc/clang/${LLVM_MAJOR}" || die
+
+	for CHOST in ${HOSTS[@]}; do
+		( per_host_install )
+	done
+}
+
+per_host_install() {
+	local cchost="${CHOST/mingw32/windows-gnu}"
+	for bin in clang clang++; do
+		ln -s "${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/bin/${bin}" "${bindir}/${CHOST}-${bin}" || die
+		echo "@${cchost}-common.cfg" >"${ED}/etc/clang/${LLVM_MAJOR}/${cchost}-${bin}.cfg" || die
+	done
+	cat >"${ED}/etc/clang/${LLVM_MAJOR}/${cchost}-common.cfg" <<-EOF
+	-Xclang=-internal-isystem
+	-Xclang=${EPREFIX}/usr/lib/${PN}/${CHOST}/include
+	-stdlib=libc++
+	-rtlib=compiler-rt
+	-unwindlib=libunwind
+	-L${EPREFIX}/usr/lib/${PN}/${CHOST}/lib/
+	EOF
+	for bin in dlltool windres ar; do
+		ln -s "${EPREFIX}/usr/lib/llvm/${LLVM_MAJOR}/bin/llvm-${bin}" "${bindir}/${CHOST}-${bin}" || die
+	done
+}
+
+pkg_postinst() {
+	if [[ ! ${REPLACING_VERSIONS} ]]; then
+		elog "Note that this package is primarily intended for Wine and related"
+		elog "packages to depend on without needing a manual crossdev setup."
+		elog
+		elog "Settings are oriented only for what these need and simplicity."
+		elog "Use sys-devel/crossdev if need full toolchain/customization:"
+		elog "    https://wiki.gentoo.org/wiki/Mingw"
+		elog "    https://wiki.gentoo.org/wiki/Crossdev"
+	fi
+}


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-10-19 16:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-08 12:03 [gentoo-commits] repo/gentoo:master commit in: dev-util/llvm-mingw64/ Sam James
  -- strict thread matches above, loose matches on Subject: below --
2025-06-12 21:44 Sam James
2025-06-13  0:15 Sam James
2025-10-15  5:27 Sam James
2025-10-19 16:43 Sam James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox