-
Notifications
You must be signed in to change notification settings - Fork 235
ENV: Add formula.lib to RPATH for unlinked kegs #449
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it definitely fixes the problem, both for superenv and stdenv (tested that with mozjpeg
). Thanks a bunch Shaun 👍
Left some points for clarification.
end | ||
|
||
# Set the search path for header files. | ||
prepend_path "CPATH", HOMEBREW_PREFIX/"include" | ||
# Set the dynamic linker and library search path. | ||
append "LDFLAGS", "-Wl,--dynamic-linker=#{HOMEBREW_PREFIX}/lib/ld.so -Wl,-rpath,#{HOMEBREW_PREFIX}/lib" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to https://github.com/numpy/numpy/pull/8110/files the use of a comma after -rpath is a Mac-specific thing, but this is inside an if OS.linux?
block.
I'm confused; it doesn't look like every stdenv-built executable had a bad RPATH as a result, but I find it hard to believe that we didn't notice this until now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented below.
@@ -311,6 +311,10 @@ class Cmd | |||
paths.map! { |path| prefix + path } | |||
end | |||
|
|||
def rpath_flags(prefix, paths) | |||
paths.uniq.map { |path| prefix + path } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not remove non-directories from the list like path_flags
does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! A comment is justified here. The problem is that the formula.lib
directory does not yet exist when the formula is being compiled and this function is called, so formula.lib
gets pruned from the list of directories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that non-exsting lib
directories of dependencies are already pruned from this list earlier: https://github.com/Linuxbrew/brew/blob/master/Library/Homebrew/extend/ENV/super.rb#L193
Pruning again here was a bit redundant.
prepend_path "LD_RUN_PATH", HOMEBREW_PREFIX/"lib" | ||
unless formula.nil? | ||
prepend "LDFLAGS", "-Wl,-rpath=#{formula.lib}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear, the issue affects only keg-only formulae (because their libraries aren't symlinked into $HOMEBREW_PREFIX/lib
), but we're adding the lib directory for all formulae, right?
I can think of one possible consequence of that, which is that if you have two conflicting formulae that both install a shared library and you force one of them with brew link --overwrite
, the library from this formula will still be preferred even if it's overwritten. I'm not sure if that's a good thing or a bad thing; I'm leaning towards good thing, but some users might find it surprising.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, and yes that's a change in behaviour, but I agree a good thing.
Comma after No bottles until now had This fixes one other small issue. If you had multiple versions of |
Unlinked kegs, such as versioned kegs, need their lib directory in their RPATH.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanations Shaun.
Merged! |
Unlinked kegs, such as versioned kegs, need their lib directory in their RPATH.
See
openssl@1.1
as an example.