From 9b37b3ea4467b3aab9110e0d259d0cf27478697d Mon Sep 17 00:00:00 2001 From: Chester Liu <4710575+skyline75489@users.noreply.github.com> Date: Mon, 23 Sep 2024 17:19:30 +0800 Subject: [PATCH] Specify the paths of system tools when building Apple framework (#22056) ### Description Specify the path of `ar`, `ld` and `libtool` when building apple framework. ### Motivation and Context Sometimes non-system executables will comes before the system-provided ones. This PR intends to prevent it from happening. --- cmake/onnxruntime.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/onnxruntime.cmake b/cmake/onnxruntime.cmake index 7e992fb330..f2be742458 100644 --- a/cmake/onnxruntime.cmake +++ b/cmake/onnxruntime.cmake @@ -352,12 +352,12 @@ if(onnxruntime_BUILD_APPLE_FRAMEWORK) # make both maccatalyst and other builds do the same thing. set(CUR_TARGET_CMAKE_SOURCE_LIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_LIB}.dir) add_custom_command(TARGET onnxruntime POST_BUILD - COMMAND ar -t $ | grep "\.o$" > ${_LIB}.object_file_list.txt + COMMAND /usr/bin/ar -t $ | grep "\.o$" > ${_LIB}.object_file_list.txt COMMAND ${CMAKE_COMMAND} -E env python3 ${CMAKE_CURRENT_SOURCE_DIR}/maccatalyst_prepare_objects_for_prelink.py ${CUR_TARGET_CMAKE_SOURCE_LIB_DIR} ${CUR_STATIC_LIB_OBJ_DIR} ${CUR_STATIC_LIB_OBJ_DIR}/${_LIB}.object_file_list.txt WORKING_DIRECTORY ${CUR_STATIC_LIB_OBJ_DIR}) else() add_custom_command(TARGET onnxruntime POST_BUILD - COMMAND ar ARGS -x $ + COMMAND /usr/bin/ar ARGS -x $ WORKING_DIRECTORY ${CUR_STATIC_LIB_OBJ_DIR}) endif() endif() @@ -378,12 +378,12 @@ if(onnxruntime_BUILD_APPLE_FRAMEWORK) # do the pre-link with `ld -r` to create a single relocatable object with correct symbol visibility add_custom_command(TARGET onnxruntime POST_BUILD - COMMAND ld ARGS -r -o ${STATIC_LIB_DIR}/prelinked_objects.o */*.o ../*.a + COMMAND /usr/bin/ld ARGS -r -o ${STATIC_LIB_DIR}/prelinked_objects.o */*.o ../*.a WORKING_DIRECTORY ${STATIC_LIB_TEMP_DIR}) # create the static library add_custom_command(TARGET onnxruntime POST_BUILD - COMMAND libtool -static -o ${STATIC_FRAMEWORK_DIR}/onnxruntime prelinked_objects.o + COMMAND /usr/bin/libtool -static -o ${STATIC_FRAMEWORK_DIR}/onnxruntime prelinked_objects.o WORKING_DIRECTORY ${STATIC_LIB_DIR}) # Assemble the other pieces of the static framework