-
Notifications
You must be signed in to change notification settings - Fork 697
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
Relocatable packages #2255
Relocatable packages #2255
Conversation
One (major) flaw in my current implementation is that in handles libraries with
Problem 2. could be solved by wrapper schell scripts, such as the |
Thanks, will review soon. Can you please use rebase instead of merge to remove spurious merge commits? |
It seems I have already totally messed up my git history with an incorrect rebase earlier.... as you can see, some messages appear double. Should I just delete my current github repo? and push the changes as one big patch agains master? |
Try rebasing against master first. You can combine/remove/reorder patches with I'd prefer to have several smaller patches instead of a single giant patch, e.g. whitespace changes should be separate from code changes. |
Before, RPATH handling was left to GHC. But this causes problems when a package contains both a Library section and an Executable section which depends on the library, and the executable is dynamically linked. See e.g. haskell#1568
These operating systems do support RPath, but they are untested with regards to Cabal's RPATH calculation, so we will leave RPATH handling on those operating systems to GHC.
Is this rebased and ready to be merged? |
It is properly rebased. Whether it is ready to be merged depends on your thoughts regarding my first comment on the problem of data-files in libraries. |
@christiaanb does it make the data files situation worse for users who don't use --enable-relocatable? If not I'm fine with merging it. |
@tibbe Users who do not use |
|
Somehow the new RPATH handling breaks test suites when building with |
I should mention, this RPATH/test suite bug only appears using GHC 7.8. EDIT: Actually, this probably isn't true, sorry! |
Indeed, I incorrectly assumed we only needed to setup (DY)LD_LIBRARY_PATH for relocatable packages. I've created a fix at: #2289 |
@christiaanb I'm working if it's possible to disable this behavior? I was hoping We're having problems in Nix due to this behavior for two reasons:
So in Nix itself, we use the following ugly workaround NixOS/nixpkgs@19e2e72, but I'm hoping to also fix Stack+Nix. |
See #4183 for further discussion. |
This patch partially implements Relocatable Packages as discussed in #462. This entails:
RPATH
included in libraries and executables are$ORIGIN
(@loader_path
on OS X) relative.data-files
are located relative to the executable based onSystem.Environment.getExecutablePath
.package.conf
files now contain directory specifications that are${pkgroot}
relative.It enables the installation of packages that are prefix-relative with regards to dependencies in the same package database. For example, assume a relocatable ghc installation (e.g. http://ghcformacosx.github.io/ for OS X). You can add packages to this relocatable ghc installation by:
cabal install --global --enable-relocatable <package>
. You can then make a new tar-ball of this installation and deploy it on someone else's machine, and the added libraries and executable will work out-of-the-box.Another example is the
.cabal-sandbox
directory created by cabal sandboxes. When you do acabal install --dependencies-only --enable-relocatable
you will get a.cabal-sandbox
directory which is relocatable anywhere on the developer machine. That is, all libraries and executables in the.cabal-sandbox
directory are prefix-relative amongst eachother, however, they will contain hardcoded paths to the dependencies in the global package database (e.g. thebase
package). That is what is meant by: prefix-relative with regards to dependencies in the same package database.data-files
are located based on the location returned bySystem.Environment.getExecutablePath
. I have confirmed that this works on my OS X and Linux machines. The current implementation of relocatable packages will not work on operating systems whereSystem.Environment.getExecutablePath
does not function correctly.This patch also puts the handling of
RPATH
in the hands of Cabal on those systems on which the patch has been tested (OS X and Linux). When--enable-relocatable
is specified, theRPATH
s will be prefix-relative. Coincidentally, this also fixes #1568 for the tested platforms, even when--disable-relocatable
.This patch has been tested on OS X 10.8, and Linux (CentOS 6.4), using GHC 7.8.3. Relocatable packages are only supported on those platforms, and installation will fail (Cabal will inform the user) if
--enable-relocatable
is specified for an unsupported platform.As said, this partially implements #462. To fully implement that issue, we would additionally need a
deploy
command. Which you would call like:cabal deploy --deploy-dir=<deploy_dir> <package>
which would collect the binaries, libraries of the dependencies (in case of a dynamically linked executable), and data-files, and turn them into a relocatable bundle at the specified directory.