@@ -47,19 +47,6 @@ function ensure_soname(prefix::Prefix, path::AbstractString, platform::AbstractP
4747 return true
4848 end
4949
50- # macOS uses install_name_tool (check first since Sys.isbsd is true for macOS too)
51- if Sys. isapple (platform)
52- return _ensure_soname_macho (prefix, path, platform; verbose, autofix, subdir)
53- end
54-
55- # For Linux/FreeBSD, wrap the entire read-modify-verify cycle in the file lock
56- return with_patchelf_lock (path) do
57- _ensure_soname_elf (prefix, path, platform; verbose, autofix, subdir)
58- end
59- end
60-
61- function _ensure_soname_macho (prefix:: Prefix , path:: AbstractString , platform:: AbstractPlatform ;
62- verbose:: Bool = false , autofix:: Bool = false , subdir:: AbstractString = " " )
6350 # Skip if this file already contains an SONAME
6451 rel_path = relpath (realpath (path), realpath (prefix. path))
6552 soname = get_soname (path)
@@ -78,55 +65,19 @@ function _ensure_soname_macho(prefix::Prefix, path::AbstractString, platform::Ab
7865 end
7966
8067 # Otherwise, set the SONAME
68+ # Create a new linkage that looks like @rpath/$lib on OSX
8169 retval = with_logfile (prefix, " set_soname_$(basename (rel_path)) _$(soname) .log" ; subdir) do io
82- ur = preferred_runner ()(prefix. path; cwd= " /workspace/" , platform= platform)
83- install_name_tool = " /opt/bin/$(triplet (ur. platform)) /install_name_tool"
84- set_soname_cmd = ` $install_name_tool -id $(soname) $(rel_path) `
85- @lock AUDITOR_SANDBOX_LOCK run (ur, set_soname_cmd, io; verbose= verbose)
86- end
87-
88- if ! retval
89- @lock AUDITOR_LOGGING_LOCK @warn (" Unable to set SONAME on $(rel_path) " )
90- return false
91- end
92-
93- # Read the SONAME back in and ensure it's set properly
94- new_soname = get_soname (path)
95- if new_soname != soname
96- @lock AUDITOR_LOGGING_LOCK @warn (" Set SONAME on $(rel_path) to $(soname) , but read back $(string (new_soname)) !" )
97- return false
98- end
99-
100- if verbose
101- @lock AUDITOR_LOGGING_LOCK @info (" Set SONAME of $(rel_path) to \" $(soname) \" " )
102- end
103-
104- return true
105- end
106-
107- # This function is called with the patchelf lock already held
108- function _ensure_soname_elf (prefix:: Prefix , path:: AbstractString , platform:: AbstractPlatform ;
109- verbose:: Bool = false , autofix:: Bool = false , subdir:: AbstractString = " " )
110- # Skip if this file already contains an SONAME
111- rel_path = relpath (realpath (path), realpath (prefix. path))
112- soname = get_soname (path)
113- if soname != nothing
114- if verbose
115- @lock AUDITOR_LOGGING_LOCK @info (" $(rel_path) already has SONAME \" $(soname) \" " )
70+ if Sys. isapple (platform)
71+ ur = preferred_runner ()(prefix. path; cwd= " /workspace/" , platform= platform)
72+ install_name_tool = " /opt/bin/$(triplet (ur. platform)) /install_name_tool"
73+ set_soname_cmd = ` $install_name_tool -id $(soname) $(rel_path) `
74+ @lock AUDITOR_SANDBOX_LOCK run (ur, set_soname_cmd, io; verbose= verbose)
75+ else
76+ # For Linux/FreeBSD, wrap the entire read-modify-verify cycle in the file lock
77+ with_patchelf_lock (path) do
78+ success (run_with_io (io, ` $(patchelf ()) $(patchelf_flags (platform)) --set-soname $(soname) $(realpath (path)) ` ; wait= false ))
79+ end
11680 end
117- return true
118- else
119- soname = basename (path)
120- end
121-
122- # If we're not allowed to fix it, fail out
123- if ! autofix
124- return false
125- end
126-
127- # Otherwise, set the SONAME
128- retval = with_logfile (prefix, " set_soname_$(basename (rel_path)) _$(soname) .log" ; subdir) do io
129- success (run_with_io (io, ` $(patchelf ()) $(patchelf_flags (platform)) --set-soname $(soname) $(realpath (path)) ` ; wait= false ))
13081 end
13182
13283 if ! retval
0 commit comments