Skip to content

Undocumented fields in the user manual #2481

Closed

Description

@osa1

Cabal accepts extra-include-dirs field in the file, but 1) it's not working 2) it's not documented 3) seems to be replaced with include-dirs.

EDIT: I wasted an hour trying to fix a linker problem and here's what I found:

Cabal has lib-dirs, include-dirs and libraries fields, and a extra- prefixed version of each. In the user manual:

extra-lib-dirs is documented , but lib-dirs is missing.
include-dirs is documented, but extra-include-dirs is missing.
extra-libraries is documented, but libraries is missing.

And clearly those are not the same, i.e. extra-lib-dirs and lib-dirs are used differently. (I had to use both in my program to make it working)

So I think user guide needs improvements.

Activity

  1. changed the title [-]extra-include-dirs not documented and not working[/-] [+]Undocumented fields in the user manual[/+] on Mar 19, 2015
  2. osa1 commented on Mar 19, 2015

    @osa1
    Author

    (also changed the title)

  3. added this to the milestone on Apr 25, 2015
  4. modified the milestones: Cabal 1.24, on Feb 21, 2016
  5. bollu commented on May 15, 2016

    @bollu

    This doesn't work even now AFAIK. I've been trying to write bindings to SymEngine, and cabal just doesn't accept --extra-lib-dirs. It's frustrating.

    Here is the travis.yml

    Here is a cabal build that is failing

    On the other hand, [here is the succeeding stack build](https://travis-
    ci.org/symengine/symengine.hs/jobs/130275588) for the same commit.

    I find this insane, that cabal still has problems that shouldn't be problems, which stack solves this perfectly.

    How can I help fix this error / how do I solve this anyway? cabal doesn't accept --lib-dirs as a command line parameter either so I really don't know how to tell cabal that I have a library in a non-standard location

  6. ezyang commented on May 15, 2016

    @ezyang
    Contributor

    I am confused. cabal configure --extra-lib-dirs works for me:

    ezyang@sabre:~/Dev/labs/cc$ ls
    A.hs  cc.cabal  ChangeLog.md  LICENSE  Setup.hs
    ezyang@sabre:~/Dev/labs/cc$ cabal configure --extra-lib-dirs=/tmp
    Resolving dependencies...
    Configuring cc-0.1.0.0...
    ezyang@sabre:~/Dev/labs/cc$ cabal build -v
    Component build order: library 'cc'
    Building cc-0.1.0.0...
    /usr/bin/ghc-pkg init dist/package.conf.inplace
    creating dist/build
    creating dist/build/autogen
    Preprocessing library cc-0.1.0.0...
    Building library cc...
    creating dist/build
    /usr/bin/ghc --make -fbuilding-cabal-package -O -j1 -static -dynamic-too -dynosuf dyn_o -dynhisuf dyn_hi -outputdir dist/build -odir dist/build -hidir dist/build -stubdir dist/build -i -idist/build -i. -idist/build/autogen -Idist/build/autogen -Idist/build -optP-include -optPdist/build/autogen/cabal_macros.h -package-name cc-0.1.0.0 -hide-all-packages -package-db dist/package.conf.inplace -package-id base-4.7.0.2-5ef1e7e809bc3b18d74efc783356e209 -XHaskell2010 A
    [1 of 1] Compiling A                ( A.hs, dist/build/A.o )
    Linking...
    [(SimpleUnitId (ComponentId
    "base-4.7.0.2-5ef1e7e809bc3b18d74efc783356e209"),ModuleRenaming True [])]
    /usr/bin/ar -r dist/build/objs-8806/libHScc-0.1.0.0-LmHDApNUJXzLN6FQsTlkp7.a dist/build/A.o
    /usr/bin/ar: creating dist/build/objs-8806/libHScc-0.1.0.0-LmHDApNUJXzLN6FQsTlkp7.a
    /usr/bin/ghc -shared -dynamic -L/tmp '-dynload deploy' -optl-Wl,-rpath,/usr/lib/ghc/base-4.7.0.2 -optl-Wl,-rpath,/usr/lib/ghc/rts-1.0 -optl-Wl,-rpath,/usr/lib/ghc/ghc-prim-0.3.1.0 -optl-Wl,-rpath,/usr/lib/ghc/integer-gmp-0.5.1.0 -no-auto-link-packages -package-db dist/package.conf.inplace -package-id base-4.7.0.2-5ef1e7e809bc3b18d74efc783356e209 dist/build/A.dyn_o -o dist/build/libHScc-0.1.0.0-LmHDApNUJXzLN6FQsTlkp7-ghc7.8.4.so
    /usr/bin/ghc-pkg recache '--package-db=dist/package.conf.inplace'
    

    (look for -L).

    I don't really know what is going on with extra-lib-dirs in the package description format, but that was added by ekarttun in a693cd5; the flag was added later by Pepe Iborra in 6040df4.

  7. bollu commented on May 15, 2016

    @bollu

    hm, interesting. And no, I'm not passing it through the .cabal file, I'm passing it through the cabal install.

    Here is the exact cabal install invocation: Link

    As I have said, a similar stack build works: Link

    Thanks a lot for your help, I really appreciate it!

  8. ezyang commented on May 15, 2016

    @ezyang
    Contributor

    Can you run this with -v? I want to see if -lsymengine is being passed to the compiler.

    And just a random idea, but can you try a more recent version of Cabal/cabal-install?

    cabal install passes --extra-lib-dirs just fine for me too:

    ezyang@sabre:~/Dev/labs/cc$ cabal install --extra-lib-dirs=/tmp -v
    <snip>
    /usr/bin/ghc -shared -dynamic -L/tmp '-dynload deploy' -optl-Wl,-rpath,/usr/lib/ghc/base-4.7.0.2 -optl-Wl,-rpath,/usr/lib/ghc/rts-1.0 -optl-Wl,-rpath,/usr/lib/ghc/ghc-prim-0.3.1.0 -optl-Wl,-rpath,/usr/lib/ghc/integer-gmp-0.5.1.0 -no-auto-link-packages -package-db dist/package.conf.inplace -package-id base-4.7.0.2-5ef1e7e809bc3b18d74efc783356e209 dist/build/A.dyn_o -o dist/build/libHScc-0.1.0.0-LmHDApNUJXzLN6FQsTlkp7-ghc7.8.4.so
    

    In any case, the error is not consistent with --extra-lib-dirs not being passed to Cabal, because the error you are getting during compilation is a missing symbol rather than a missing library. So this seems to suggest that the library is not making it to the build in the first place. I can't tell from your Travis log because it doesn't have enough information.

  9. bollu commented on May 15, 2016

    @bollu

    @ezyang - Thanks for the help, but I think I figured the issue out.

    For the library to link, it supposedly needs to have the other module in the other-modules.

    Here's the edited .cabal file

    The build passes and runs the tests: Here's a travis log

    I think the cabal error message is terrible though, since it simply tells you the linker fails, but it doesn't tell you why it does.

    For the sake of documentation, here's how you fix it

    Fix for the error

    I'm writing the down for SEO, so others can find the solution

    Error
    In function `___':
    (.text+__): undefined reference to `___'
    
    Keywords
    haskell cabal build travis test source-modules undefined reference FFI
    
    Solution
    1. The fix is to added the module the un-linkable functions are present into other-modules in your .cabal file.
    2. If the module can't be found, then add the source folder of the module into the hs-source-dirs part of the .cabal file
  10. ezyang commented on May 15, 2016

    @ezyang
    Contributor

    I am very confused by your proposed fix. I don't see any change to other-modules in your Cabal file history.

  11. bollu commented on May 15, 2016

    @bollu

    @ezyang - Apologies, I pointed you to the .cabal file on the wrong branch. I've edited the comment to point to the right one.

    Here is the link

  12. modified the milestone: Cabal 2.0 on Sep 6, 2016
  13. gbaz commented on Feb 7, 2018

    @gbaz
    Collaborator

    The extra- versions of all are now documented, and it appears the non-extra versions are no longer around/used? Which suggests to me this can be closed... (unless the non-prefixed versions are still there, undocumented, and of some possible use...)

  14. self-assigned this
    on Nov 17, 2018
  15. linearray commented on Nov 17, 2018

    @linearray
    Member

    I just checked and lib-dirs is gone, libraries appears to be gone, include-dirs and extra-include-dirs are here and well-documented. Closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions