[vlc-devel] [PATCH 2/7] extras: fix arch handling in macOS build script

Felix Paul Kühne fkuehne at videolan.org
Mon Nov 30 09:38:54 CET 2020


Hello Martin,

Thanks for your remark.

> Am 30.11.2020 um 09:23 schrieb Martin Storsjö <martin at martin.st>:
> 
> On Sun, 29 Nov 2020, Felix Paul Kühne wrote:
> 
>> From: Felix Paul Kühne <felix at feepk.net>
>> 
>> ---
>> extras/package/macosx/build.sh | 43 +++++++++++++++++++++++++---------
>> 1 file changed, 32 insertions(+), 11 deletions(-)
>> 
>> diff --git a/extras/package/macosx/build.sh b/extras/package/macosx/build.sh
>> index 87a3129bb5..44b16ce59b 100755
>> --- a/extras/package/macosx/build.sh
>> +++ b/extras/package/macosx/build.sh
>> @@ -11,6 +11,7 @@ info()
>> ARCH="x86_64"
>> MINIMAL_OSX_VERSION="10.7"
>> OSX_KERNELVERSION=`uname -r | cut -d. -f1`
>> +BUILD_ARCH=`uname -m | cut -d. -f1`
>> SDKROOT=$(xcrun --show-sdk-path)
>> VLCBUILDDIR=""
>> @@ -54,6 +55,14 @@ spopd()
>>    popd > /dev/null
>> }
>> +get_actual_arch() {
>> +    if [ "$1" = "aarch64" ]; then
>> +        echo "arm64"
>> +    else
>> +        echo "$1"
>> +    fi
>> +}
>> +
>> while getopts "hvrcpi:k:a:j:C:b:" OPTION
>> do
>>     case $OPTION in
>> @@ -124,16 +133,25 @@ builddir=`pwd`
>> info "Building in \"$builddir\""
>> -TRIPLET=$ARCH-apple-darwin$OSX_KERNELVERSION
>> +BUILD_TRIPLET=$BUILD_ARCH-apple-darwin$OSX_KERNELVERSION
>> +HOST_TRIPLET=$ARCH-apple-darwin$OSX_KERNELVERSION
>> +ACTUAL_ARCH=`get_actual_arch $ARCH`
>> python3Path=$(echo /Library/Frameworks/Python.framework/Versions/3.*/bin | awk '{print $1;}')
>> if [ ! -d "$python3Path" ]; then
>> 	python3Path=""
>> fi
>> +export AR="`xcrun --find ar`"
>> +export AS="`xcrun --find as`"
>> export CC="`xcrun --find clang`"
>> export CXX="`xcrun --find clang++`"
>> +export LD="`xcrun --find ld`"
>> +export NM="`xcrun --find nm`"
>> export OBJC="`xcrun --find clang`"
>> +export RANLIB="`xcrun --find ranlib`"
>> +export STRINGS="`xcrun --find strings`"
>> +export STRIP="`xcrun --find strip`"
>> export SDKROOT
>> export PATH="${vlcroot}/extras/tools/build/bin:${vlcroot}/contrib/${TRIPLET}/bin:$python3Path:${VLC_PATH}:/bin:/sbin:/usr/bin:/usr/sbin"
>> @@ -216,15 +234,15 @@ export CFLAGS="-Werror=partial-availability"
>> export CXXFLAGS="-Werror=partial-availability"
>> export OBJCFLAGS="-Werror=partial-availability"
>> -export EXTRA_CFLAGS="-isysroot $SDKROOT -mmacosx-version-min=$MINIMAL_OSX_VERSION -DMACOSX_DEPLOYMENT_TARGET=$MINIMAL_OSX_VERSION"
>> -export EXTRA_LDFLAGS="-Wl,-syslibroot,$SDKROOT -mmacosx-version-min=$MINIMAL_OSX_VERSION -isysroot $SDKROOT -DMACOSX_DEPLOYMENT_TARGET=$MINIMAL_OSX_VERSION"
>> +export EXTRA_CFLAGS="-isysroot $SDKROOT -mmacosx-version-min=$MINIMAL_OSX_VERSION -DMACOSX_DEPLOYMENT_TARGET=$MINIMAL_OSX_VERSION -arch $ACTUAL_ARCH"
>> +export EXTRA_LDFLAGS="-Wl,-syslibroot,$SDKROOT -mmacosx-version-min=$MINIMAL_OSX_VERSION -isysroot $SDKROOT -DMACOSX_DEPLOYMENT_TARGET=$MINIMAL_OSX_VERSION -arch $ACTUAL_ARCH"
>> # xcodebuild only allows to set a build-in sdk, not a custom one. Therefore use the default included SDK here
>> export XCODE_FLAGS="MACOSX_DEPLOYMENT_TARGET=$MINIMAL_OSX_VERSION -sdk macosx WARNING_CFLAGS=-Werror=partial-availability"
>> info "Building contribs"
>> spushd "${vlcroot}/contrib"
>> -mkdir -p contrib-$TRIPLET && cd contrib-$TRIPLET
>> -../bootstrap --build=$TRIPLET --host=$TRIPLET > $out
>> +mkdir -p contrib-$HOST_TRIPLET && cd contrib-$HOST_TRIPLET
>> +../bootstrap --build=x86_64-apple-darwin14 --host=$HOST_TRIPLET > $out
>> if [ "$REBUILD" = "yes" ]; then
> 
> Why hardcode x86_64 in the --build arg, won't this potentially mess with things if you actually build on arm64 macos?

The hardcoding was an oversight when writing the script. It needs to be replaced with BUILD_TRIPLET.

> Also, in which cases do you really need to pass --build at all? In 9 out of 10 cases I see it mostly carried around out of habit; there's very seldom a case when configure scripts can't figure it out on their own.

I fear that we have at least 3 of those cases in our contrib.

Best regards,

Felix



More information about the vlc-devel mailing list