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

fix(build): Fix recently broken rpath setting #4618

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented Feb 2, 2025

As part of the recent big python wheel merge, compiler.cmake got changed in a subtle way in how it sets CMAKE_INSTALL_RPATH.

This broken iv for me on a Mac with dynamic libraries. Strangely (and I'm too lazy to chase down exactly why), oiiotool seems fine. So this was missed entirely by the CI, which never runs 'iv', since it's an interactive app. (Note to self: we should find some way to at least verify that it can execute as part of the testsuite.)

Anyway, I believe that this change adds the install lib area back to the path, and it does seem to repair my ability to run iv on my end.

As part of the big python wheel merge, compiler.cmake got changed in
a subtle way in how it sets CMAKE_INSTALL_RPATH.

This broken iv for me on a Mac with dynamic libraries. Strangely (and
I'm too lazy to chase down exactly why), oiiotool seems fine.  So this
was missed entirely by the CI, which never runs 'iv', since it's an
interactive app. (Note to self: we should find some way to at least
verify that it can execute as part of the testsuite.)

Anyway, I believe that this change adds the install lib area back to
the path, and it does seem to repair my ability to run iv on my end.

Signed-off-by: Larry Gritz <[email protected]>
@lgritz
Copy link
Collaborator Author

lgritz commented Feb 2, 2025

@zachlewis @JeanChristopheMorinPerso Opinions/review desired.

Comment on lines 701 to 703
set (CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}
${BASEPOINT}
${BASEPOINT}/${CMAKE_INSTALL_LIBDIR})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm tempted to suggest something like this.

Suggested change
set (CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}
${BASEPOINT}
${BASEPOINT}/${CMAKE_INSTALL_LIBDIR})
set (CMAKE_INSTALL_RPATH ${BASEPOINT} ${BASEPOINT}/${CMAKE_INSTALL_LIBDIR})
if (NOT SKBUILD)
set (CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR} ${CMAKE_INSTALL_RPATH})
endif()

This would avoid having the full path when building the wheels. The wheels should be as hermetic as possible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that makes sense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to add ${BASEPOINT}/../lib to the SKBUILD clause?
BASEPOINT is going to be something/bin, where the executable lives. ${BASEPOINT}/${CMAKE_INSTALL_LIBDIR} is therefore something/bin/lib which is useless, that's never where the libraries will be, right?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Umm, won't BASEPOINT be lib for the library? We technically need two different RPATH don't we? One for the executables and one for the libs no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RPATH is only used to find libraries, whether the thing needing the library is a binary or another library. So RPATH always needs to include the lib directory.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, what I meant was that the executable will have a different RPATH. The executable needs $ORIGIN/../lib while the library(ies) need $ORIGIN.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. But ${BASEPOINT}/../${CMAKE_INSTALL_LIBDIR} points to the same correct place in both cases, and seems to me less error-prone than trying to set rpath attributes separately for every library and binary target -- seems easy for somebody adding libraries or binaries later or modifying the cmake scripts to mess it up by not understanding this subtlety.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed an amendment to the PR that swaps the absolute path for what I was discussing above.

Signed-off-by: Larry Gritz <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants