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

Merged
merged 3 commits into from
Feb 6, 2025

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 <lg@larrygritz.com>
@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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OH, I didn't realize we were tweaking it in those spots as well. So it seems to me that the real problem is that the one in fancy_add_executable is ONLY happening for SKBUILD. When I build on my Mac from source, it's not getting this logic that includes the ../lib suffix, and that's why it's not finding the library.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So you have some special logic in libutil (for libOpenImageIO_Util), but not in libOpenImageIO (for the main libOpenImageIO)?

Can all these scattered special cases be removed and just use the one in compiler.cmake for everything?

Copy link
Collaborator

Choose a reason for hiding this comment

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

So you have some special logic in libutil (for libOpenImageIO_Util), but not in libOpenImageIO (for the main libOpenImageIO)?

Yep, to make sure libOpenImageIO_Util can find libOpenImageIO.
(libOpenImageIO doesn't link against libOpenImageIO_Util)
(Without doing this, the default cibuildwheel repair wheel step would flag libOpenImageIO_Util as missing dependencies (even though libOpenImageIO was right there in the same directory. So frustrating)

Can all these scattered special cases be removed and just use the one in compiler.cmake for everything?

I do believe so!!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, updated once again. Got rid of the special cases in fancy_add_executable and in libutil/CMakeLists.txt. Just the one place in compiler.cmake, and it has both the basepoint and basepoint/../lib, which I think covers all of our bases.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks Larry, this seems correct to me now.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
@lgritz
Copy link
Collaborator Author

lgritz commented Feb 4, 2025

Any further comments on this?

Signed-off-by: Larry Gritz <lg@larrygritz.com>
@lgritz lgritz merged commit 1b2ce1d into AcademySoftwareFoundation:main Feb 6, 2025
27 checks passed
@lgritz lgritz deleted the lg-rpath branch February 6, 2025 05:36
lgritz added a commit to lgritz/OpenImageIO that referenced this pull request Feb 6, 2025
…ion#4618)

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.

---------

Signed-off-by: Larry Gritz <lg@larrygritz.com>
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.

3 participants