[build2] Disabling rpath linking for all update operations
Matthew Krupcale
mkrupcale at matthewkrupcale.com
Mon Mar 25 02:19:15 UTC 2019
Hello,
When `updating` a project with exe or shared lib target which imports
shared, non-system libraries, these dependencies are added to the
target's rpath by default. This (correctly) does not happen for the
`install` operation, but I am wondering if it might be possible to
disable the addition of rpath to such targets during any update
operation.
There are two reasons for this request. First, Fedora does not
generally allow binaries to use rpath[1] at all, so it'd probably be
preferable to just disable it altogether. In practice, the current
design is not a problem in this regard since the installed binaries do
not use an rpath. Secondly, Fedora build specifications divide the
build process into several blocks, executed sequentially as %build,
%install, and %check. Thus, if we `b configure:` and perform `b
update:` during %build, the binaries are linked with rpath. Then, in
%install we perform `b install:`, and now the targets must be
re-linked without rpath. Finally, in %check we perform `b test:` and
again the targets are re-linked this time again with rpath. This is
obviously suboptimal because if I could disable rpath linking
altogether for all operations performed in these blocks, the
high-fidelity builds would have the same arguments and only need to
link once as opposed to three times[2].
I can understand why things are done this way, in that unless these
libraries are installed, there's no reason to expect them to be found
by default during testing or running. However, for the purposes of
these package build scripts, I can easily enough just add the library
paths to LD_LIBRARY_PATH as necessary and avoid re-linking, which is
relatively expensive. I haven't spent much time thinking about this,
but it seems like this might be as simple as hijacking the final
`bool` argument to `rpath_libraries` in
`cc::link_rule::perform_update`[3] and adding a user-configurable
variable to disable this for all operations.
Please let me know if this is something that could be done or if I
have missed something.
Best,
Matthew
[1] https://docs.fedoraproject.org/en-US/packaging-guidelines/#_beware_of_rpath
[2] https://copr-be.cloud.fedoraproject.org/results/mkrupcale/build2/fedora-30-x86_64/00873121-build2/build.log.gz
[3] https://git.build2.org/cgit/build2/tree/build2/cc/link-rule.cxx?id=47716dea2911cffb2ec50d6ad38abc43f9168118#n1973
More information about the users
mailing list