From 40d0fd393ac48096a4e826f3eb941a21142a1f41 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Wed, 28 Apr 2021 22:58:19 +0100 Subject: dev-util/mingw64-runtime: fix build against gcc-11 (__rdtsc clash) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc-11 defines __rdtsc as a macro: // include/ia32intrin.h:110 #define __rdtsc() __builtin_ia32_rdtsc () and causes build failure: intrincs/rdtsc.c:15:30: error: macro "__rdtsc" passed 1 arguments, but takes just 0 15 | unsigned __int64 __rdtsc(void) | ^ Let's avoid __rdtsc definition on systems with #define __rdtsc present. There is still a chance that it might be a '#define __rdtsc __rdtsc'. We'll revisit it then. Reported-by: Mihai Donțu Closes: https://bugs.gentoo.org/786549 Package-Manager: Portage-3.0.18, Repoman-3.0.3 Signed-off-by: Sergei Trofimovich --- .../files/mingw64-runtime-8.0.0-__rdtsc.patch | 25 +++++ .../mingw64-runtime-8.0.0-r1.ebuild | 119 +++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 dev-util/mingw64-runtime/files/mingw64-runtime-8.0.0-__rdtsc.patch create mode 100644 dev-util/mingw64-runtime/mingw64-runtime-8.0.0-r1.ebuild (limited to 'dev-util') diff --git a/dev-util/mingw64-runtime/files/mingw64-runtime-8.0.0-__rdtsc.patch b/dev-util/mingw64-runtime/files/mingw64-runtime-8.0.0-__rdtsc.patch new file mode 100644 index 000000000000..df06f041c8c2 --- /dev/null +++ b/dev-util/mingw64-runtime/files/mingw64-runtime-8.0.0-__rdtsc.patch @@ -0,0 +1,25 @@ +https://bugs.gentoo.org/786549 + +gcc-11 defines __rdtsc as a macro: + // include/ia32intrin.h:110 + #define __rdtsc() __builtin_ia32_rdtsc () +and causes build failure: + intrincs/rdtsc.c:15:30: error: macro "__rdtsc" passed 1 arguments, but takes just 0 + 15 | unsigned __int64 __rdtsc(void) + | ^ + +Let's avoid __rdtsc definition on systems with #define __rdtsc present. + +There is still a chance that it might be a '#define __rdtsc __rdtsc'. +We'll revisit it then. +--- a/mingw-w64-crt/intrincs/rdtsc.c ++++ b/mingw-w64-crt/intrincs/rdtsc.c +@@ -11,7 +11,7 @@ + #define __has_builtin(x) 0 + #endif + +-#if !__has_builtin(__rdtsc) ++#if !__has_builtin(__rdtsc) && !defined(__rdtsc) + unsigned __int64 __rdtsc(void) + { + #ifdef _WIN64 diff --git a/dev-util/mingw64-runtime/mingw64-runtime-8.0.0-r1.ebuild b/dev-util/mingw64-runtime/mingw64-runtime-8.0.0-r1.ebuild new file mode 100644 index 000000000000..3dfff3894bf5 --- /dev/null +++ b/dev-util/mingw64-runtime/mingw64-runtime-8.0.0-r1.ebuild @@ -0,0 +1,119 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +export CBUILD=${CBUILD:-${CHOST}} +export CTARGET=${CTARGET:-${CHOST}} +if [[ ${CTARGET} == ${CHOST} ]] ; then + if [[ ${CATEGORY} == cross-* ]] ; then + export CTARGET=${CATEGORY#cross-} + fi +fi + +inherit autotools flag-o-matic toolchain-funcs + +DESCRIPTION="Free Win64 runtime and import library definitions" +HOMEPAGE="http://mingw-w64.sourceforge.net/" +SRC_URI="mirror://sourceforge/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v${PV}.tar.bz2" + +LICENSE="BSD" +SLOT="0" +KEYWORDS="~amd64 ~x86" +# USE=libraries needs working stage2 compiler: bug #665512 +IUSE="headers-only idl libraries tools" +RESTRICT="strip" + +S="${WORKDIR}/mingw-w64-v${PV}" + +PATCHES=( + "${FILESDIR}"/${PN}-7.0.0-fortify-only-ssp.patch + "${FILESDIR}"/${PN}-8.0.0-__rdtsc.patch +) + +is_crosscompile() { + [[ ${CHOST} != ${CTARGET} ]] +} +just_headers() { + use headers-only +} +alt_prefix() { + is_crosscompile && echo /usr/${CTARGET} +} +crt_with() { + just_headers && echo --without-$1 || echo --with-$1 +} +crt_use_enable() { + just_headers && echo --without-$2 || use_enable "$@" +} +crt_use_with() { + just_headers && echo --without-$2 || use_with "$@" +} + +pkg_setup() { + if [[ ${CBUILD} == ${CHOST} ]] && [[ ${CHOST} == ${CTARGET} ]] ; then + die "Invalid configuration" + fi +} + +src_configure() { + CHOST=${CTARGET} strip-unsupported-flags + # Normally mingw-64 does not use dynamic linker. + # But at configure time it uses $LDFLAGS. + # When default -Wl,--hash-style=gnu is passed + # __CTORS_LIST__ / __DTORS_LIST__ is mis-detected + # for target ld and binaries crash at shutdown. + filter-ldflags '-Wl,--hash-style=*' + + if ! just_headers; then + mkdir "${WORKDIR}/headers" + pushd "${WORKDIR}/headers" > /dev/null + CHOST=${CTARGET} "${S}/configure" \ + --prefix="${T}/tmproot" \ + --with-headers \ + --without-crt \ + || die + popd > /dev/null + append-cppflags "-I${T}/tmproot/include" + fi + + # By default configure tries to set --sysroot=${prefix}. We disable + # this behaviour with --with-sysroot=no to use gcc's sysroot default. + # That way we can cross-build mingw64-runtime with cross-emerge. + local prefix="${EPREFIX}"$(alt_prefix)/usr + CHOST=${CTARGET} econf \ + --with-sysroot=no \ + --prefix="${prefix}" \ + --libdir="${prefix}"/lib \ + --with-headers \ + --enable-sdk \ + $(crt_with crt) \ + $(crt_use_enable idl idl) \ + $(crt_use_with libraries libraries) \ + $(crt_use_with tools tools) \ + $( + $(tc-getCPP ${CTARGET}) ${CPPFLAGS} -dM - < /dev/null | grep -q __MINGW64__ \ + && echo --disable-lib32 --enable-lib64 \ + || echo --enable-lib32 --disable-lib64 + ) +} + +src_compile() { + if ! just_headers; then + emake -C "${WORKDIR}/headers" install + fi + default +} + +src_install() { + default + + if is_crosscompile ; then + # gcc is configured to look at specific hard-coded paths for mingw #419601 + dosym usr /usr/${CTARGET}/mingw + dosym usr /usr/${CTARGET}/${CTARGET} + dosym usr/include /usr/${CTARGET}/sys-include + fi + + rm -rf "${ED}/usr/share" +} -- cgit v1.2.3-65-gdbad