Subject: Trying to create a x86 build of mplayer

From: Gino Lisignoli <[email-masked]>
Date: Mon, 7 Dec 2020 20:25:54 +1300

First let me preface this by saying this is beyond my capabilities.
But I am trying to create a x86 build of mplayer (purely for the
mencoder binary). My issue is abuild returns a bunch of errors about
pthread:

libavcodec/frame_thread_encoder.c: At top level:
libavcodec/frame_thread_encoder.c:46:5: error: unknown type name
'pthread_mutex_t'
   46 |     pthread_mutex_t buffer_mutex;
      |     ^~~~~~~~~~~~~~~
libavcodec/frame_thread_encoder.c:49:5: error: unknown type name
'pthread_mutex_t'
   49 |     pthread_mutex_t task_fifo_mutex;
      |     ^~~~~~~~~~~~~~~
libavcodec/frame_thread_encoder.c:50:5: error: unknown type name
'pthread_cond_t'
   50 |     pthread_cond_t task_fifo_cond;
      |     ^~~~~~~~~~~~~~
libavcodec/frame_thread_encoder.c:53:5: error: unknown type name
'pthread_mutex_t'
   53 |     pthread_mutex_t finished_task_mutex;
      |     ^~~~~~~~~~~~~~~
libavcodec/frame_thread_encoder.c:54:5: error: unknown type name
'pthread_cond_t'
   54 |     pthread_cond_t finished_task_cond;
      |     ^~~~~~~~~~~~~~
libavcodec/frame_thread_encoder.c:59:5: error: unknown type name 'pthread_t'
   59 |     pthread_t worker[MAX_THREADS];
      |     ^~~~~~~~~

Any advice on how to solve this would be appreciated.

---

From: Natanael Copa <[email-masked]>
Date: Mon, 7 Dec 2020 11:23:06 +0100

On Mon, 7 Dec 2020 20:25:54 +1300
Gino Lisignoli <[email-masked]> wrote:

> libavcodec/frame_thread_encoder.c:59:5: error: unknown type name
> 'pthread_t' 59 |     pthread_t worker[MAX_THREADS];
>       |     ^~~~~~~~~
> 

From the error messages it looks like you need to add 

#include <pthread>

to libavcodec/frame_thread_encoder.c

We dropped support for x86 in commit 1ee95a3ff6a9 (main/mplayer: fails
to build on x86) so you are pretty much on your own.

-nc

---

From: Gino Lisignoli <[email-masked]>
Date: Mon, 21 Dec 2020 17:46:14 +1300

So I got this far:

x86_musl.patch:
--- a/loader/ldt_keeper.c
+++ b/loader/ldt_keeper.c
@@ -49,7 +49,7 @@
 #if defined(__GLIBC__) &&  (__GLIBC__ < 2 || (__GLIBC__ == 2 &&
__GLIBC_MINOR__ == 0))
 _syscall3( int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount );
 #else
-int modify_ldt(int func, void *ptr, unsigned long bytecount);
+#define modify_ldt(func, ptr, bytecount) syscall(__NR_modify_ldt,
func, ptr, bytecount)
 #endif
 #else
 #if defined(__NetBSD__) || defined(__FreeBSD__) ||
defined(__OpenBSD__) || defined(__DragonFly__)

And:
APKBUILD:
--- a/community/mplayer/APKBUILD
+++ b/community/mplayer/APKBUILD
@@ -4,7 +4,7 @@ pkgver=1.4.0
 pkgrel=2
 pkgdesc="A movie player for linux"
 url="http://www.mplayerhq.hu/design7/news.html"
-arch="x86_64 aarch64"
+arch="x86 x86_64 aarch64"
 license="GPL-2.0-or-later"
 subpackages="$pkgname-doc"
 makedepends="libxxf86dga-dev libxv-dev libmad-dev lame-dev libao-dev
@@ -15,7 +15,7 @@ makedepends="libxxf86dga-dev libxv-dev libmad-dev
lame-dev libao-dev
 source="http://www.mplayerhq.hu/MPlayer/releases/MPlayer-${pkgver%.*}.tar.xz
        x11-libs.patch
        mplayer_alpine_aarch64.patch
-       "
+       x86_musl.patch"
 builddir="$srcdir"/MPlayer-${pkgver%.*}
 build() {
 case "$CARCH" in
@@ -50,6 +50,7 @@ case "$CARCH" in
                --enable-debug \
                --enable-radio \
                --enable-radio-capture \
+                --enable-pthreads \
                --extra-cflags="-I/usr/lib/live-media -O2 -fno-PIC -fno-PIE" \
                --extra-ldflags="-no-pie" \
                --disable-nemesi \
@@ -69,4 +70,5 @@ package() {
 }
 sha512sums="8ef71cad187d8c8f81c837279bd3a421b440c892d3347a667670b21c954007e35cf0d15828f0901f347b9c1b053e8da4bc7f0fb6de34382d1e463074923d7b34
 MPlayer-1.4.tar.xz
 bba012c5a116cbc6715955a0a563c89a33a1d8ad3c44301a083ce65296ba9112a88a58e38c874d9347f9c3133054e62bd16d3b3367383f207ee40ddae105081c
 x11-libs.patch
-7bcb79de0627903ae1016487f9623283d3b2b186c4f2e5686093558f8d9b5d884e3357a93f43862e14fc261e587c50cd38821896ae2bdaff3f32290194fa4b55
 mplayer_alpine_aarch64.patch"
+7bcb79de0627903ae1016487f9623283d3b2b186c4f2e5686093558f8d9b5d884e3357a93f43862e14fc261e587c50cd38821896ae2bdaff3f32290194fa4b55
 mplayer_alpine_aarch64.patch
+7f9a8bcfb5e30eef29cc4ed495448e0d1acf1fdf77c9fdcbc4721c00cf257bcb0ed5ace655acfed524aebab12955fd084d96ff2806aeb5bc5dab9a4cf84dd19c
 x86_musl.patch"

$ abuild -r
.....
.....
>>> mplayer*: Running postcheck for mplayer
>>> ERROR: mplayer*: Found textrels:
TEXTREL  /build/community/mplayer/pkg/mplayer/usr/bin/mencoder
TEXTREL  /build/community/mplayer/pkg/mplayer/usr/bin/mplayer
>>> ERROR: mplayer*: prepare_subpackages failed
>>> ERROR: mplayer: rootpkg failed

Adding options=textrels to the APKBUILD allows it to build and
package, but when I run it, it just segfaults.

Patch taken from:
https://github.com/dimkr/rlsd2/tree/master/rules/mplayer

---

From: Natanael Copa <[email-masked]>
Date: Mon, 21 Dec 2020 11:11:39 +0100

I removed x86 because I don't have time and energy to give support for
it. Sorry.

-nc

On Mon, 21 Dec 2020 17:46:14 +1300