Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support idempotent addition of RPATHs and NEEDEDs (i.e. remove duplicates) #497

Open
de11n opened this issue May 15, 2023 · 0 comments
Open

Comments

@de11n
Copy link

de11n commented May 15, 2023

patchelf --add-needed libX Y && patchelf --add-needed libX Y will add libX twice. The same goes for patchelf --add-rpath.

It would be very handy if there were a way to enable patchelf to only make additions when the requested NEEDED/RPATH is not already present.

Ordering matters for both of these, so this feature would likely only come into effect for duplicates that would otherwise have a lower precedence than an existing entry.

This feature could be added numerous ways:

patchelf --add-needed libX --add-rpath /path/y --uniq-needed --uniq-rpaths Z

This would be strictly more general than merely making --add-needed/--add-rpath idempotent, but it would achieve the goal.

(Indeed, --shrink-rpath probably has this effect, but it cannot be used when the RPATH contains directories that don't exist yet.)

A more granular option could be:

patchelf --add-needed-idempotent libX Z

Obviously this functionality can be achieved with a few calls to patchelf --print-needed/patchelf --print-rpath along with some tr and awk. But that's also true of many features (e.g. --add-rpath could be implemented in terms of --print-rpath and --set-rpath) and I think it's probably the semantics people mean when they say --add-needed etc. It's also just much more convenient for patchelf to do it, while also more efficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant