-
Notifications
You must be signed in to change notification settings - Fork 45
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 RPATH handling in TriBITS #126
Comments
I am going to slam this out since this would likely fix a problem for xSDKTrilinos on an OSX system (see trilinos/xSDKTrilinos#8). |
So much for slamming this out ... I am working on a slightly revised plan:
Above, I changed the original plan in #126 and decided not to set the default for This plan is to use the explicit full install path in RPATH. My exploration of CMake behaviors with RPATH is going well. I will attach my detailed notes when I am finished. When reading the documentation: https://cmake.org/Wiki/CMake_RPATH_handling I noticed that it recommends using
From: Bartlett, Roscoe A Hello Brad and Bill, I am finally getting to the bottom of RPATH issues with Trilinos (through TriBITS) and I am documenting the various install and distributions use cases and how to deal with RPATH for each of these. The nice feature of CMake is that it can replace RPATH for the final installation directory when you know what it is using CMAKE_INSTALL_RPATH. But you can only use that if you know what the final directory structure will look like. It occurred to me that it would be great if you could define a binary distribution executable based on CMake that could make this RPATH substitution on the final target machine. I guess you would have to know the max length of RPATH to make sure there is room for the substitution but otherwise, it seems that the functionality to implement is already in CMake and that could be used to create a binary installer that does this as well. Do any of the CMake CPack binary installer implementations support replacing RPATH in the shared libs and execs on the final install on the target machine through the binary distribution package? Thanks, -Ross |
I assume this issue encompasses adding TPL RPATHs to Trilinos libraries, for example |
Yes, this will resolve that issue. The new default will be the add the directories for all the external TPLs to RPATH. But you can do that right now by just configuring with:
That is a magical CMake option that I just learned about recently. The new TriBITS will make that the default. Would you be willing to review the documentation for RPATH once I push it to this GitHub repo master branch? That would be good before I snapshot TriBITS into Trilinos proper. |
Excellent, I've also been making that the default in my codes (actually, the whole "full RPATH" from Kitware's documentation). I wasn't sure TriBITS would respect it on the command line, but I'll try that in the meantime. I'd be happy to review, just let me know when it's pushed. |
From the perspective of the user who is just configuring using CMake, a project that uses TriBITS should behave just like any regular old CMake project, except perhaps with different defaults. If you set any raw CMake variable, then it should have the same effect as it would with any other CMake project. However, there are some known examples where this is not true that need to be fixed (e.g. #131). If you know of other examples like this, please let me know.
Thanks! I will add a comment here once I do the push to the TriBITS GitHub master branch. At that point the online documentation will be updated. Then you can test against Trilinos you want by TriBITS locally and using that version. |
Need to add unit tests for this yet.
This showed some surprising behavior of CMake and/or the Linux linker on this machine. Somehow it put in the path to libsimplecxx.so into RPATH when it should not have done so.
This failed on the Travis CI server that has no RPATH set at all.
When no RPATH is set on the Travis CI server, then there is no RPATH field at all. Hopefully this will fix the Travis CI build once and for all.
It seems that the `date` command does not work on OSX like it does on Linux. This is important to know. I found this out while working TriBITSPub#126 (but this change is not directly releated to TriBITSPub#126).
With this change that test for CMAKE_INSTALL_RPATH now passes on OSX!
This was done as part of TriBITSPub#126 but is not directly related to that story.
This changes the default behavior of TriBITS projects to set RPATH on install so that everything works right out of the install directory without having to set any extra env vars. Several things done as part of this: * Added SimpleTpl to help teste RPATH. (This will also come in handy for doing more TPL testing.) * Add installable exec to SimpleCxx package to help test RPATH. * Added documentation for users and developers (see documenation files). * Added detailed automated tests to test the different use cases described in the documentation. I manually tested this locally on Linux, Mac OSX (gaia) and on Travis CI (by pushing the branch fix-rpath-126 to the main TriBITS GitHub repo). I think this is pretty solid. See #126 for more motivation and details.
This was done as part of #126 but is not directly related to that story.
This changes the default behavior of TriBITS projects to set RPATH on install so that everything works right out of the install directory without having to set any extra env vars. Several things done as part of this: * Added SimpleTpl to help teste RPATH. (This will also come in handy for doing more TPL testing.) * Add installable exec to SimpleCxx package to help test RPATH. * Added documentation for users and developers (see documenation files). * Added detailed automated tests to test the different use cases described in the documentation. I manually tested this locally on Linux, Mac OSX (gaia) and on Travis CI (by pushing the branch fix-rpath-126 to the main TriBITS GitHub repo). I think this is pretty solid. See #126 for more motivation and details.
This was done as part of #126 but is not directly related to that story.
I just pushed the commit eb300ad to the 'master' branch so this is ready to review. The updated documentation on RPATH handling can be seen here:
I wrote some pretty good automated tests for these different RPATH use cases and ran them on OSX and Linux as shown here (see "RPATH" tests):
@ibaned and @bradking, if you have some time can you please take a few minutes and look over the above documentation and then provide any comments in this Issue ticket? Also, if you want to test against Trilinos, just clone TriBITS under Trilinos and then configure with:
Thanks! |
Thanks @bartlettroscoe !
The content makes sense and I'm impressed that testing actually checks the |
I fixed the typos things that @ibaned found and made the other changes he suggested in #126. I also did a full read over and fixed a few more typos and improved a few things. Build/Test Cases Summary Enabled Packages: Enabled all Packages 0) MPI_DEBUG => passed: passed=222,notpassed=0 (0.33 min) 1) SERIAL_RELEASE => passed: passed=222,notpassed=0 (0.31 min)
@bartlettroscoe I've just finished reading through the documentation. It looks fine after the fixup commit. |
Thanks @bradking. I am now closing at complete. No more RPATH problems with shared libraries :-) |
Brings in: * Fixed default RPATH (see TriBITSPub/TriBITS#126) * Updated gitdist --dist-repos behavior (see TriBITSPub/TriBITS#151). For this last change, one should update their install of the gitdist script. If you don't, then running gitdist will process the base Trilinos git repo twice (which is typically harmless). There are other small changes as well but the above ones were the motivation for updating the TriBITS snapshot.
These tests are not set up to work correctly on cygwin (and RPATH likely will not work on Windows under cygwin).
Next Action Status: ???
Relates To: trilinos/Trilinos#91
Description:
Currently, TriBITS sets the
INSTALL_RPATH
property on libraries defined withTRIBITS_ADD_LIBRARY()
using:This results in having the RPATH for libraries swapped out in install for libraries.
However, executables installed with
TRIBITS_ADD_EXECUTABLE( ... INSTALLABLE ...)
do not currently have this property set. This means that executables that get installed do not work correctly once installed. This problem was not found in the early days of TriBITS because Trilinos installed only libraries and not executables.Also, by default, there is no RPATH set on install for TPL libraries that are not built by the CMake project. That means that you have to set
LD_LIBRARY_PATH
in the env in order to run these executables. (This is a big problem for CASL VERA, for example.)This story is to resolve the handling of RPATH as follows:
${PROJECT_NAME}_SET_INSTALL_RPATH
and allow projects to set the default with${PROJECT_NAME}_SET_INSTALL_RPATH_DEFAULT
but make the defaultTRUE
.${PROJECT_NAME}_SET_INSTALL_RPATH==TRUE
, then set the propertyINSTALL_RPATH
on all installable libraries defined withTRIBITS_ADD_LIBRARY()
and executables defined withTRIBITS_ADD_EXECUTABLE( ... INSTALLABLE ...)
.${PROJECT_NAME}_SET_INSTALL_RPATH==TRUE
, then set the propertyCMAKE_INSTALL_RPATH_USE_LINK_PATH
toTRUE
by default. (This will make it so that CASL VERA no longer needs to set LD_LIBRARY_PATH inload_env.sh
.)Together with setting the CMake 3.3 policy (see trilinos/Trilinos#91), then these changes should fix all of the issues with RPATH that people are having with Trilinos and CASL VERA.
Tasks:
${PROJECT_NAME}_SET_INSTALL_RPATH
in the TriBITS Developers Guide and point to the TriBITS Build Reference for a discussion of RPATH handling.The text was updated successfully, but these errors were encountered: