Skip to content

Commit f6eda0f

Browse files
authored
Merge pull request #9 from staticfloat/sf/better_find_libraries
Strip `@loader_path` from libpaths in `find_libraries()`
2 parents 2ad43af + 80eeb49 commit f6eda0f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/Abstract/ObjectHandle.jl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,25 @@ function find_libraries(oh::ObjectHandle)
391391
rpath = RPath(oh)
392392
sonames = [path(dl) for dl in DynamicLinks(oh)]
393393

394-
# Remote '@rpath/' prefix if it exists
394+
# Remove '@rpath/' prefix if it exists
395395
function strip_rpath(soname)
396396
if startswith(soname, "@rpath/")
397397
return soname[8:end]
398398
end
399+
return soname
400+
end
401+
402+
# Translate `@loader_path/` to the actual path of the binary
403+
function strip_loader_path(soname)
404+
if startswith(soname, "@loader_path/")
405+
return joinpath(dirname(path(oh)), soname[14:end])
406+
end
399407
return soname
400408
end
401409

402-
return Dict(s => find_library(oh, strip_rpath(s)) for s in sonames)
410+
# Get rid of confusing loader tokens
411+
sonames = strip_rpath.(sonames)
412+
sonames = strip_loader_path.(sonames)
413+
414+
return Dict(s => find_library(oh, s) for s in sonames)
403415
end

0 commit comments

Comments
 (0)