From aa48b6fafe914e53d2d11f4e70776322ada5441f Mon Sep 17 00:00:00 2001 From: Benjamin Moody Date: Wed, 17 Jul 2024 18:19:01 -0400 Subject: [PATCH 1/9] Set interpreter (/bin/sh) for build scripts explicitly. Ensure that these scripts are executed by the standard 'sh', rather than whatever your current shell happens to be. --- linux_build.sh | 2 ++ mac_build.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/linux_build.sh b/linux_build.sh index 1896df4..19fbc46 100755 --- a/linux_build.sh +++ b/linux_build.sh @@ -1,3 +1,5 @@ +#!/bin/sh + OGGVERSION=1.3.5 VORBISVERSION=1.3.7 FLACVERSION=1.4.3 diff --git a/mac_build.sh b/mac_build.sh index eafb533..e6ac113 100755 --- a/mac_build.sh +++ b/mac_build.sh @@ -1,3 +1,5 @@ +#!/bin/sh + OGGVERSION=1.3.5 VORBISVERSION=1.3.7 FLACVERSION=1.4.3 From 732dff9acd830674dc21aed50231434fac911499 Mon Sep 17 00:00:00 2001 From: Benjamin Moody Date: Wed, 17 Jul 2024 18:23:41 -0400 Subject: [PATCH 2/9] Don't ignore failures from intermediate commands when building. --- linux_build.sh | 2 ++ mac_build.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/linux_build.sh b/linux_build.sh index 19fbc46..0f40e22 100755 --- a/linux_build.sh +++ b/linux_build.sh @@ -13,6 +13,8 @@ SNDFILENAME=libsndfile-$SNDFILE_VERSION OGG_INCDIR="$(pwd)/libogg-$OGGVERSION/include" OGG_LIBDIR="$(pwd)/libogg-$OGGVERSION/src/.libs" +set -e + # make sure all static libraries are position-independent, so we can link them # into the libsndfile.so later: export CFLAGS="-fPIC" diff --git a/mac_build.sh b/mac_build.sh index e6ac113..35fb514 100755 --- a/mac_build.sh +++ b/mac_build.sh @@ -13,6 +13,8 @@ SNDFILENAME=libsndfile-$SNDFILE_VERSION OGG_INCDIR="$(pwd)/libogg-$OGGVERSION/include" OGG_LIBDIR="$(pwd)/libogg-$OGGVERSION/src/.libs" +set -e + if [ "$1" = "arm64" ]; then echo "Cross compiling for Darwin arm64.." export MACOSX_DEPLOYMENT_TARGET=11.0 From 7ebab6a149ec192b5d537e6b623b48b03310034e Mon Sep 17 00:00:00 2001 From: Benjamin Moody Date: Wed, 17 Jul 2024 18:24:09 -0400 Subject: [PATCH 3/9] Explicitly enable libraries when configuring libsndfile. If pkg-config is installed, then libsndfile's configure will try to use pkg-config to check whether the optional dependencies (flac, ogg, vorbis, opus, mpg123) are present. (It will conclude that the packages are present because the appropriate *_CFLAGS and *_LIBS are set.) If pkg-config isn't installed, then --enable-external-libs and --enable-mpeg must be set explicitly in order to use these packages. --- linux_build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linux_build.sh b/linux_build.sh index 0f40e22..ee7fe6c 100755 --- a/linux_build.sh +++ b/linux_build.sh @@ -105,7 +105,8 @@ cp lame-$LAMEVERSION/include/*.h lame-$LAMEVERSION/include/lame curl -LO https://github.com/libsndfile/libsndfile/releases/download/$SNDFILE_VERSION/libsndfile-$SNDFILE_VERSION.tar.xz tar xvf libsndfile-$SNDFILE_VERSION.tar.xz cd $SNDFILENAME -./configure --disable-static --disable-sqlite --disable-alsa && make -j$JOBS +./configure --disable-static --disable-sqlite --disable-alsa --enable-external-libs --enable-mpeg +make -j$JOBS cd .. cp $SNDFILENAME/src/.libs/libsndfile.so libsndfile.so From 5dcf8f265ae63b3af3ba2e167364e2e6d4fa31a1 Mon Sep 17 00:00:00 2001 From: Benjamin Moody Date: Thu, 25 Jul 2024 09:53:29 -0400 Subject: [PATCH 4/9] Replace x86_64-glibc2_17 workflow with x86_64-glibc2_28. Remove the old workflow using CentOS 7 (which is unsupported and broken) and replace it with one using a newer (glibc 2.28 based) container from pypa. --- .github/workflows/build-libs.yml | 36 +++----------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build-libs.yml b/.github/workflows/build-libs.yml index adbf295..a6d1ff2 100644 --- a/.github/workflows/build-libs.yml +++ b/.github/workflows/build-libs.yml @@ -58,49 +58,19 @@ jobs: name: lib-linux-x86_64 path: "libsndfile.so" - build-libs-linux-x86_64-glibc2_17: + build-libs-linux-x86_64-glibc2_28: runs-on: "ubuntu-latest" strategy: fail-fast: true container: - image: centos:7 - env: - # OpenSSL<=1.0.2 is available for CentOS7, so we need to compile OpenSSL and Curl - SSL_VERSION: 3.1.0 - CURL_VERSION: 8.0.1 + image: quay.io/pypa/manylinux_2_28_x86_64 steps: - uses: actions/checkout@v3 - - name: Install required packages - run: | - yum install -y gcc gcc-c++ make bzip2 zlib-devel perl-core libmetalink-devel libssh2-devel c-ares-devel lbzip2 - - name: Compile OpenSSL - run : | - curl -LO https://www.openssl.org/source/openssl-${SSL_VERSION}.tar.gz - tar xvf openssl-${SSL_VERSION}.tar.gz - cd openssl-${SSL_VERSION} - ./config --prefix=/usr shared zlib-dynamic - make - make test - make install - # check version - openssl version - - name: Compile curl - run: | - curl -LO https://curl.se/download/curl-${CURL_VERSION}.tar.gz - tar xvf curl-${CURL_VERSION}.tar.gz - cd curl-${CURL_VERSION} - ./configure --enable-libcurl-option --with-openssl - make - make install - rm /usr/bin/curl - # check version - curl -V - - name: Compile library run: ./linux_build.sh - uses: actions/upload-artifact@v3 with: - name: lib-linux-x86_64-glibc2_17 + name: lib-linux-x86_64-glibc2_28 path: "libsndfile.so" build-libs-linux-arm64: From a1fa50e23dda616ea7281e7458728e49e7581b36 Mon Sep 17 00:00:00 2001 From: Benjamin Moody Date: Thu, 25 Jul 2024 16:27:34 -0400 Subject: [PATCH 5/9] Replace use of macos-11 with macos-13 and macos-14. Note that GitHub's "macos-13" runners are x86-64 whereas "macos-14" runners are arm64. --- .github/workflows/build-libs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-libs.yml b/.github/workflows/build-libs.yml index a6d1ff2..cfc0473 100644 --- a/.github/workflows/build-libs.yml +++ b/.github/workflows/build-libs.yml @@ -10,7 +10,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: ["macos-11"] + os: ["macos-13"] fail-fast: true steps: @@ -28,7 +28,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: ["macos-11"] + os: ["macos-14"] fail-fast: true steps: From 2197f3ca13899efaea086736109aa5146c40edfc Mon Sep 17 00:00:00 2001 From: Benjamin Moody Date: Thu, 25 Jul 2024 17:18:48 -0400 Subject: [PATCH 6/9] Set OGG_CFLAGS and OGG_LIBS before running libvorbis configure. The libvorbis configure script will try multiple methods to find the libogg headers and library. Using the pkg-config variables is the newer and probably-more-stable method. --- linux_build.sh | 3 +++ mac_build.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/linux_build.sh b/linux_build.sh index ee7fe6c..2f3abcd 100755 --- a/linux_build.sh +++ b/linux_build.sh @@ -31,6 +31,9 @@ cd .. # libvorbis +export OGG_CFLAGS="-I$OGG_INCDIR" +export OGG_LIBS="-L$OGG_LIBDIR -logg" + curl -LO https://downloads.xiph.org/releases/vorbis/libvorbis-$VORBISVERSION.tar.gz tar xvf libvorbis-$VORBISVERSION.tar.gz cd libvorbis-$VORBISVERSION diff --git a/mac_build.sh b/mac_build.sh index 35fb514..ad971ee 100755 --- a/mac_build.sh +++ b/mac_build.sh @@ -38,6 +38,9 @@ cd .. # libvorbis +export OGG_CFLAGS="-I$OGG_INCDIR" +export OGG_LIBS="-L$OGG_LIBDIR -logg" + curl -LO https://downloads.xiph.org/releases/vorbis/libvorbis-$VORBISVERSION.tar.gz tar zxvf libvorbis-$VORBISVERSION.tar.gz cd libvorbis-$VORBISVERSION From 7028ecb78822a5b6f7be3e75f225d13fd85bab1f Mon Sep 17 00:00:00 2001 From: Benjamin Moody Date: Thu, 25 Jul 2024 18:02:55 -0400 Subject: [PATCH 7/9] Build arm64 Linux library using a cross compiler. Instead of using an arm64 native compiler and everything else running inside an emulator, use the aarch64-linux-gnu cross compiler provided by Debian 10 (glibc 2.28). --- .github/workflows/build-libs.yml | 19 +++++++++++-------- linux_build.sh | 14 +++++++------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-libs.yml b/.github/workflows/build-libs.yml index cfc0473..82302b7 100644 --- a/.github/workflows/build-libs.yml +++ b/.github/workflows/build-libs.yml @@ -75,22 +75,25 @@ jobs: build-libs-linux-arm64: runs-on: ${{ matrix.os }} + container: debian:10 strategy: matrix: os: ["ubuntu-20.04"] fail-fast: true steps: + - name: Install aarch64-linux-gnu cross-compiler + run: | + apt-get update + apt-get install -y build-essential \ + curl \ + python3 \ + g++-aarch64-linux-gnu - uses: actions/checkout@v3 - name: Compile library - uses: pguyot/arm-runner-action@v2 - with: - base_image: raspios_lite_arm64:2022-04-04 - cpu: cortex-a53 - cpu_info: cpuinfo/raspberrypi_zero2_w_arm64 - bind_mount_repository: true - commands: | - ./linux_build.sh + run: | + export CONFIGURE_FLAGS="--host=aarch64-linux-gnu --build=x86_64-linux-gnu" + ./linux_build.sh - uses: actions/upload-artifact@v3 with: name: lib-linux-arm64 diff --git a/linux_build.sh b/linux_build.sh index 2f3abcd..bb53b7c 100755 --- a/linux_build.sh +++ b/linux_build.sh @@ -25,7 +25,7 @@ export LDFLAGS="-fPIC" curl -LO https://downloads.xiph.org/releases/ogg/libogg-$OGGVERSION.tar.gz tar xvf libogg-$OGGVERSION.tar.gz cd libogg-$OGGVERSION -./configure --disable-shared +./configure --disable-shared $CONFIGURE_FLAGS make -j$JOBS cd .. @@ -37,7 +37,7 @@ export OGG_LIBS="-L$OGG_LIBDIR -logg" curl -LO https://downloads.xiph.org/releases/vorbis/libvorbis-$VORBISVERSION.tar.gz tar xvf libvorbis-$VORBISVERSION.tar.gz cd libvorbis-$VORBISVERSION -./configure --disable-shared --with-ogg-includes=$OGG_INCDIR --with-ogg-libraries=$OGG_LIBDIR +./configure --disable-shared --with-ogg-includes=$OGG_INCDIR --with-ogg-libraries=$OGG_LIBDIR $CONFIGURE_FLAGS make -j$JOBS cd .. @@ -46,7 +46,7 @@ cd .. curl -LO https://downloads.xiph.org/releases/flac/flac-$FLACVERSION.tar.xz tar xvf flac-$FLACVERSION.tar.xz cd flac-$FLACVERSION -./configure --enable-static --disable-shared --with-ogg-includes=$OGG_INCDIR --with-ogg-libraries=$OGG_LIBDIR +./configure --enable-static --disable-shared --with-ogg-includes=$OGG_INCDIR --with-ogg-libraries=$OGG_LIBDIR $CONFIGURE_FLAGS make -j$JOBS cd .. @@ -55,7 +55,7 @@ cd .. curl -LO https://downloads.xiph.org/releases/opus/opus-$OPUSVERSION.tar.gz tar xvf opus-$OPUSVERSION.tar.gz cd opus-$OPUSVERSION -./configure --disable-shared +./configure --disable-shared $CONFIGURE_FLAGS make -j$JOBS cd .. @@ -64,7 +64,7 @@ cd .. curl -LO https://sourceforge.net/projects/mpg123/files/mpg123/$MPG123VERSION/mpg123-$MPG123VERSION.tar.bz2 tar xvf mpg123-$MPG123VERSION.tar.bz2 cd mpg123-$MPG123VERSION -./configure --enable-static --disable-shared +./configure --enable-static --disable-shared $CONFIGURE_FLAGS make -j$JOBS cd .. @@ -73,7 +73,7 @@ cd .. curl -LO https://sourceforge.net/projects/lame/files/lame/$LAMEVERSION/lame-$LAMEVERSION.tar.gz tar xvf lame-$LAMEVERSION.tar.gz cd lame-$LAMEVERSION -./configure --enable-static --disable-shared +./configure --enable-static --disable-shared $CONFIGURE_FLAGS make -j$JOBS cd .. @@ -108,7 +108,7 @@ cp lame-$LAMEVERSION/include/*.h lame-$LAMEVERSION/include/lame curl -LO https://github.com/libsndfile/libsndfile/releases/download/$SNDFILE_VERSION/libsndfile-$SNDFILE_VERSION.tar.xz tar xvf libsndfile-$SNDFILE_VERSION.tar.xz cd $SNDFILENAME -./configure --disable-static --disable-sqlite --disable-alsa --enable-external-libs --enable-mpeg +./configure --disable-static --disable-sqlite --disable-alsa --enable-external-libs --enable-mpeg $CONFIGURE_FLAGS make -j$JOBS cd .. From 3a7d7ed6c29d9101e35464daa34b931344fb0909 Mon Sep 17 00:00:00 2001 From: Benjamin Moody Date: Fri, 26 Jul 2024 11:14:32 -0400 Subject: [PATCH 8/9] Update darwin.cmake for libsndfile >= 1.2.1. In libsndfile 1.2.1 and 1.2.2, the spelling of "mpg123" in the cmake variable names was changed to lowercase. --- darwin.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/darwin.cmake b/darwin.cmake index 7574cc1..03149ef 100644 --- a/darwin.cmake +++ b/darwin.cmake @@ -17,5 +17,5 @@ set(OPUS_INCLUDE_DIR $ENV{OPUS_INCLUDE}) set(MP3LAME_LIBRARY $ENV{MP3LAME_LIBS}) set(MP3LAME_INCLUDE_DIR $ENV{MP3LAME_INCLUDE}) -set(MPG123_LIBRARY $ENV{MPG123_LIBS}) -set(MPG123_INCLUDE_DIR $ENV{MPG123_INCLUDE}) +set(mpg123_LIBRARY $ENV{MPG123_LIBS}) +set(mpg123_INCLUDE_DIR $ENV{MPG123_INCLUDE}) From 804500c476f9f8059b25eafafbe97593ee16452e Mon Sep 17 00:00:00 2001 From: Benjamin Moody Date: Fri, 26 Jul 2024 11:55:58 -0400 Subject: [PATCH 9/9] Patch libvorbis's configure for compatibility with MacOS >= 13. --- mac_build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/mac_build.sh b/mac_build.sh index ad971ee..46412ba 100755 --- a/mac_build.sh +++ b/mac_build.sh @@ -44,6 +44,7 @@ export OGG_LIBS="-L$OGG_LIBDIR -logg" curl -LO https://downloads.xiph.org/releases/vorbis/libvorbis-$VORBISVERSION.tar.gz tar zxvf libvorbis-$VORBISVERSION.tar.gz cd libvorbis-$VORBISVERSION +sed -e 's/ -force_cpusubtype_ALL / /' -i.orig configure CFLAGS=$EXTRA_CFLAGS CXXFLAGS=$EXTRA_CFLAGS ./configure $BUILD_HOST --disable-shared --with-ogg-includes=$OGG_INCDIR --with-ogg-libraries=$OGG_LIBDIR make -j$JOBS cd ..