Skip to content

Use binary patching to improve relocatability of bottles #10846

@danielnachun

Description

@danielnachun

Provide a detailed description of the proposed feature

Currently we have some bottles which are non-relocatable – they can only be used if they are installed in the default cellar locations we use in CI. This is because these bottles contain binaries with strings which reference the cellar.

I propose we make all of our binaries relocatable by implementing an approach used by Anaconda: https://docs.conda.io/projects/conda-build/en/latest/resources/make-relocatable.html. This solution would require two changes to Homebrew:

  1. Build bottles with a long placeholder prefix (Anaconda uses 255 characters).
  2. During keg relocation, if a bottle does not have a relocatable cellar, use binary patching to replace the placeholder prefix with the user’s cellar, with null padding to make it the same length as the placeholder.

As long as the user does not have an install prefix longer than the placeholder prefix, this should make all binaries we build relocatable. Note that it will require rebuilding all bottles with non-relocatable cellars (about 1000 formulae).

On macOS ARM64, Anaconda has to codesign the patched binaries, which makes it likely we will need to the same.

For reference, the binary relocation in Anaconda is implemented here: https://github.com/conda/conda/blob/6fc320aa625939db271c2227d935e4588d277b61/conda/core/portability.py.

What is the motivation for the feature?

Using a non-default cellar is probably the most common reason for a user to still have to build from source. Making all our bottles relocatable would resolve this. It would also make a lot of other features easier to implement like installing bottles using the JSON API.

How will the feature be relevant to at least 90% of Homebrew users?

It would greatly improve the experience for all users who use non-default cellars. We don’t officially support building from source, so we can only support non-default cellars on a best effort basis. In addition, as mentioned above it would make it easier for implement other features that will benefit the vast majority of users.

What alternatives to the feature have been considered?

The current alternative is to build these formulae from source.

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionInput solicited from othersenhancementin progressMaintainers are working on thisoutdatedPR was locked due to age

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions