Gentoo Archives: gentoo-commits

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-util/mingw64-runtime/files/, dev-util/mingw64-runtime/
Date: Wed, 28 Apr 2021 21:59:01
Message-Id: 1619647134.40d0fd393ac48096a4e826f3eb941a21142a1f41.slyfox@gentoo
1 commit: 40d0fd393ac48096a4e826f3eb941a21142a1f41
2 Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
3 AuthorDate: Wed Apr 28 21:58:19 2021 +0000
4 Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
5 CommitDate: Wed Apr 28 21:58:54 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=40d0fd39
7
8 dev-util/mingw64-runtime: fix build against gcc-11 (__rdtsc clash)
9
10 gcc-11 defines __rdtsc as a macro:
11 // include/ia32intrin.h:110
12 #define __rdtsc() __builtin_ia32_rdtsc ()
13 and causes build failure:
14 intrincs/rdtsc.c:15:30:
15 error: macro "__rdtsc" passed 1 arguments, but takes just 0
16 15 | unsigned __int64 __rdtsc(void)
17 | ^
18
19 Let's avoid __rdtsc definition on systems with #define __rdtsc present.
20
21 There is still a chance that it might be a '#define __rdtsc __rdtsc'.
22 We'll revisit it then.
23
24 Reported-by: Mihai Donțu
25 Closes: https://bugs.gentoo.org/786549
26 Package-Manager: Portage-3.0.18, Repoman-3.0.3
27 Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
28
29 .../files/mingw64-runtime-8.0.0-__rdtsc.patch | 25 +++++
30 .../mingw64-runtime-8.0.0-r1.ebuild | 119 +++++++++++++++++++++
31 2 files changed, 144 insertions(+)
32
33 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
34 new file mode 100644
35 index 00000000000..df06f041c8c
36 --- /dev/null
37 +++ b/dev-util/mingw64-runtime/files/mingw64-runtime-8.0.0-__rdtsc.patch
38 @@ -0,0 +1,25 @@
39 +https://bugs.gentoo.org/786549
40 +
41 +gcc-11 defines __rdtsc as a macro:
42 + // include/ia32intrin.h:110
43 + #define __rdtsc() __builtin_ia32_rdtsc ()
44 +and causes build failure:
45 + intrincs/rdtsc.c:15:30: error: macro "__rdtsc" passed 1 arguments, but takes just 0
46 + 15 | unsigned __int64 __rdtsc(void)
47 + | ^
48 +
49 +Let's avoid __rdtsc definition on systems with #define __rdtsc present.
50 +
51 +There is still a chance that it might be a '#define __rdtsc __rdtsc'.
52 +We'll revisit it then.
53 +--- a/mingw-w64-crt/intrincs/rdtsc.c
54 ++++ b/mingw-w64-crt/intrincs/rdtsc.c
55 +@@ -11,7 +11,7 @@
56 + #define __has_builtin(x) 0
57 + #endif
58 +
59 +-#if !__has_builtin(__rdtsc)
60 ++#if !__has_builtin(__rdtsc) && !defined(__rdtsc)
61 + unsigned __int64 __rdtsc(void)
62 + {
63 + #ifdef _WIN64
64
65 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
66 new file mode 100644
67 index 00000000000..3dfff3894bf
68 --- /dev/null
69 +++ b/dev-util/mingw64-runtime/mingw64-runtime-8.0.0-r1.ebuild
70 @@ -0,0 +1,119 @@
71 +# Copyright 1999-2021 Gentoo Authors
72 +# Distributed under the terms of the GNU General Public License v2
73 +
74 +EAPI=7
75 +
76 +export CBUILD=${CBUILD:-${CHOST}}
77 +export CTARGET=${CTARGET:-${CHOST}}
78 +if [[ ${CTARGET} == ${CHOST} ]] ; then
79 + if [[ ${CATEGORY} == cross-* ]] ; then
80 + export CTARGET=${CATEGORY#cross-}
81 + fi
82 +fi
83 +
84 +inherit autotools flag-o-matic toolchain-funcs
85 +
86 +DESCRIPTION="Free Win64 runtime and import library definitions"
87 +HOMEPAGE="http://mingw-w64.sourceforge.net/"
88 +SRC_URI="mirror://sourceforge/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v${PV}.tar.bz2"
89 +
90 +LICENSE="BSD"
91 +SLOT="0"
92 +KEYWORDS="~amd64 ~x86"
93 +# USE=libraries needs working stage2 compiler: bug #665512
94 +IUSE="headers-only idl libraries tools"
95 +RESTRICT="strip"
96 +
97 +S="${WORKDIR}/mingw-w64-v${PV}"
98 +
99 +PATCHES=(
100 + "${FILESDIR}"/${PN}-7.0.0-fortify-only-ssp.patch
101 + "${FILESDIR}"/${PN}-8.0.0-__rdtsc.patch
102 +)
103 +
104 +is_crosscompile() {
105 + [[ ${CHOST} != ${CTARGET} ]]
106 +}
107 +just_headers() {
108 + use headers-only
109 +}
110 +alt_prefix() {
111 + is_crosscompile && echo /usr/${CTARGET}
112 +}
113 +crt_with() {
114 + just_headers && echo --without-$1 || echo --with-$1
115 +}
116 +crt_use_enable() {
117 + just_headers && echo --without-$2 || use_enable "$@"
118 +}
119 +crt_use_with() {
120 + just_headers && echo --without-$2 || use_with "$@"
121 +}
122 +
123 +pkg_setup() {
124 + if [[ ${CBUILD} == ${CHOST} ]] && [[ ${CHOST} == ${CTARGET} ]] ; then
125 + die "Invalid configuration"
126 + fi
127 +}
128 +
129 +src_configure() {
130 + CHOST=${CTARGET} strip-unsupported-flags
131 + # Normally mingw-64 does not use dynamic linker.
132 + # But at configure time it uses $LDFLAGS.
133 + # When default -Wl,--hash-style=gnu is passed
134 + # __CTORS_LIST__ / __DTORS_LIST__ is mis-detected
135 + # for target ld and binaries crash at shutdown.
136 + filter-ldflags '-Wl,--hash-style=*'
137 +
138 + if ! just_headers; then
139 + mkdir "${WORKDIR}/headers"
140 + pushd "${WORKDIR}/headers" > /dev/null
141 + CHOST=${CTARGET} "${S}/configure" \
142 + --prefix="${T}/tmproot" \
143 + --with-headers \
144 + --without-crt \
145 + || die
146 + popd > /dev/null
147 + append-cppflags "-I${T}/tmproot/include"
148 + fi
149 +
150 + # By default configure tries to set --sysroot=${prefix}. We disable
151 + # this behaviour with --with-sysroot=no to use gcc's sysroot default.
152 + # That way we can cross-build mingw64-runtime with cross-emerge.
153 + local prefix="${EPREFIX}"$(alt_prefix)/usr
154 + CHOST=${CTARGET} econf \
155 + --with-sysroot=no \
156 + --prefix="${prefix}" \
157 + --libdir="${prefix}"/lib \
158 + --with-headers \
159 + --enable-sdk \
160 + $(crt_with crt) \
161 + $(crt_use_enable idl idl) \
162 + $(crt_use_with libraries libraries) \
163 + $(crt_use_with tools tools) \
164 + $(
165 + $(tc-getCPP ${CTARGET}) ${CPPFLAGS} -dM - < /dev/null | grep -q __MINGW64__ \
166 + && echo --disable-lib32 --enable-lib64 \
167 + || echo --enable-lib32 --disable-lib64
168 + )
169 +}
170 +
171 +src_compile() {
172 + if ! just_headers; then
173 + emake -C "${WORKDIR}/headers" install
174 + fi
175 + default
176 +}
177 +
178 +src_install() {
179 + default
180 +
181 + if is_crosscompile ; then
182 + # gcc is configured to look at specific hard-coded paths for mingw #419601
183 + dosym usr /usr/${CTARGET}/mingw
184 + dosym usr /usr/${CTARGET}/${CTARGET}
185 + dosym usr/include /usr/${CTARGET}/sys-include
186 + fi
187 +
188 + rm -rf "${ED}/usr/share"
189 +}