os/mac: Flush RPATHs from Mach-Os when possible

This commit is contained in:
William Woodruff 2018-12-27 13:30:16 -05:00 committed by William Woodruff
parent 2e2dea6131
commit 54aca0d14f
No known key found for this signature in database
GPG Key ID: 600D68320BE45ACC
2 changed files with 13 additions and 0 deletions

View File

@ -69,6 +69,15 @@ class Keg
new_name = fixed_name(file, bad_name) new_name = fixed_name(file, bad_name)
change_install_name(bad_name, new_name, file) unless new_name == bad_name change_install_name(bad_name, new_name, file) unless new_name == bad_name
end end
# If none of the install names reference RPATH(s), then we can safely
# remove all RPATHs from the file.
if file.dynamically_linked_libraries.none? { |lib| lib.start_with?("@rpath") }
# Note: This could probably be made more efficient by reverse-sorting
# the RPATHs by offset and calling MachOFile#delete_command
# with repopulate: false.
file.rpaths.each { |r| file.delete_rpath(r) }
end
end end
end end

View File

@ -64,6 +64,10 @@ module MachOShim
macho.rpaths macho.rpaths
end end
def delete_rpath(rpath)
macho.delete_rpath(rpath)
end
def archs def archs
mach_data.map { |m| m.fetch :arch }.extend(ArchitectureListExtension) mach_data.map { |m| m.fetch :arch }.extend(ArchitectureListExtension)
end end