[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:45:26 CET 2020


Hi David,

Thanks again for your timely review!

> Am 30.11.2020 um 08:46 schrieb naich64 <david.fuhrmann at gmail.com>:
> 
> 
> Hi Felix,
> 
> Thanks for those patches.
> 
>> Am 29.11.2020 um 20:12 schrieb Felix Paul Kühne <fkuehne at videolan.org>:
>> 
>> 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`
> 
> This takes arch from the command line options. Can’t we just drop get_actual_arch, and pass the intended arch, like arm64, to the script directly?

No, because for the HOST_TRIPLET, you need aarch64 as this is what most of the contrib libraries expect. They fail when using arm64 instead.

> 
>> 
>> 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`"
> 
> Ok for now, but maybe we can drop that section altogether eventually? Tools seem to be aliased into /usr/bin nowadays.

This really helps if you have more than one Xcode installation and you switch between them as those links are not updated when you switch with xcode-select.

> 
>> 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
> 
> Why hardcoding darwin14 here? Shouldn’t we rather use $BUILD_TRIPLET, like you already use for the configure call of VLC?

It’s an oversight and your idea is absolutely right. BUILD_TRIPLET must be used here.

Best regards,

Felix



More information about the vlc-devel mailing list