commit:     8da9ea49f14cfc17a49174d51b608f7484daba19
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 15 04:13:55 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Sep 15 04:33:09 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8da9ea49

media-libs/alsa-lib: fix 32-bit LFS mismatches

Signed-off-by: Sam James <sam <AT> gentoo.org>

 media-libs/alsa-lib/alsa-lib-1.2.10-r2.ebuild      | 102 ++++++++++++
 ...sa-lib-1.2.10-pcm-fix-segfault-32bit-libs.patch |  91 +++++++++++
 ...-1.2.10-reshuffle-included-files-config-h.patch | 174 +++++++++++++++++++++
 3 files changed, 367 insertions(+)

diff --git a/media-libs/alsa-lib/alsa-lib-1.2.10-r2.ebuild 
b/media-libs/alsa-lib/alsa-lib-1.2.10-r2.ebuild
new file mode 100644
index 000000000000..4b5a3c65e8bb
--- /dev/null
+++ b/media-libs/alsa-lib/alsa-lib-1.2.10-r2.ebuild
@@ -0,0 +1,102 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{10..11} )
+inherit autotools multilib-minimal flag-o-matic python-single-r1
+
+DESCRIPTION="Advanced Linux Sound Architecture Library"
+HOMEPAGE="https://alsa-project.org/wiki/Main_Page";
+if [[ ${PV} == *_p* ]] ; then
+       # Please set correct commit ID for a snapshot release!
+       COMMIT="abe805ed6c7f38e48002e575535afd1f673b9bcd"
+       
SRC_URI="https://git.alsa-project.org/?p=${PN}.git;a=snapshot;h=${COMMIT};sf=tgz
 -> ${P}.tar.gz"
+       S="${WORKDIR}"/${PN}-${COMMIT:0:7}
+else
+       # TODO: Upstream does publish .sig files, so someone could implement 
verify-sig ;)
+       SRC_URI="https://www.alsa-project.org/files/pub/lib/${P}.tar.bz2";
+fi
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 
~riscv ~sparc ~x86 ~amd64-linux ~x86-linux"
+IUSE="alisp debug doc python"
+REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
+
+RDEPEND="
+       media-libs/alsa-topology-conf
+       media-libs/alsa-ucm-conf
+       python? ( ${PYTHON_DEPS} )
+"
+DEPEND="${RDEPEND}"
+BDEPEND="doc? ( >=app-doc/doxygen-1.2.6 )"
+
+PATCHES=(
+       "${FILESDIR}/${PN}-1.1.6-missing_files.patch" # bug #652422
+       "${FILESDIR}/${P}-musl-string.patch" # bug #913573, backport
+       "${FILESDIR}/${P}-ump-header-detection.patch" # bug #913573, backport
+       "${FILESDIR}/${P}-pcm-fix-segfault-32bit-libs.patch" # backport
+       "${FILESDIR}/${P}-reshuffle-included-files-config-h.patch" # backport
+)
+
+pkg_setup() {
+       use python && python-single-r1_pkg_setup
+}
+
+src_prepare() {
+       default
+
+       find . -name Makefile.am -exec sed -i -e '/CFLAGS/s:-g -O2::' {} + || 
die
+       # bug #545950
+       sed -i -e '5s:^$:\nAM_CPPFLAGS = -I$(top_srcdir)/include:' 
test/lsb/Makefile.am || die
+
+       eautoreconf
+}
+
+multilib_src_configure() {
+       # Broken upstream. Could in theory work with -flto-partitions=none
+       # but it's a hack to workaround the real problem and not strictly safe.
+       # bug #616108, bug #669086, and 
https://github.com/alsa-project/alsa-lib/issues/6.
+       # (This bug is closed as of 1.2.9 but there's been no clear actual fix 
to it.
+       # Let us know if you can identify one.)
+       filter-lto
+
+       local myeconfargs=(
+               --disable-maintainer-mode
+               --disable-resmgr
+               --enable-aload
+               --enable-rawmidi
+               --enable-seq
+               --enable-shared
+               --enable-thread-safety
+
+               $(multilib_native_use_enable python)
+               $(use_enable alisp)
+               $(use_with debug)
+       )
+
+       ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
+}
+
+multilib_src_compile() {
+       emake
+
+       if multilib_is_native_abi && use doc; then
+               emake doc
+               grep -FZrl "${S}" doc/doxygen/html | \
+                       xargs -0 sed -i -e "s:${S}::" || die
+       fi
+}
+
+multilib_src_install() {
+       multilib_is_native_abi && use doc && local HTML_DOCS=( 
doc/doxygen/html/. )
+
+       default
+}
+
+multilib_src_install_all() {
+       find "${ED}" -type f -name '*.la' -delete || die
+
+       dodoc ChangeLog doc/asoundrc.txt NOTES TODO
+}

diff --git 
a/media-libs/alsa-lib/files/alsa-lib-1.2.10-pcm-fix-segfault-32bit-libs.patch 
b/media-libs/alsa-lib/files/alsa-lib-1.2.10-pcm-fix-segfault-32bit-libs.patch
new file mode 100644
index 000000000000..4cd3614ee943
--- /dev/null
+++ 
b/media-libs/alsa-lib/files/alsa-lib-1.2.10-pcm-fix-segfault-32bit-libs.patch
@@ -0,0 +1,91 @@
+https://github.com/alsa-project/alsa-lib/commit/0e3dfb9f705ca78be34cd70fd59d67c431e29cc7
+
+From 0e3dfb9f705ca78be34cd70fd59d67c431e29cc7 Mon Sep 17 00:00:00 2001
+From: Takashi Iwai <ti...@suse.de>
+Date: Sat, 9 Sep 2023 17:42:03 +0200
+Subject: [PATCH] pcm: Fix segfault with 32bit libs
+
+The recent rearrangement of header inclusion order caused a regression
+showing segfaults on 32bit Arm.  The primary reason is the
+inconsistent compile condition depending on the inclusion of config.h;
+while most of other code include pcm_local.h (that implicitly includes
+config.h) at first, pcm_direct.c doesn't do it, hence the access with
+direct plugins crashes.
+
+For fixing it, we need to include config.h at the beginning.  But,
+it's better to include pcm_local.h for all relevant code for
+consistency.  The patch does it, and also it adds the guard in
+pcm_local.h for double inclusions.
+
+Fixes: ad3a8b8b314e ("reshuffle included files to include config.h as first")
+Link: https://github.com/alsa-project/alsa-lib/issues/352
+Signed-off-by: Takashi Iwai <ti...@suse.de>
+--- a/src/pcm/pcm_direct.c
++++ b/src/pcm/pcm_direct.c
+@@ -19,6 +19,7 @@
+  *
+  */
+   
++#include "pcm_local.h"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <stddef.h>
+--- a/src/pcm/pcm_dmix.c
++++ b/src/pcm/pcm_dmix.c
+@@ -26,7 +26,7 @@
+  *
+  */
+   
+-#include "config.h"
++#include "pcm_local.h"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <stddef.h>
+--- a/src/pcm/pcm_dshare.c
++++ b/src/pcm/pcm_dshare.c
+@@ -26,6 +26,7 @@
+  *
+  */
+   
++#include "pcm_local.h"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <stddef.h>
+--- a/src/pcm/pcm_dsnoop.c
++++ b/src/pcm/pcm_dsnoop.c
+@@ -26,6 +26,7 @@
+  *
+  */
+   
++#include "pcm_local.h"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <stddef.h>
+--- a/src/pcm/pcm_local.h
++++ b/src/pcm/pcm_local.h
+@@ -20,6 +20,9 @@
+  *
+  */
+ 
++#ifndef __PCM_LOCAL_H
++#define __PCM_LOCAL_H
++
+ #include "config.h"
+ 
+ #include <stdio.h>
+@@ -1223,3 +1226,5 @@ static inline void snd_pcm_unlock(snd_pcm_t *pcm)
+ #define snd_pcm_lock(pcm)             do {} while (0)
+ #define snd_pcm_unlock(pcm)           do {} while (0)
+ #endif /* THREAD_SAFE_API */
++
++#endif /* __PCM_LOCAL_H */
+--- a/src/pcm/pcm_shm.c
++++ b/src/pcm/pcm_shm.c
+@@ -26,6 +26,7 @@
+  *
+  */
+   
++#include "pcm_local.h"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <stddef.h>

diff --git 
a/media-libs/alsa-lib/files/alsa-lib-1.2.10-reshuffle-included-files-config-h.patch
 
b/media-libs/alsa-lib/files/alsa-lib-1.2.10-reshuffle-included-files-config-h.patch
new file mode 100644
index 000000000000..42493fef6af1
--- /dev/null
+++ 
b/media-libs/alsa-lib/files/alsa-lib-1.2.10-reshuffle-included-files-config-h.patch
@@ -0,0 +1,174 @@
+https://github.com/alsa-project/alsa-lib/commit/81a7a93636d9472fcb0c2ff32d9bfdf6ed10763d
+
+From 81a7a93636d9472fcb0c2ff32d9bfdf6ed10763d Mon Sep 17 00:00:00 2001
+From: Jaroslav Kysela <pe...@perex.cz>
+Date: Wed, 13 Sep 2023 12:27:21 +0200
+Subject: [PATCH] reshuffle included files to include config.h as first - v2
+
+config.h may contain defines like _FILE_OFFSET_BITS which influence
+the system wide include files (off_t types, open -> open64 function
+usage etc.).
+
+Fixes: ad3a8b8b ("reshuffle included files to include config.h as first")
+Related: https://github.com/alsa-project/alsa-lib/pull/333
+Signed-off-by: Jaroslav Kysela <pe...@perex.cz>
+--- a/src/control/setup.c
++++ b/src/control/setup.c
+@@ -29,13 +29,13 @@
+  *
+  */
+ 
++#include "local.h"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <stdarg.h>
+ #include <unistd.h>
+ #include <string.h>
+ #include <ctype.h>
+-#include "local.h"
+ 
+ #ifndef DOC_HIDDEN
+ typedef struct {
+--- a/src/rawmidi/rawmidi.c
++++ b/src/rawmidi/rawmidi.c
+@@ -144,12 +144,12 @@ This example shows open and read/write rawmidi 
operations.
+  * Shows open and read/write rawmidi operations.
+  */
+  
++#include "rawmidi_local.h"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <stdarg.h>
+ #include <unistd.h>
+ #include <string.h>
+-#include "rawmidi_local.h"
+ 
+ /**
+  * \brief setup the default parameters
+--- a/src/rawmidi/rawmidi_local.h
++++ b/src/rawmidi/rawmidi_local.h
+@@ -19,10 +19,10 @@
+  *
+  */
+ 
++#include "local.h"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <limits.h>
+-#include "local.h"
+ 
+ typedef struct {
+       int (*close)(snd_rawmidi_t *rawmidi);
+--- a/src/rawmidi/rawmidi_virt.c
++++ b/src/rawmidi/rawmidi_virt.c
+@@ -19,13 +19,11 @@
+  *
+  */
+ 
+-#include <stdio.h>
+-#include <stdlib.h>
++#include "rawmidi_local.h"
+ #include <unistd.h>
+ #include <string.h>
+ #include <fcntl.h>
+ #include <sys/ioctl.h>
+-#include "rawmidi_local.h"
+ #include "seq.h"
+ #include "seq_midi_event.h"
+ 
+--- a/src/rawmidi/ump.c
++++ b/src/rawmidi/ump.c
+@@ -4,10 +4,6 @@
+  * \brief Universal MIDI Protocol (UMP) Interface
+  */
+ 
+-#include <stdio.h>
+-#include <stdlib.h>
+-#include <limits.h>
+-#include "local.h"
+ #include "rawmidi_local.h"
+ #include "ump_local.h"
+ 
+--- a/src/seq/seq.c
++++ b/src/seq/seq.c
+@@ -777,8 +777,8 @@ void event_filter(snd_seq_t *seq, snd_seq_event_t *ev)
+ 
+ */
+ 
+-#include <poll.h>
+ #include "seq_local.h"
++#include <poll.h>
+ 
+ /****************************************************************************
+  *                                                                          *
+--- a/src/seq/seq_hw.c
++++ b/src/seq/seq_hw.c
+@@ -20,9 +20,9 @@
+  *
+  */
+ 
++#include "seq_local.h"
+ #include <fcntl.h>
+ #include <sys/ioctl.h>
+-#include "seq_local.h"
+ 
+ #ifndef PIC
+ /* entry for static linking */
+--- a/src/seq/seq_local.h
++++ b/src/seq/seq_local.h
+@@ -23,10 +23,10 @@
+ #ifndef __SEQ_LOCAL_H
+ #define __SEQ_LOCAL_H
+ 
++#include "local.h"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <limits.h>
+-#include "local.h"
+ 
+ #define SND_SEQ_OBUF_SIZE     (16*1024)       /* default size */
+ #define SND_SEQ_IBUF_SIZE     500             /* in event_size aligned */
+--- a/src/seq/seq_midi_event.c
++++ b/src/seq/seq_midi_event.c
+@@ -28,10 +28,10 @@
+  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  
02110-1301  USA
+  */
+ 
++#include "local.h"
+ #if HAVE_MALLOC_H
+ #include <malloc.h>
+ #endif
+-#include "local.h"
+ 
+ #ifndef DOC_HIDDEN
+ 
+--- a/src/seq/seqmid.c
++++ b/src/seq/seqmid.c
+@@ -20,14 +20,12 @@
+  *
+  */
+ 
+-#include <stdio.h>
+-#include <stdlib.h>
++#include "seq_local.h"
+ #include <unistd.h>
+ #include <string.h>
+ #include <fcntl.h>
+ #include <ctype.h>
+ #include <sys/ioctl.h>
+-#include "seq_local.h"
+ 
+ /**
+  * \brief queue controls - start/stop/continue
+--- a/src/userfile.c
++++ b/src/userfile.c
+@@ -18,7 +18,7 @@
+  *
+  */
+   
+-#include <config.h>
++#include "config.h"
+ #include <string.h>
+ #include <errno.h>
+ #include <assert.h>
+

Reply via email to