Skip to content

Commit 88c4f92

Browse files
committed
Fix paths for dylibs for Apple platforms
Embedded paths in dylibs are absolute paths of where they were built. This makes it so that on CI it embeds the full CI path of artefacts which is then traversed and the binary is not found when linking. To fix that `install_name_tool` must be used. The effects can be observed by using MacOS tool called `otool`(part of XCode tools). ``` $ otool lib.dylib ... Load command 3 cmd LC_ID_DYLIB name /Users/[REDACTED]/target/lib.dylib ... ``` Signed-off-by: Lukas Pukenis <[email protected]>
1 parent 4f1ecf8 commit 88c4f92

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

rust_build_utils/darwin_build_utils.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,17 @@ def create_xcframework(
185185
command = ["xcodebuild", "-create-xcframework"]
186186

187187
for target_os in target_os_list:
188-
command.extend(
189-
[
190-
"-library",
191-
str(
192-
get_universal_library_distribution_directory(
193-
project, target_os, debug
194-
)
195-
/ library_file_name
196-
),
197-
]
188+
lib_path = str(
189+
get_universal_library_distribution_directory(project, target_os, debug)
190+
/ library_file_name
198191
)
192+
193+
# fix @rpath to relative one since the absolute is embedded at this point
194+
subprocess.run(
195+
["install_name_tool", "-id", f"@rpath/{library_file_name}", lib_path],
196+
check=True,
197+
)
198+
command.extend(["-library", lib_path])
199199
command.extend(["-headers", str(temp_headers)])
200200

201201
command.extend(["-output", str(framework_path)])

0 commit comments

Comments
 (0)