From cbaa0ea8aa9907054095b71a8275a9a09789c4a6 Mon Sep 17 00:00:00 2001 From: Dan Zheng Date: Mon, 10 Jun 2019 09:13:58 -0700 Subject: [PATCH] [TF] install_name_dir workaround for Python and TensorFlow modules. `install_name_dir` for the standard library has been changed from @rpath to /usr/lib/swift in https://github.com/apple/swift/pull/24382. This patch may resolve "Library not loaded: /usr/lib/swift/libswiftTensorFlow.dylib" linker issues: https://github.com/tensorflow/swift-apis/pull/136 --- stdlib/public/Python/CMakeLists.txt | 5 ++++- stdlib/public/TensorFlow/CMakeLists.txt | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/stdlib/public/Python/CMakeLists.txt b/stdlib/public/Python/CMakeLists.txt index 5620608354049..1e4d3657ff9a9 100644 --- a/stdlib/public/Python/CMakeLists.txt +++ b/stdlib/public/Python/CMakeLists.txt @@ -40,4 +40,7 @@ add_swift_target_library(swiftPython ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS SWIFT_MODULE_DEPENDS_CYGWIN Glibc SWIFT_MODULE_DEPENDS_HAIKU Glibc SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}" - LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}") + LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}" + # NOTE: This is a workaround for https://github.com/apple/swift/pull/24382, + # which changed the default install_name_dir to `/usr/bin/swift`. + DARWIN_INSTALL_NAME_DIR "@rpath") diff --git a/stdlib/public/TensorFlow/CMakeLists.txt b/stdlib/public/TensorFlow/CMakeLists.txt index 3628bac4e1bb9..f56d2d1efa074 100644 --- a/stdlib/public/TensorFlow/CMakeLists.txt +++ b/stdlib/public/TensorFlow/CMakeLists.txt @@ -67,4 +67,7 @@ add_swift_target_library(swiftTensorFlow ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_ SWIFT_COMPILE_FLAGS "${swift_stdlib_compile_flags}" LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}" INSTALL_IN_COMPONENT stdlib - EXTRA_RPATHS "${SWIFT_TENSORFLOW_TARGET_LIB_DIR}") + EXTRA_RPATHS "${SWIFT_TENSORFLOW_TARGET_LIB_DIR}" + # NOTE: This is a workaround for https://github.com/apple/swift/pull/24382, + # which changed the default install_name_dir to `/usr/bin/swift`. + DARWIN_INSTALL_NAME_DIR "@rpath")