[vlc-commits] apple/build: Fix workaround for cross-compilation

Marvin Scholz git at videolan.org
Tue Dec 10 15:17:47 CET 2019


vlc | branch: master | Marvin Scholz <epirat07 at gmail.com> | Tue Dec 10 15:16:15 2019 +0100| [aa28053ba22c108697fcebfff3943080e7e5e904] | committer: Marvin Scholz

apple/build: Fix workaround for cross-compilation

This fixes the workaround for cross-compilation for the iOS Simulator
introduced in 43826f9fd75b53346c79ba9b8071237c03723c9e

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=aa28053ba22c108697fcebfff3943080e7e5e904
---

 extras/package/apple/build.sh | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/extras/package/apple/build.sh b/extras/package/apple/build.sh
index ab2daf53d7..12a87d50d8 100755
--- a/extras/package/apple/build.sh
+++ b/extras/package/apple/build.sh
@@ -173,6 +173,8 @@ set_deployment_target()
 }
 
 # Validates the architecture and sets VLC_HOST_ARCH
+# This MUST set the arch to what the compiler accepts
+# for the -arch argument!
 # Globals:
 #   VLC_HOST_ARCH
 # Arguments:
@@ -192,6 +194,26 @@ validate_architecture()
     esac
 }
 
+# Set the VLC_HOST_TRIPLET based on the architecture
+# by querying the compiler for it, as the VLC_HOST_ARCH
+# can not be used in the triplet directly, like in
+# case of arm64.
+# Globals:
+#   CC
+#   VLC_HOST_TRIPLET
+# Arguments:
+#   Architecture string
+set_host_triplet()
+{
+    local triplet_arch = $(${CC:-cc} -arch "$1" -dumpmachine | cut -d- -f 1)
+    # We can not directly use the compiler value here as when building for
+    # x86_64 iOS Simulator the triplet will match the build machine triplet
+    # exactly, which will cause autoconf to assume we are not cross-compiling.
+    # Therefore we construct a triplet here without a version number, which
+    # will not match the autoconf "guessed" host machine triplet.
+    VLC_HOST_TRIPLET="${triplet_arch}-apple-darwin"
+}
+
 # Take SDK name, verify it exists and populate
 # VLC_HOST_*, VLC_APPLE_SDK_PATH variables based
 # on the SDK and calls the set_deployment_target
@@ -418,14 +440,12 @@ check_tool xcrun
 # Validate given SDK name
 validate_sdk_name "$VLC_APPLE_SDK_NAME"
 
-# Set triplet (query the compiler for this)
-# FIXME: we hard-code the version number here so HOST and BUILD will not be same
-# which fixes cross-compilation for x86_64
-# note that for 'aarch64', we need to specify it like this here and sanity to 'arm64' afterwards
-readonly VLC_HOST_TRIPLET="${VLC_HOST_ARCH}-apple-darwin18"
-
 # Validate architecture argument
 validate_architecture "$VLC_HOST_ARCH"
+
+# Set triplet (needs to be called after validating the arch)
+set_host_triplet "$VLC_HOST_ARCH"
+
 # Set pseudo-triplet
 readonly VLC_PSEUDO_TRIPLET="${VLC_HOST_ARCH}-apple-${VLC_HOST_PLATFORM}_${VLC_DEPLOYMENT_TARGET}"
 # Contrib install dir



More information about the vlc-commits mailing list