Skip to content

Commit

Permalink
os/mac/{keg,mach}: fix cache invalidation
Browse files Browse the repository at this point in the history
We were rewriting dylib IDs and install names using `MachO::Tools`,
which doesn't update the state of the file in memory. This leads to
those changes being undone when we call `change_rpath`.

We fix this by making sure the state of the file in memory always
matches the state of file on disk.

Closes Homebrew#12832.
  • Loading branch information
carlocab committed Feb 11, 2022
1 parent 1aa0897 commit 8f51c35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Library/Homebrew/os/mac/keg.rb
Expand Up @@ -7,7 +7,7 @@ def change_dylib_id(id, file)

@require_relocation = true
odebug "Changing dylib ID of #{file}\n from #{file.dylib_id}\n to #{id}"
MachO::Tools.change_dylib_id(file, id, strict: false)
file.change_dylib_id(id, strict: false)
apply_ad_hoc_signature(file)
rescue MachO::MachOError
onoe <<~EOS
Expand All @@ -23,7 +23,7 @@ def change_install_name(old, new, file)

@require_relocation = true
odebug "Changing install name in #{file}\n from #{old}\n to #{new}"
MachO::Tools.change_install_name(file, old, new, strict: false)
file.change_install_name(old, new, strict: false)
apply_ad_hoc_signature(file)
rescue MachO::MachOError
onoe <<~EOS
Expand Down
10 changes: 10 additions & 0 deletions Library/Homebrew/os/mac/mach.rb
Expand Up @@ -64,6 +64,16 @@ def delete_rpath(rpath, **options)
macho.write!
end

def change_dylib_id(id, **options)
macho.change_dylib_id(id, options)
macho.write!
end

def change_install_name(old, new, **options)
macho.change_install_name(old, new, options)
macho.write!
end

def dynamically_linked_libraries(except: :none)
lcs = macho.dylib_load_commands.reject { |lc| lc.type == except }

Expand Down

0 comments on commit 8f51c35

Please sign in to comment.