Subject: [alpine-aports] [PATCH] community/mplayer: add --enable-runtime-cpudetection

From: Vladislav Ivanishin <[email-masked]>
Date: Sun, 24 Dec 2017 04:13:58 +0300

Hello, Natanael,

I installed Alpine on an old system with an Athlon 64 CPU, which does
not have SSE4* extensions. Mplayer from the official repositories
crashed immediately upon opening an audio file. The reason was an
"illegal" -- for my CPU that is -- instruction, `popcnt' in my case.

Compiling mplayer on my machine (with `abuild -r') helped (obviously).

Arch Linux folks had pretty much the same bug in 2009: [1], and I
suggest pretty much the same patch as a fix: configure with
--enable-runtime-cpudetection.

Debian `rules' for the package [2,3] also include the option, though not
for all architectures, it seems:

ifeq ($(DEB_HOST_ARCH),i386)
#configure optimizes for the cpu detected at ./configure time
#in order to build a generic binary, avoid non-standard opcodes through gcc
  archconf += --target=i586-linux
  CONFIGURE_FLAGS += --enable-runtime-cpudetection
endif
ifeq ($(DEB_HOST_ARCH),amd64)
  CONFIGURE_FLAGS += --enable-runtime-cpudetection
endif
ifeq ($(DEB_HOST_ARCH),kfreebsd-i386)
  CONFIGURE_FLAGS += --enable-runtime-cpudetection
endif
ifeq ($(DEB_HOST_ARCH),kfreebsd-amd64)
  CONFIGURE_FLAGS += --enable-runtime-cpudetection
endif
ifeq ($(DEB_HOST_ARCH),powerpc)
  CONFIGURE_FLAGS += --enable-runtime-cpudetection
endif
# when run on a sparc64 kernel, configure will normally select v9 asm.
# this is hidden when running on buildds with 32bit kernel personality.
# because of #644856, this will currently lead to a FTBFS
# therefore, we force a 'generic' target.
ifeq ($(DEB_HOST_ARCH),sparc)
  archconf += --target=generic
endif
ifeq ($(DEB_HOST_ARCH),alpha)
#Avoid high optimization through gcc.
# see http://permalink.gmane.org/gmane.linux.debian.ports.alpha/7295
  archconf += --target=alpha_ev5-linux
endif

Not sure what happens for arm here. Hope you have more knowledge. 

[1]: https://bugs.archlinux.org/task/15396
[2]: http://security.debian.org/debian-security/pool/updates/main/m/mplayer/mplayer_1.0~rc4.dfsg1+svn34540-1+deb7u2.debian.tar.gz
[3]: https://packages.debian.org/wheezy/mplayer

- Vlad

>From 5f4dbd30a3b32c5e301f69e31ffbff51618cc879 Mon Sep 17 00:00:00 2001
From: Vladislav Ivanishin <[email-masked]>
Date: Sun, 24 Dec 2017 02:55:50 +0300
Subject: [PATCH] community/mplayer: add --enable-runtime-cpudetection

---
 community/mplayer/APKBUILD | 1 +
 1 file changed, 1 insertion(+)

diff --git a/community/mplayer/APKBUILD b/community/mplayer/APKBUILD
index b218938782..0acfa6a181 100644
--- a/community/mplayer/APKBUILD
+++ b/community/mplayer/APKBUILD
@@ -23,6 +23,7 @@ build() {
 
 	./configure \
 		--prefix=/usr \
+		--enable-runtime-cpudetection \
 		--disable-gui \
 		--disable-gif \
 		--disable-arts \
-- 
2.15.0

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Natanael Copa <[email-masked]>
Date: Tue, 26 Dec 2017 12:39:21 +0100

On Sun, 24 Dec 2017 04:13:58 +0300

> "illegal" -- for my CPU that is -- instruction, `popcnt' in my case.

...
 
>  1 file changed, 1 insertion(+)

I applied and bumped pkgrel. Thanks!

-nc

---