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

[WIP] Document/Examples on Relocatable Software #5

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a66b01c
Initial notes on Relocatable Packages
drbenmorgan Jun 3, 2015
65b01f2
Improve layout and sections
drbenmorgan Jun 10, 2015
ee00c72
Update info for Bash and Go
drbenmorgan Jun 12, 2015
700e684
Create folder for all relocatable notes/code
drbenmorgan Apr 19, 2016
8300e49
Rename doc file so GitHub renders it
drbenmorgan Apr 19, 2016
cf916ef
Update and clarify sections
drbenmorgan Apr 19, 2016
8437d68
Add project with demo code
drbenmorgan Apr 25, 2016
8e769e7
Add placeholder section for third-party patching
drbenmorgan Apr 27, 2016
692c46f
Add note on the behaviour of $ORIGIN
drbenmorgan Apr 27, 2016
5d0b6c2
Add links to ABI/API issues and tools
drbenmorgan Apr 28, 2016
3312a11
Organise project in line with docs
drbenmorgan May 1, 2016
4740a0e
update project name to match main docs
drbenmorgan May 1, 2016
77e9bfb
Move binreloc frontend to dedicated iface
drbenmorgan May 1, 2016
01a4802
Reorganise for clarity
drbenmorgan May 1, 2016
39d700e
Rename project to HSFReloc
drbenmorgan May 1, 2016
f753602
Add missing text in Ruby section
drbenmorgan May 2, 2016
a9781ae
Link to scripting language examples
drbenmorgan May 2, 2016
491eb32
Start section on dynamic library location
drbenmorgan May 3, 2016
a020929
How to get info from the dynamic linker/loader
drbenmorgan May 3, 2016
d8a2fa8
Some minor updates and additions
drbenmorgan Nov 3, 2016
5d93744
Add section on interpreter paths
drbenmorgan Nov 4, 2016
bf83cca
Add section to cover packaging issues
drbenmorgan Nov 4, 2016
e9b5463
Basic spring clean to get started again
drbenmorgan Mar 21, 2018
541af2e
Update README to include RelocatableSoftware
drbenmorgan May 18, 2018
8d38239
Initial binreloc modernization
drbenmorgan May 18, 2018
40bf54a
Isolate binreloc code
drbenmorgan May 18, 2018
3327022
Generate binreloc code/INTERFACE target on demand
drbenmorgan May 18, 2018
71ab5f0
Add example of plugin loading
drbenmorgan May 22, 2018
46d29a7
Move development-related stuff to subdir
drbenmorgan May 22, 2018
c8fa96c
Add links to subprojects
drbenmorgan May 22, 2018
654277c
Merge self-location docs to "HSFReloc"
drbenmorgan May 22, 2018
d1ec90b
Move "HSFReloc" to "SLPackage"
drbenmorgan May 22, 2018
7dee8f9
Additional HSFReloc->SLPackage names
drbenmorgan May 22, 2018
c8bb6d3
Minor grammar/clarity updates
drbenmorgan Jun 11, 2018
3afe905
Move script -> programs
drbenmorgan Jun 11, 2018
cc6d65c
Additional tidying/reorganisation
drbenmorgan Jun 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ they can be used to install a basic HEP software stack.
This project provides some notes and example C/C++ code for packaging software
that uses/requires specific CPU instruction sets such as SSE, AVX.

## [Relocatable Software](RelocatableSoftware)
This project provides some notes and example code for developing
packages that are _relocatable_. That is, the collection of installed
files can be moved from their installed location to anywhere else on
the system and still function without any system or user configuration
changes.

# Contributing
Questions and comments on any of the projects are welcome, simply [raise an issue](https://github.com/HSF/packaging/issues).
If you want to actively contribute to the working group, please contact us through our [HSF Page](http://hepsoftwarefoundation.org/activities/packaging.html).
Expand Down
65 changes: 65 additions & 0 deletions RelocatableSoftware/DevTools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Relocatability and Development Tools
====================================
This looks at relocatability of/in files that a package may install for
use by other packages that use, and thus develop against, it. It therefore
focuses on the HEP case of C/C++/Fortran libraries that use, and are used by,
other libraries.

CMake
=====
To support use of a Project by a CMake based client project, scripts for
use with CMake's [`find_package`](http://www.cmake.org/cmake/help/v3.2/command/find_package.html) command in "config"
mode should be provided. A `FindPACKAGENAME.cmake` should *not* be implemented, including the use of CMake commands
like `find_path`, `find_library` as these are intended to locate packages not supplying any CMake support files. CMake
"ProjectConfig.cmake" files are installed alongside the project and can self-locate the project's headers/libraries/executables
without having to find anything.

If the Project itself is built with CMake, "ProjectConfig.cmake" files are very easy to create
via the [`CMakePackageConfigHelpers`](http://www.cmake.org/cmake/help/v3.2/module/CMakePackageConfigHelpers.html) module
and the [`install`](http://www.cmake.org/cmake/help/v3.2/command/install.html) command's `EXPORT` signature.
These make use of CMake's [imported targets](http://www.cmake.org/cmake/help/v3.2/command/add_library.html?#imported-libraries) and the ability for CMake scripts to self-locate themselves (e.g. [`CMAKE_CURRENT_LIST_FILE`](https://cmake.org/cmake/help/v3.2/variable/CMAKE_CURRENT_LIST_FILE.html)to allow the resultant "ProjectConfig.cmake" file(s)
to be completely relocatable.

Creating and managing these files can become more complicated with Projects that depend on others.
Generally, this can be handled with

- Consistent use of imported targets to avoid hard-coding paths to dependent libraries/headers
- Minimizing public link dependencies, as these must be refound, even if the client does not use the dependency directly
- "ProjectConfig.cmake" files should call `find_package` for any compile or link time dependencies. This
refinds any dependencies and hence creates the required imported targets. How the dependencies are located
by `find_package` should be left to the configuration management system, which can point CMake to
the right locations using the standard CMake command line/environment variables such as [`CMAKE_PREFIX_PATH`](http://www.cmake.org/cmake/help/v3.2/variable/CMAKE_PREFIX_PATH.html)
- This also works for build wrapper systems (e.g. spack's env setup, Homebrew's sh/superenv or Nix environments for example).

However, this is not necessarily a complete solution.

Pkg-Config
==========
Scripts for the [pkg-config](http://www.freedesktop.org/wiki/Software/pkg-config/)
tool can also be made relocatable by using the builtin `pcfiledir` variable.
This expands to the directory holding the `.pc` file, and so for an
example project Foo this could be written as

```
prefix=${pcfiledir}/../..
libdir=${prefix}/lib
includedir=${prefix}/include

Name: Foo
Libs: -L${libdir} -lfoo
Cflags: -I${includedir}
```

Here the relative path from `pcfiledir` to the prefix and the relative
`lib` and `include` paths have been hand written for clarity, but can easily
be created from expansion variables set by the buildsystem of Foo.

Pkg-config can also handled dependencies, and the `PKG_CONFIG_PATH` (and possibly `PKG_CONFIG_LIBDIR`)
environment variable should be used to correctly resolves paths to these.
As with CMake, this should be handled by the configuration management or
build wrapper.

Other tools
===========
**TODO**: Autotools (though probably via `pkg-config`), SCons, others, Python packaging.

Loading