1 |
commit: 58e1d4b5b4cd962f2fbe44a3abd5dab69a95e77a |
2 |
Author: Matoro Mahri <matoro <AT> users <DOT> noreply <DOT> github <DOT> com> |
3 |
AuthorDate: Wed Mar 15 16:32:08 2023 +0000 |
4 |
Commit: Joonas Niilola <juippis <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Mar 15 18:07:36 2023 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=58e1d4b5 |
7 |
|
8 |
media-libs/openh264: wire up tests, add mips patch |
9 |
|
10 |
Patch backports https://github.com/cisco/openh264/pull/3630 |
11 |
|
12 |
Tests are currently broken on BE but pass on LE. |
13 |
|
14 |
https://github.com/cisco/openh264/issues/3634 |
15 |
|
16 |
Bug: https://bugs.gentoo.org/896138 |
17 |
Signed-off-by: Matoro Mahri <matoro <AT> users.noreply.github.com> |
18 |
Closes: https://github.com/gentoo/gentoo/pull/30137 |
19 |
Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org> |
20 |
|
21 |
.../openh264/files/openh264-2.3.1-pr3630.patch | 159 +++++++++++++++++++++ |
22 |
media-libs/openh264/openh264-2.3.1-r1.ebuild | 20 ++- |
23 |
2 files changed, 175 insertions(+), 4 deletions(-) |
24 |
|
25 |
diff --git a/media-libs/openh264/files/openh264-2.3.1-pr3630.patch b/media-libs/openh264/files/openh264-2.3.1-pr3630.patch |
26 |
new file mode 100644 |
27 |
index 000000000000..c9d0c3f2a98b |
28 |
--- /dev/null |
29 |
+++ b/media-libs/openh264/files/openh264-2.3.1-pr3630.patch |
30 |
@@ -0,0 +1,159 @@ |
31 |
+https://bugs.gentoo.org/show_bug.cgi?id=896138 |
32 |
+https://github.com/cisco/openh264/pull/3630 |
33 |
+ |
34 |
+From f60e7d9bdc39e51b644db7624256116202cac992 Mon Sep 17 00:00:00 2001 |
35 |
+From: matoro <matoro@××××××××××××××××××××.com> |
36 |
+Date: Thu, 2 Mar 2023 17:39:45 -0500 |
37 |
+Subject: [PATCH] Use environment for mips feature detection |
38 |
+ |
39 |
+The -march= option is perfectly happy to emit code to run on a processor |
40 |
+different than the one on which it is being compiled. This results in |
41 |
+misdetection of mips features because the test compiles specify that a |
42 |
+given extension should be emitted, but this does not check whether or |
43 |
+not this corresponds to the subarchitecture targeted in CFLAGS by the |
44 |
+rest of the build. |
45 |
+ |
46 |
+$ echo "void main(void){ __asm__ volatile(\"punpcklhw \$f0, \$f0, \$f0\"); }" > test.c |
47 |
+$ CFLAGS="-march=loongson3a" make test |
48 |
+cc -march=loongson3a test.c -o test |
49 |
+$ ./test |
50 |
+Illegal instruction |
51 |
+$ CFLAGS="-march=native" make -B test |
52 |
+cc -march=native test.c -o test |
53 |
+/tmp/ccLbeyM1.s: Assembler messages: |
54 |
+/tmp/ccLbeyM1.s:25: Error: opcode not supported on this processor: octeon2 (mips64r2) `punpcklhw $f0,$f0,$f0' |
55 |
+make: *** [<builtin>: test] Error 1 |
56 |
+ |
57 |
+This leads to -march=loongson3a getting appended to CFLAGS, which may |
58 |
+conflict with previously specified -march= levels for the build, or |
59 |
+other options. Calling make in the test will use whatever CC/CFLAGS are |
60 |
+specified in the environment to determine whether the actual compile |
61 |
+command line to be used in the build supports these features. |
62 |
+ |
63 |
+Fixes: 8b942ee ("Adjust the mmi/msa detection mode for mips platform.") |
64 |
+--- |
65 |
+ build/arch.mk | 8 ++++---- |
66 |
+ build/loongarch-simd-check.sh | 17 +++++++---------- |
67 |
+ build/mips-simd-check.sh | 17 +++++++---------- |
68 |
+ 3 files changed, 18 insertions(+), 24 deletions(-) |
69 |
+ |
70 |
+diff --git a/build/arch.mk b/build/arch.mk |
71 |
+index 4e1538c45c..80983686f7 100644 |
72 |
+--- a/build/arch.mk |
73 |
++++ b/build/arch.mk |
74 |
+@@ -39,14 +39,14 @@ ASM_ARCH = mips |
75 |
+ ASMFLAGS += -I$(SRC_PATH)codec/common/mips/ |
76 |
+ #mmi |
77 |
+ ifeq ($(ENABLE_MMI), Yes) |
78 |
+-ENABLE_MMI = $(shell $(SRC_PATH)build/mips-simd-check.sh $(CC) mmi) |
79 |
++ENABLE_MMI = $(shell CC="$(CC)" CFLAGS="$(CFLAGS)" $(SRC_PATH)build/mips-simd-check.sh mmi) |
80 |
+ ifeq ($(ENABLE_MMI), Yes) |
81 |
+ CFLAGS += -DHAVE_MMI -march=loongson3a |
82 |
+ endif |
83 |
+ endif |
84 |
+ #msa |
85 |
+ ifeq ($(ENABLE_MSA), Yes) |
86 |
+-ENABLE_MSA = $(shell $(SRC_PATH)build/mips-simd-check.sh $(CC) msa) |
87 |
++ENABLE_MSA = $(shell CC="$(CC)" CFLAGS="$(CFLAGS)" $(SRC_PATH)build/mips-simd-check.sh msa) |
88 |
+ ifeq ($(ENABLE_MSA), Yes) |
89 |
+ CFLAGS += -DHAVE_MSA -mmsa |
90 |
+ endif |
91 |
+@@ -63,14 +63,14 @@ ASM_ARCH = loongarch |
92 |
+ ASMFLAGS += -I$(SRC_PATH)codec/common/loongarch/ |
93 |
+ #lsx |
94 |
+ ifeq ($(ENABLE_LSX), Yes) |
95 |
+-ENABLE_LSX = $(shell $(SRC_PATH)build/loongarch-simd-check.sh $(CC) lsx) |
96 |
++ENABLE_LSX = $(shell CC="$(CC)" CFLAGS="$(CFLAGS)" $(SRC_PATH)build/loongarch-simd-check.sh lsx) |
97 |
+ ifeq ($(ENABLE_LSX), Yes) |
98 |
+ CFLAGS += -DHAVE_LSX -mlsx |
99 |
+ endif |
100 |
+ endif |
101 |
+ #lasx |
102 |
+ ifeq ($(ENABLE_LASX), Yes) |
103 |
+-ENABLE_LASX = $(shell $(SRC_PATH)build/loongarch-simd-check.sh $(CC) lasx) |
104 |
++ENABLE_LASX = $(shell CC="$(CC)" CFLAGS="$(CFLAGS)" $(SRC_PATH)build/loongarch-simd-check.sh lasx) |
105 |
+ ifeq ($(ENABLE_LASX), Yes) |
106 |
+ CFLAGS += -DHAVE_LASX -mlasx |
107 |
+ endif |
108 |
+diff --git a/build/loongarch-simd-check.sh b/build/loongarch-simd-check.sh |
109 |
+index 597ddcdc22..2e609443b9 100755 |
110 |
+--- a/build/loongarch-simd-check.sh |
111 |
++++ b/build/loongarch-simd-check.sh |
112 |
+@@ -8,29 +8,26 @@ |
113 |
+ # lsx, lasx (maybe more in the future). |
114 |
+ # |
115 |
+ # --usage: |
116 |
+-# ./loongarch-simd-check.sh $(CC) lsx |
117 |
+-# or ./loongarch-simd-check.sh $(CC) lasx |
118 |
++# ./loongarch-simd-check.sh lsx |
119 |
++# or ./loongarch-simd-check.sh lasx |
120 |
+ # |
121 |
+ # date: 11/23/2021 Created |
122 |
+ #*************************************************************************************** |
123 |
+ |
124 |
+ TMPC=$(mktemp tmp.XXXXXX.c) |
125 |
+-TMPO=$(mktemp tmp.XXXXXX.o) |
126 |
+-if [ $2 == "lsx" ] |
127 |
++if [ $1 == "lsx" ] |
128 |
+ then |
129 |
+ echo "void main(void){ __asm__ volatile(\"vadd.b \$vr0, \$vr1, \$vr1\"); }" > $TMPC |
130 |
+- $1 -mlsx $TMPC -o $TMPO &> /dev/null |
131 |
+- if test -s $TMPO |
132 |
++ if make -f /dev/null "${TMPC/.c/.o}" |
133 |
+ then |
134 |
+ echo "Yes" |
135 |
+ fi |
136 |
+-elif [ $2 == "lasx" ] |
137 |
++elif [ $1 == "lasx" ] |
138 |
+ then |
139 |
+ echo "void main(void){ __asm__ volatile(\"xvadd.b \$xr0, \$xr1, \$xr1\"); }" > $TMPC |
140 |
+- $1 -mlasx $TMPC -o $TMPO &> /dev/null |
141 |
+- if test -s $TMPO |
142 |
++ if make -f /dev/null "${TMPC/.c/.o}" |
143 |
+ then |
144 |
+ echo "Yes" |
145 |
+ fi |
146 |
+ fi |
147 |
+-rm -f $TMPC $TMPO |
148 |
++rm -f $TMPC |
149 |
+diff --git a/build/mips-simd-check.sh b/build/mips-simd-check.sh |
150 |
+index d0d72f9edd..5ff1eb432c 100755 |
151 |
+--- a/build/mips-simd-check.sh |
152 |
++++ b/build/mips-simd-check.sh |
153 |
+@@ -4,29 +4,26 @@ |
154 |
+ # mmi, msa (maybe more in the future). |
155 |
+ # |
156 |
+ # --usage: |
157 |
+-# ./mips-simd-check.sh $(CC) mmi |
158 |
+-# or ./mips-simd-check.sh $(CC) msa |
159 |
++# ./mips-simd-check.sh mmi |
160 |
++# or ./mips-simd-check.sh msa |
161 |
+ # |
162 |
+ # date: 10/17/2019 Created |
163 |
+ #********************************************************************************** |
164 |
+ |
165 |
+ TMPC=$(mktemp tmp.XXXXXX.c) |
166 |
+-TMPO=$(mktemp tmp.XXXXXX.o) |
167 |
+-if [ $2 == "mmi" ] |
168 |
++if [ $1 == "mmi" ] |
169 |
+ then |
170 |
+ echo "void main(void){ __asm__ volatile(\"punpcklhw \$f0, \$f0, \$f0\"); }" > $TMPC |
171 |
+- $1 -march=loongson3a $TMPC -o $TMPO &> /dev/null |
172 |
+- if test -s $TMPO |
173 |
++ if make -f /dev/null "${TMPC/.c/.o}" &> /dev/null |
174 |
+ then |
175 |
+ echo "Yes" |
176 |
+ fi |
177 |
+-elif [ $2 == "msa" ] |
178 |
++elif [ $1 == "msa" ] |
179 |
+ then |
180 |
+ echo "void main(void){ __asm__ volatile(\"addvi.b \$w0, \$w1, 1\"); }" > $TMPC |
181 |
+- $1 -mmsa $TMPC -o $TMPO &> /dev/null |
182 |
+- if test -s $TMPO |
183 |
++ if make -f /dev/null "${TMPC/.c/.o}" &> /dev/null |
184 |
+ then |
185 |
+ echo "Yes" |
186 |
+ fi |
187 |
+ fi |
188 |
+-rm -f $TMPC $TMPO |
189 |
++rm -f $TMPC |
190 |
|
191 |
diff --git a/media-libs/openh264/openh264-2.3.1-r1.ebuild b/media-libs/openh264/openh264-2.3.1-r1.ebuild |
192 |
index 0bb5fa26460b..bd16d2a68ecf 100644 |
193 |
--- a/media-libs/openh264/openh264-2.3.1-r1.ebuild |
194 |
+++ b/media-libs/openh264/openh264-2.3.1-r1.ebuild |
195 |
@@ -19,21 +19,28 @@ LICENSE="BSD" |
196 |
# https://github.com/cisco/openh264/issues/3459 ) |
197 |
SLOT="0/7" |
198 |
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~loong ppc ppc64 ~riscv sparc x86" |
199 |
-IUSE="cpu_flags_arm_neon cpu_flags_x86_avx2 +plugin utils" |
200 |
+IUSE="cpu_flags_arm_neon cpu_flags_x86_avx2 +plugin test utils" |
201 |
|
202 |
-RESTRICT="bindist test" |
203 |
+RESTRICT="bindist !test? ( test )" |
204 |
|
205 |
BDEPEND=" |
206 |
abi_x86_32? ( dev-lang/nasm ) |
207 |
- abi_x86_64? ( dev-lang/nasm )" |
208 |
+ abi_x86_64? ( dev-lang/nasm ) |
209 |
+ test? ( dev-cpp/gtest[${MULTILIB_USEDEP}] )" |
210 |
|
211 |
DOCS=( LICENSE CONTRIBUTORS README.md ) |
212 |
|
213 |
-PATCHES=( "${FILESDIR}"/openh264-2.3.0-pkgconfig-pathfix.patch ) |
214 |
+PATCHES=( |
215 |
+ "${FILESDIR}"/openh264-2.3.0-pkgconfig-pathfix.patch |
216 |
+ "${FILESDIR}"/${PN}-2.3.1-pr3630.patch |
217 |
+) |
218 |
|
219 |
src_prepare() { |
220 |
default |
221 |
|
222 |
+ ln -svf "/dev/null" "build/gtest-targets.mk" || die |
223 |
+ sed -i -e 's/$(LIBPREFIX)gtest.$(LIBSUFFIX)//g' Makefile || die |
224 |
+ |
225 |
sed -i -e 's/ | generate-version//g' Makefile || die |
226 |
sed -e 's|$FULL_VERSION|""|g' codec/common/inc/version_gen.h.template > \ |
227 |
codec/common/inc/version_gen.h |
228 |
@@ -53,6 +60,7 @@ emakecmd() { |
229 |
SHAREDLIB_DIR="${EPREFIX}/usr/$(get_libdir)" \ |
230 |
INCLUDES_DIR="${EPREFIX}/usr/include/${PN}" \ |
231 |
HAVE_AVX2=$(usex cpu_flags_x86_avx2 Yes No) \ |
232 |
+ HAVE_GTEST=$(usex test Yes No) \ |
233 |
ARCH="$(tc-arch)" \ |
234 |
$@ |
235 |
} |
236 |
@@ -71,6 +79,10 @@ multilib_src_compile() { |
237 |
use plugin && emakecmd ${myopts} plugin |
238 |
} |
239 |
|
240 |
+multilib_src_test() { |
241 |
+ emakecmd test |
242 |
+} |
243 |
+ |
244 |
multilib_src_install() { |
245 |
emakecmd DESTDIR="${D}" install-shared |