From f909bcbff1a41c4bc684022a5a33bc1e55fe4cd5 Mon Sep 17 00:00:00 2001 From: Sarah Gilmore Date: Fri, 24 May 2024 15:50:43 -0400 Subject: [PATCH] Delete rename_macos_arm64_dylibs.sh --- dev/tasks/matlab/rename_macos_arm64_dylibs.sh | 146 ------------------ 1 file changed, 146 deletions(-) delete mode 100755 dev/tasks/matlab/rename_macos_arm64_dylibs.sh diff --git a/dev/tasks/matlab/rename_macos_arm64_dylibs.sh b/dev/tasks/matlab/rename_macos_arm64_dylibs.sh deleted file mode 100755 index 4598f4f0c8aa4..0000000000000 --- a/dev/tasks/matlab/rename_macos_arm64_dylibs.sh +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/env bash -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -set -ex - -# Issue Number 1: -# -# MATLAB's programmatic packaging interface does not properly package symbolic links. If the -# toolboxFolder argumented provided to the constructor of matlab.addons.toolbox.ToolboxOptions -# contains a symbolic link, the ToolboxOptions will resolve the symbolic link and include -# the symbolic link's target as one of the files to package instead of the link itself. -# -# Example: -# -# Suppose you had this folder structure -# -# $ tree /tmp/example -# /tmp/example -# |-- regular_file.txt -# |-- symbolic_link -> regular_file.txt -# -# Passing "/tmp/example" as the toolboxFolder argument to ToolboxOptions' constructor returns -# the following object: -# -# -# >> opts = matlab.addons.toolbox.ToolboxOptions("/tmp/example", "dummy-identifier"); -# >> opts.ToolboxFiles -# -# ans = -# -# "/private/tmp/example/regular_file.txt" -# -# Note that the ToolboxFiles property - the list of files to package - does not include the -# symbolic link. -# -# This is a bug in matlab.addons.toolbox.ToolboxOptions. -# -# Why is this a problem? -# -# On macOS, building the Arrow C++ bindings generates the following files: -# -# $ tree arrow/matlab/install/arrow_matlab/+libmexclass/+proxy/ -# . -# |-- libarrow.1700.0.0.dylib -# |-- libarrow.1700.dylib -> libarrow.1700.0.0.dylib -# |-- libarrow.dylib -> libarrow.1700.dylib -# -# When "arrow/matlab/install/arrow_matlab" is suppplied as the toolboxFolder argument -# to the constructor of ToolboxOptions, only the libarrow.1700.0.0.dylib is included as a file -# to package. This is a problem because building the MATLAB interface to Arrow creates a shared -# library called libarrowproxy.dylib, which is linked against libarrow.1700.dylib - not -# libarrow.1700.0.0.dyblib. -# -# This can be seen by calling otool with the -L flag on libarrowproxy.dylib: -# -# $ otool -L libarrowproxy.dylib | grep -E '@rpath/libarrow\.' -# @rpath/libarrow.1700.dylib -# -# To prevent a run-time linker error, we need to update the name of libarrowproxy.dylib's -# dependent shared library from @rpath/libarrow.1700.dylib to @rpath/libarrow.1700.0.0.dylib -# because only libarrow.1700.0.0.dylib is packaged. -# -# ============================================================================================== -# -# Issue Number 2: -# -# The platforms that the MATLAB Interface to Arrow supports includen Windows, Linux, -# Intel/AMD-based macOS and ARM-based macOS. Currently, we create one "monolithic" MLTBX file -# to package the interface that includes all shared libraries for all supported platforms. -# We do this because the File Exchange <-> GitHub Release integration does not support -# platform-specific MLTBX files. -# -# The problem with creating one MLTBX to package the interface for all platforms is that -# the names of the shared libraries built by the interface for Intel/AMD-based macOS -# and ARM-based macOS are identical.For example, building the interface generates the shared -# library libarrow.1700.0.0.dylib on both platforms. To avoid this duplicate name problem, -# we need to modify the names of the shared libraries generated for either Intel/AMD-based -# macOS or ARM-based macOS. - -if [ "$#" -ne 1 ]; then - echo "Usage: $0 " - exit -fi - -DYLIB_DIR=${1} -ORIG_DIR=$(pwd) - -cd ${DYLIB_DIR} - -ORIG_LIBARROW_DYLIB="$(find . -name 'libarrow.dylib' | xargs basename)" -ORIG_LIBARROW_MAJOR_DYLIB="$(find . -name 'libarrow.*.dylib' -type l | xargs basename)" -ORIG_LIBARROW_MAJOR_MINOR_PATCH_DYLIB="$(echo libarrow.*.*.dylib)" -ORIG_LIBMEXCLASS_DYLIB="$(find . -name 'libmexclass.dylib' | xargs basename)" -ORIG_LIBARROWPROXY_DYLIB="$(find . -name 'libarrowproxy.dylib' | xargs basename)" -MEX_GATEWAY="$(find . -name 'gateway.mexmaca64' | xargs basename)" - -MAJOR_MINOR_PATCH_VERSION=${ORIG_LIBARROW_MAJOR_MINOR_PATCH_DYLIB#*.} -MAJOR_MINOR_PATCH_VERSION=${MAJOR_MINOR_PATCH_VERSION%.*} - -NEW_LIBARROW_MAJOR_MINOR_PATCH_DYLIB="libarrow_arm64.${MAJOR_MINOR_PATCH_VERSION}.dylib" -NEW_LIBARROWPROXY_DYLIB="libarrowproxy_arm64.dylib" -NEW_LIBMEXCLASS_DYLIB="libmexclass_arm64.dylib" - -# Delete the symbolic links. These files are not included in the packaged MLTBX file. -rm ${ORIG_LIBARROW_MAJOR_DYLIB} -rm ${ORIG_LIBARROW_DYLIB} - -# Rename libarrow.*.*.*.dylib to libarrow_arm64.*.*.*.dylib (e.g. libarrow.1700.0.0.dylib -> libarrow_arm64.1700.0.0.dylib) -mv ${ORIG_LIBARROW_MAJOR_MINOR_PATCH_DYLIB} ${NEW_LIBARROW_MAJOR_MINOR_PATCH_DYLIB} -# Rename libarrowproxy.dylib to libarrowproxy_arm64.dylib -mv ${ORIG_LIBARROWPROXY_DYLIB} ${NEW_LIBARROWPROXY_DYLIB} -# Rename libmexclass.dylib to libmexclass_arm64.dylib -mv ${ORIG_LIBMEXCLASS_DYLIB} ${NEW_LIBMEXCLASS_DYLIB} - -# Update the identificaton names of the renamed dynamic libraries -install_name_tool -id @rpath/${NEW_LIBMEXCLASS_DYLIB} ${NEW_LIBMEXCLASS_DYLIB} -install_name_tool -id @rpath/${NEW_LIBARROWPROXY_DYLIB} ${NEW_LIBARROWPROXY_DYLIB} -install_name_tool -id @rpath/${NEW_LIBARROW_MAJOR_MINOR_PATCH_DYLIB} ${NEW_LIBARROW_MAJOR_MINOR_PATCH_DYLIB} - -# Change install name of dependent shared library libarrow.*.*.*.dylib to libarrow_arm64.*.*.*.dylib in libarrowproxy_arm64.dylib -install_name_tool -change @rpath/${ORIG_LIBARROW_MAJOR_DYLIB} @rpath/${NEW_LIBARROW_MAJOR_MINOR_PATCH_DYLIB} ${NEW_LIBARROWPROXY_DYLIB} -# Change install name of dependent shared library libmexclass.dylib to libmexclass_arm64.*.*.*.dylib libarrowproxy_arm64.dylib -install_name_tool -change @rpath/${ORIG_LIBMEXCLASS_DYLIB} @rpath/${NEW_LIBMEXCLASS_DYLIB} ${NEW_LIBARROWPROXY_DYLIB} - -# Change install name of dependent shared library libmexclass.dylib to libmexclass_arm64.dylib in gateway.mexmaca64 -install_name_tool -change @rpath/${ORIG_LIBMEXCLASS_DYLIB} @rpath/${NEW_LIBMEXCLASS_DYLIB} ${MEX_GATEWAY} -# Change install name of dependent shared library libarrowproxy.dylib to libarrowproxy_arm64.dylib in gateway.mexmaca64 -install_name_tool -change @rpath/${ORIG_LIBARROWPROXY_DYLIB} @rpath/${NEW_LIBARROWPROXY_DYLIB} ${MEX_GATEWAY} - -cd ${ORIG_DIR}