Skip to content

abseil: make bottle relocatable#75450

Closed
carlocab wants to merge 1 commit intoHomebrew:masterfrom
carlocab:abs-relocate
Closed

abseil: make bottle relocatable#75450
carlocab wants to merge 1 commit intoHomebrew:masterfrom
carlocab:abs-relocate

Conversation

@carlocab
Copy link
Copy Markdown
Member

See 52203dd and 068fcb9.


  • Have you followed the guidelines for contributing?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing brew install <formula>)?

@carlocab
Copy link
Copy Markdown
Member Author

I think this is the right way to do this for Linux. @Homebrew/linux, can one of you have a look?

See also #75449.

@carlocab
Copy link
Copy Markdown
Member Author

From the bottle json files:

❯ jq '.[].bottle.cellar' <abseil--20210324.0.*.bottle.json
"any"
"any"
"any"
"any"

@danielnachun
Copy link
Copy Markdown
Contributor

Shouldn't the RPATH be rewritten by install_name_tool on macOS? My understanding of binary relocation is that the RPATH can be updated using install_name_tool on macOS and patchelf.rb on Linux. The harder problem is when there are strings in the .rodata section of an ELF (or the equivalent location in a Mach-O on macOS), and that's why I want to implement Homebrew/brew#10846 to fix that.

@carlocab
Copy link
Copy Markdown
Member Author

carlocab commented Apr 19, 2021

I don't think we do any RPATH re-writing on macOS, so we rely on the build system to specify this correctly. When it doesn't, we can give it hints, but it seems we've given a suboptimal one here.

Do you do RPATH rewriting on Linux?

Homebrew/brew#10846 would be good to have, but I think that wherever we can get relocation for free, we should take it.

@danielnachun
Copy link
Copy Markdown
Contributor

I don't think we do any RPATH re-writing on macOS, so we rely on the build system to specify this correctly. When it doesn't, we can give it hints, but it seems we've given a suboptimal one here.

It looks like we sort of do this by rewriting the lib paths in https://github.com/Homebrew/brew/blob/a654730accaaadff4d28ed8678b88baed693d621/Library/Homebrew/extend/os/mac/keg_relocate.rb#L42, and then try to remove the RPATHs afterward if the lib paths no longer use them. In theory I think we should fully rewrite the RPATH on macOS when pouring bottles and I will have to investigate this as part of Homebrew/brew#10846, but that can't be changed now.

Do you do RPATH rewriting on Linux?

That is what patchelf.rb (and formerly the patchelf formula) is used for.

Homebrew/brew#10846 would be good to have, but I think that wherever we can get relocation for free, we should take it.

100% agreed on this!

@danielnachun
Copy link
Copy Markdown
Contributor

My guess is that this change will have no affect on Linux either way because the RPATHs are ignored when determining a bottle cellar. I can test this locally if you want me to just to be sure.

@carlocab
Copy link
Copy Markdown
Member Author

Actually it looks like this is already relocatable on Linux:

https://github.com/Homebrew/linuxbrew-core/blob/008365c9444c63af980f2302be56f2f401536bdc/Formula/abseil.rb

I'm just more concerned about whether the specific rpath argument here might break anything. I suppose I could always just set it to opt_lib, as it is in the current version of the formula on Linux, but we don't want that on macOS as that breaks relocatability.

Knowing the correct thing to pass to CMAKE_INSTALL_RPATH might be useful for other formulae though.

@danielnachun
Copy link
Copy Markdown
Contributor

Actually it looks like this is already relocatable on Linux:

https://github.com/Homebrew/linuxbrew-core/blob/008365c9444c63af980f2302be56f2f401536bdc/Formula/abseil.rb

I'm just more concerned about whether the specific rpath argument here might break anything. I suppose I could always just set it to opt_lib, as it is in the current version of the formula on Linux, but we don't want that on macOS as that breaks relocatability.

I would say we should take the safe route in that case and use opt_lib on Linux, since it will be ignored when determining the cellar, and rewritten as needed if the user has a non-standard install prefix.

Knowing the correct thing to pass to CMAKE_INSTALL_RPATH might be useful for other formulae though.

Yes, that could be useful if it improves relocatability on macOS. It's possible that as part of Homebrew/brew#10846 we will eventually not need to set the RPATH like this, but until then I think we should use this approach to eliminate "trivial" cases where the only reason a binary can't be relocated is because of the RPATH.

@carlocab
Copy link
Copy Markdown
Member Author

Done.

@carlocab
Copy link
Copy Markdown
Member Author

Needs the next brew release tag.

@carlocab carlocab added ready to merge PR can be merged once CI is green and removed do not merge labels Apr 25, 2021
See 52203dd and 068fcb9.

Also, add head spec, as this is the version encouraged for use upstream.
carlocab added a commit to carlocab/homebrew-core that referenced this pull request Apr 25, 2021
Setting RPATH to `lib` breaks relocatability on macOS.

See Homebrew#75450 and Homebrew#75449.
@BrewTestBot
Copy link
Copy Markdown
Contributor

🤖 A scheduled task has triggered a merge.

BrewTestBot pushed a commit that referenced this pull request Apr 26, 2021
Setting RPATH to `lib` breaks relocatability on macOS.

See #75450 and #75449.

Closes #75457.

Signed-off-by: Sean Molenaar <1484494+SMillerDev@users.noreply.github.com>
Signed-off-by: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com>
@carlocab carlocab deleted the abs-relocate branch April 30, 2021 17:12
@github-actions github-actions bot added the outdated PR was locked due to age label May 31, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated PR was locked due to age ready to merge PR can be merged once CI is green

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants