On Tue, Mar 08, 2016 at 11:05:33 -0500, Elizabeth Fischer wrote:
> 1. Spack compiler wrappers should always provide -fPIC, just as they always
> provide an Rpath currently. This would allow shared libraries to link to
> static libraries.
Well, it's not always spelled '-fPIC', but yes, this makes sense. Here's
CMake's "table" of -fPIC flags:
Modules/Compiler/GNU.cmake: set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
Modules/Compiler/NAG-Fortran.cmake:set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "-PIC")
Modules/Compiler/SCO.cmake: set(CMAKE_${lang}_COMPILE_OPTIONS_PIC -Kpic)
Modules/Compiler/SunPro-C.cmake:set(CMAKE_C_COMPILE_OPTIONS_PIC -KPIC)
Modules/Compiler/SunPro-CXX.cmake:set(CMAKE_CXX_COMPILE_OPTIONS_PIC -KPIC)
Modules/Compiler/SunPro-Fortran.cmake:set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "-KPIC")
Modules/Compiler/XL.cmake: set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-qpic")
> 2. We standardize on variants for ALL packages that control shared /
> non-shared generation:
> a) These variants get implemented in the core Spack code, so the
> package.py files don't have to provide variant() declarations.
> b) There should be a way to set these variants by default for ALL
> packages (eg: I'd set "+shared" as a general Spack configuration, and then
> all packages would be built with "+shared"). If this capability is not
> already in Spack, it would be provided as a follow-on to PR #120.
> b) I would suggest we follow existing convention used by some packages:
> "+shared" means build shared libraries, "+static" means build static
> libraries.
> ~shared" means don't build shared libraries, etc.
> c) If a package is incapable of building libraries in the ways
> requested, it can silently override Spack-wide defaults. But it should
> throw an error if the default was set per-package. (Eg: suppose Spack-wide
> defaults are set to "+shared" and mylib/package.py can't do shared
> libraries. Then I can silently just build static libraries. But if a user
> asks for mylib+shared, then I need to throw an error).
> d) If the user does nothing, Spack-wide defaults should be configured by
> default to "+shared+static".
I agree that it should always be spelled "+shared" and "+static" (and
not "+fpic" or "+dynamic"), but I don't know about spack providing it by
default without any mention in package.py. What does `py-six+shared`
even *mean*? What about `py-numpy+static`?
Also, with spack knowing about shared versus static, it means that spack
can drop LD_LIBRARY_PATH and rpath additions for packages which depend
on static libraries.
> 3. If we don't want to implement (2), what if we just keep it simple and
> make sure that all packages generate shared libraries by default?
> Rationale for this would be that static libraries are diminishing in use
> anyway, so why go to extra effort to keep a dying horse alive? Shared
> libraries have many advantages, but are harder to get right at link time
> and runtime. Spack solves a lot of these problems with its dependency
> management and Rpath support. Meanwhile, static libraries are increasingly
> untenable in today's world of deep and multiply-branching dependency DAGs.
Fine with me, but some supercomputers work better with static libraries
due to filesystem performance problems (mainly to do with 4000 nodes
trying to all read the same set of files at the same time) or lack of
shared library support at all.
> 4. The one shared library problem Spack does not yet solve is this...
> suppose I've built and installed a binary. Now I want to "pickle" it to a
> folder of my choosing, so it can run for three months on a supercomputer.
> I want the freedom to recompile code for the next three months while it's
> running. For this, I need a "pickle" procedure that works on a set of
> binaries. It would: (a) run ldd on those binaries to determine which
> shared libraries they load, (b) copy the binaries and all their .so
> dependencies into a folder, (c) build a lanucher bash script that sets
> LD_LIBRARY_PATH to the pickle folder and then launches the binaries.
CMake has something like this which it uses to find what libraries are
necessary when installing binaries for CPack. It's certainly something
that's possible, but probably better by just rewriting the rpaths to be
nothing so that LD_LIBRARY_PATH does all the work. I don't think a
pickled library should use libraries outside of the pickle by accident
(e.g., if you run it on the machine you happened to build it on).
--Ben