Added a sub-command to show if packages are relocatable#9199
Added a sub-command to show if packages are relocatable#9199gartung merged 9 commits intospack:developfrom
Conversation
|
This PR still needs work to make the sub-command portable. Anyhow I wanted to submit it early so that people could start to play with it, and check if their packages of interest are or are not 100% relocatable. For instance, a worrying thing is: $ spack buildcache preview mpich
Relocatable nodes
--------------------------------
[-] [email protected]%[email protected] device=ch3 +hydra netmod=tcp +pmi+romio~verbs arch=linux-ubuntu18.04-x86_64 I suspect most of the times Spack's root directory (or any subfolder) is present in the data segment just to be used in help strings, but I can't think of a reliable way to ensure that the package remains relocatable. |
|
@alalazo Tk is the only package that I know of the uses a compiled in path to locate its config file. Other strings can probably be safely ignored. This is why I added the option (-a) to create the buildcache anyway. |
tgamblin
left a comment
There was a problem hiding this comment.
@alalazo: this looks great to me but coverage is only 35%.
Could we make a test that builds trivial relocatable and non-relocatable binaries? I think this would be the first spack test to actually compile something, but it seems worth it to me. We could skip the test if clang or gcc is unavailable via spack compilers. What do you think?
Definitely worth to come up with some tests. Also, pointing this out to be sure you saw it: this PR currently works only for spack/lib/spack/spack/relocate.py Lines 497 to 499 in 5ac4665 |
f726b45 to
45f2065
Compare
|
To proceed with this PR I had to write something that skips tests if I don't find certain executables: spack/lib/spack/spack/test/relocate.py Lines 38 to 50 in 45f2065 It's used like this: spack/lib/spack/spack/test/relocate.py Lines 81 to 89 in 45f2065 I was wondering if we should move this up the test folder, maybe in |
d52c5c6 to
af0380e
Compare
|
@tgamblin I think I addressed your comments here, let me know if other changes are necessary. |
|
ping |
af0380e to
c070293
Compare
|
@tgamblin Rebased and ready for a further review. |
We recently started using buildcache. I see that common packages like gcc, python, sqlite are not relocatable if we just check with |
As far as I understand packages that contain strings referring to the installation path can't be insured to be relocatable. If you have
Do you mean override the check so that it passes the query on relocatability, while with That said, my understanding of this subject is quite naive at the moment. There are a couple of projects, like exodus, that I want to have a look at to see how they approach the issue. Also: if anybody has good references on the subject of relocating binaries, feel free to post them here (I would be glad to read them). |
c070293 to
97cc493
Compare
gartung
left a comment
There was a problem hiding this comment.
This looks OK to me. You will have to rebase on develop once all of the other changes to buildcache.py and relocate.py go in.
97cc493 to
91c3e1f
Compare
|
I got around to testing this as an alternative to --allow-root. It tries to run on all files under /usr/ for external packages. The mime type misidentifies files as ELF that are not. ==> 'file' '-b' '--mime-type' '/build/work/spack-data/install/linux-rhel7-x86_64/gcc-7.3.0/root-6.12.06-i7e2sbt2pstdfhfm7tzgwf4z6hnnguke/etc/allDict.cxx.pch' |
Test coverage is now substantially improved as requested
| assert spack.relocate.file_is_relocatable(executable) is is_relocatable | ||
|
|
||
|
|
||
| @pytest.mark.skipif( |
There was a problem hiding this comment.
@gartung Can this skip_if be removed now that you added an implementation for darwin?
…unctions introduced in spack#9199 Instead of replacing rpaths with placeholder and then checking strings, make use of the functions relocate.is_recocatable and relocate.is_file_relocatable to decide if a package needs the allow-root option. This fixes a problem where the placeholder path was not in the first rpath entry. This was seen in c++ libraries and binaries because the compiler was outside the spack install base path and always appears first in the rpath. Instead of checking the first rpath entry, all rpaths have the placeholder path and the old install path (if it exists) replaced with the new install path. The second commit changes the check for old install path strings by using the install prefix instead of the install root.
…unctions introduced in spack#9199 Instead of replacing rpaths with placeholder and then checking strings, make use of the functions relocate.is_recocatable and relocate.is_file_relocatable to decide if a package needs the allow-root option. This fixes a problem where the placeholder path was not in the first rpath entry. This was seen in c++ libraries and binaries because the compiler was outside the spack install base path and always appears first in the rpath. Instead of checking the first rpath entry, all rpaths have the placeholder path and the old install path (if it exists) replaced with the new install path.
…rpath entry. * Rework of buildcache creation and install prefix checking using the functions introduced in #9199 Instead of replacing rpaths with placeholder and then checking strings, make use of the functions relocate.is_recocatable and relocate.is_file_relocatable to decide if a package needs the allow-root option. This fixes a problem where the placeholder path was not in the first rpath entry. This was seen in c++ libraries and binaries because the compiler was outside the spack install base path and always appears first in the rpath. Instead of checking the first rpath entry, all rpaths have the placeholder path and the old install path (if it exists) replaced with the new install path. * flake8
closes #9188
This implements the idea discussed in the ticket above. From user perspective a sample output is:
meaning that in this DAG
hdf5might not be relocatable, whilelibszipandzlibsurely are.