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

Add foreign-library to LD_LIBRARY_PATH during cabal exec #4049

Closed
abooij opened this issue Oct 28, 2016 · 4 comments
Closed

Add foreign-library to LD_LIBRARY_PATH during cabal exec #4049

abooij opened this issue Oct 28, 2016 · 4 comments
Assignees
Milestone

Comments

@abooij
Copy link
Contributor

abooij commented Oct 28, 2016

Thanks for the work on the new foreign-library section. I have started using it for one of my projects, and it seems to work!

My use case is to reimplement a C library's ABI, and run existing binaries written in C against the Haskell version. At development time, this means building my haskell code as a foreign library, adding the relevant directory to LD_LIBRARY_PATH, and then running the existing binaries.

It would be convenient if cabal could add the haskell foreign library to LD_LIBRARY_PATH. I suppose the cabal exec command could be the right place to do this. So instead of

$ cabal build
$ LD_LIBRARY_PATH=dist/build/myproject/ /usr/bin/existing-binary

one would instead simply:

$ cabal exec /usr/bin/existing-binary
@ezyang
Copy link
Contributor

ezyang commented Oct 28, 2016

The motivation seems reasonable. The big question, however, is WHICH paths should get added to LD_LIBRARY_PATH? After all, a foreign library could itself depend on (1) dynamic Haskell libraries that were installed user-wide, or (2) a different foreign library. All of these paths need to be added to LD_LIBRARY_PATH for things to "work" (although I guess we do bake in RPATHs to make sure that things can be found without LD_LIBRARY_PATH).

cabal run, as opposed to cabal exec, DOES twiddle the LD_LIBRARY_PATH, but because it's associated with an actual Haskell package, we know exactly what things need to be added. In your suggested cabal exec, this is not known; is the suggestion then that every foreign library of the package be added? (What if you're in a sandbox?) That actually makes a good bit of sense, as cabal exec is supposed to add the local sandbox bin directory to your PATH, so similarly, it should add the local sandbox lib directory (doesn't exist yet) to your LD_LIBRARY_PATH. Though, this doesn't help much in the non-sandbox case where PATH doesn't get twiddled (maybe it should: add to the PATH the directory of each executable build product; similarly, add to LD_LIBRARY_PATH the directory of each library build product).

@abooij does this make sense? Would you be interested in implementing this?

@ezyang ezyang added this to the Triaged milestone Oct 28, 2016
@abooij
Copy link
Contributor Author

abooij commented Oct 28, 2016

@ezyang That does make sense. And you are able to make more precise what I was somewhat worried about when I proposed this -- thanks for that.

We discussed this a bit on IRC and I can try to work on this.

@ezyang
Copy link
Contributor

ezyang commented Oct 28, 2016

OK, I added you to the Cabal project and assigned you this ticket.

@ezyang
Copy link
Contributor

ezyang commented Oct 29, 2016

@abooij Would you like an architectural overview on this ticket?

ezyang added a commit to abooij/cabal that referenced this issue Oct 31, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
abooij pushed a commit to abooij/cabal that referenced this issue Nov 1, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Auke Booij <auke@tulcod.com>
abooij pushed a commit to abooij/cabal that referenced this issue Nov 1, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Auke Booij <auke@tulcod.com>
abooij pushed a commit to abooij/cabal that referenced this issue Nov 1, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Auke Booij <auke@tulcod.com>
abooij pushed a commit to abooij/cabal that referenced this issue Nov 1, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Auke Booij <auke@tulcod.com>
abooij pushed a commit to abooij/cabal that referenced this issue Nov 1, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Auke Booij <auke@tulcod.com>
abooij pushed a commit to abooij/cabal that referenced this issue Nov 1, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Auke Booij <auke@tulcod.com>
abooij pushed a commit to abooij/cabal that referenced this issue Nov 1, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Auke Booij <auke@tulcod.com>
abooij pushed a commit to abooij/cabal that referenced this issue Nov 1, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Auke Booij <auke@tulcod.com>
abooij pushed a commit to abooij/cabal that referenced this issue Nov 2, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Auke Booij <auke@tulcod.com>
abooij pushed a commit to abooij/cabal that referenced this issue Nov 2, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Auke Booij <auke@tulcod.com>
abooij pushed a commit to abooij/cabal that referenced this issue Nov 2, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Auke Booij <auke@tulcod.com>
abooij pushed a commit to abooij/cabal that referenced this issue Nov 2, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Auke Booij <auke@tulcod.com>
abooij pushed a commit to abooij/cabal that referenced this issue Nov 2, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Auke Booij <auke@tulcod.com>
abooij pushed a commit to abooij/cabal that referenced this issue Nov 2, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Auke Booij <auke@tulcod.com>
abooij pushed a commit to abooij/cabal that referenced this issue Nov 2, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Auke Booij <auke@tulcod.com>
abooij pushed a commit to abooij/cabal that referenced this issue Nov 22, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Auke Booij <auke@tulcod.com>
abooij pushed a commit to abooij/cabal that referenced this issue Nov 22, 2016
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Auke Booij <auke@tulcod.com>
@abooij abooij closed this as completed Sep 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants