<div dir="ltr"><div><div>> Look at the generated PKGBUILD for a tool such as `cblrepo` and you'll<br>
> see what I mean.<br><br></div>Hum, I looked again but they seem to use already `depends`. There is 233 packages in habs, and 218 have empty `makedepends`:<br><br></div>    $ cd habs<br>    $ cblrepo pkgbuild $(cblrepo build base|tail -n +2)<br>




    $ ls */PKGBUILD | wc -l<br>    233<br><div>    $ grep -R "makedepends=()" */PKGBUILD | wc -l<br>    218<br>    $ grep -R "makedepends=()" */PKGBUILD<br>    haskell-abstract-deque/PKGBUILD:makedepends=()<br>




    haskell-abstract-par/PKGBUILD:makedepends=()<br>    haskell-aeson/PKGBUILD:makedepends=()<br>    haskell-anansi/PKGBUILD:makedepends=()<br></div><div>    [[...]]<br></div><div>    haskell-xmonad/PKGBUILD:makedepends=()<br>




    haskell-yaml/PKGBUILD:makedepends=()<br>    haskell-zip-archive/PKGBUILD:makedepends=()<br>    haskell-zlib/PKGBUILD:makedepends=()<br><br><div><div><br>> The default for GHC has always been to link statically, so that's<br>





> where we started.  Then we added building of shared libs at one point,<br>
> but there was never any push to actually use them.<br>
> <br>
> After reading the page you point to above (in the GHC 7.6.3 docs) I'm<br>
> also wondering what flags to give at build time to make an executable<br>
> use dynamic libs.  I had a look at pandoc, which is a package<br>
> providing both a lib and an exe.  It is configured with<br>
> `--enable-shared` but the executable isn't dynamically linked against<br>
> the libs it uses:<br>> <br>
> % ldd /usr/bin/pandoc<br>
>         linux-vdso.so.1 (0x00007fffbbb93000)<br>
>         libz.so.1 => /usr/lib/libz.so.1 (0x00007f23e993a000)<br>
>         libpcre.so.1 => /usr/lib/libpcre.so.1 (0x00007f23e96d4000)<br>
>         libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f23e94d0000)<br>
>         libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f23e92b2000)<br>
>         libgmp.so.10 => /usr/lib/libgmp.so.10 (0x00007f23e903b000)<br>>          libm.so.6 => /usr/lib/libm.so.6 (0x00007f23e8d38000)<br>>          librt.so.1 => /usr/lib/librt.so.1 (0x00007f23e8b30000)<br>





>         libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f23e891a000)<br>
>         libc.so.6 => /usr/lib/libc.so.6 (0x00007f23e856f000)<br>
>         /lib64/ld-linux-x86-64.so.2 (0x00007f23e9b50000)<br><br></div><div>The flag "--enable-shared" generates the shared libraries. The flag "-dynamic" builds executable against these libraries. I managed to build pandoc with shared libraries (and it worked, with a small hack, see problem at the end of the message):<br>



<br>    $ ldd /usr/bin/pandoc<br>    linux-vdso.so.1 (0x00007fff819fe000)<br>    <a href="http://libHSpandoc-1.12.1-ghc7.6.3.so" target="_blank">libHSpandoc-1.12.1-ghc7.6.3.so</a> => /usr/lib/ghc-7.6.3/shared/<a href="http://libHSpandoc-1.12.1-ghc7.6.3.so" target="_blank">libHSpandoc-1.12.1-ghc7.6.3.so</a> (0x00007fd3929ec000)<br>



    <a href="http://libHSzip-archive-0.1.4-ghc7.6.3.so" target="_blank">libHSzip-archive-0.1.4-ghc7.6.3.so</a> => /usr/lib/ghc-7.6.3/shared/<a href="http://libHSzip-archive-0.1.4-ghc7.6.3.so" target="_blank">libHSzip-archive-0.1.4-ghc7.6.3.so</a> (0x00007fd39279c000)<br>



    <a href="http://libHSzlib-0.5.4.1-ghc7.6.3.so" target="_blank">libHSzlib-0.5.4.1-ghc7.6.3.so</a> => /usr/lib/ghc-7.6.3/shared/<a href="http://libHSzlib-0.5.4.1-ghc7.6.3.so" target="_blank">libHSzlib-0.5.4.1-ghc7.6.3.so</a> (0x00007fd392577000)<br>



    [[...]]<br>    <a href="http://libHStransformers-0.3.0.0-ghc7.6.3.so" target="_blank">libHStransformers-0.3.0.0-ghc7.6.3.so</a> => /usr/lib/ghc-7.6.3/shared/<a href="http://libHStransformers-0.3.0.0-ghc7.6.3.so" target="_blank">libHStransformers-0.3.0.0-ghc7.6.3.so</a> (0x00007fd3869d6000)<br>



    <a href="http://libHSinteger-gmp-0.5.0.0-ghc7.6.3.so" target="_blank">libHSinteger-gmp-0.5.0.0-ghc7.6.3.so</a> => /usr/lib/ghc-7.6.3/shared/<a href="http://libHSinteger-gmp-0.5.0.0-ghc7.6.3.so" target="_blank">libHSinteger-gmp-0.5.0.0-ghc7.6.3.so</a> (0x00007fd3867c5000)<br>



    <a href="http://libHSmtl-2.1.2-ghc7.6.3.so" target="_blank">libHSmtl-2.1.2-ghc7.6.3.so</a> => /usr/lib/ghc-7.6.3/site-local/mtl-2.1.2/<a href="http://libHSmtl-2.1.2-ghc7.6.3.so" target="_blank">libHSmtl-2.1.2-ghc7.6.3.so</a> (0x00007fd386598000)<br>



    librt.so.1 => /usr/lib/librt.so.1 (0x00007fd386390000)<br>    libutil.so.1 => /usr/lib/libutil.so.1 (0x00007fd38618d000)<br>    libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fd385f89000)<br>    libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fd385d6b000)<br>



    <a href="http://libHSdeepseq-1.3.0.1-ghc7.6.3.so" target="_blank">libHSdeepseq-1.3.0.1-ghc7.6.3.so</a> => /usr/lib/ghc-7.6.3/deepseq-1.3.0.1/<a href="http://libHSdeepseq-1.3.0.1-ghc7.6.3.so" target="_blank">libHSdeepseq-1.3.0.1-ghc7.6.3.so</a> (0x00007fd385b62000)<br>



    <a href="http://libHSarray-0.4.0.1-ghc7.6.3.so" target="_blank">libHSarray-0.4.0.1-ghc7.6.3.so</a> => /usr/lib/ghc-7.6.3/array-0.4.0.1/<a href="http://libHSarray-0.4.0.1-ghc7.6.3.so" target="_blank">libHSarray-0.4.0.1-ghc7.6.3.so</a> (0x00007fd3858c1000)<br>



    libgmp.so.10 => /usr/lib/libgmp.so.10 (0x00007fd38564a000)<br>    libffi.so.6 => /usr/lib/libffi.so.6 (0x00007fd385442000)<br>    libm.so.6 => /usr/lib/libm.so.6 (0x00007fd38513f000)<br>    /lib64/ld-linux-x86-64.so.2 (0x00007fd3937a3000)<br>



<br></div><div>I have modified cblrepo to add a flag "--dynamic" to the "pkgbuild" command to generate a PKGBUILD with dynamic linking:<br><br>    $ cblrepo pkgbuild --dynamic pandoc<br><br></div><div>



See: <a href="https://github.com/StreakyCobra/cblrepo/commit/677fe94c311c9e71f0ad99c1f7ee3ca93a02dff4" target="_blank">https://github.com/StreakyCobra/cblrepo/commit/677fe94c311c9e71f0ad99c1f7ee3ca93a02dff4</a></div><div>


<br>I'll propose that as a pull request when all will be working.<br>
</div><div><br><br><br></div><div>The current problem<br>-----------------------------<br><br></div><div>There is still a small problem: Referencing the shared libraries. As stated at the bottom of [1], there is two ways:<br>



<br></div><div>  1. By embedding a RPATH into the executable.<br></div><div>  2. Using LD_LIBRARY_PATH (or equivalently and better /etc/ld.so.conf.d/*) to specify libraries paths.<br><br></div><div>The first solution is system dependent, and also less elegant from my point of view. So I focused on the second. Sadly the current hierarchy of Haskell packages doesn't place all shared libraries in the same folder, but in separate folders of the form:<br>



<br></div><div>    /usr/lib/ghc-<version>/[site-local]/<package>-<version>/<sharedLibraryName>.so<br><br></div><div>It is unfeasible to reference all these folders (even more with the version in the folder name).<br>


<br>So I actually just made a small hack: a "/usr/lib/ghc-7.6.3/shared" folder and soft-links of all "*.so" inside. Then I added a new "/etc/ld.so.conf.d/haskell.conf" file containing the line:<br>


    /usr/lib/ghc-7.6.3/shared<br></div><div>and run `ldconfig` to update the libraries paths.<br><br></div><div>Do you see any better way to reference these libraries?<br><br></div><div>If no I suggest to put (or link) all "*.so" libraries either in "/usr/lib" or in another folder on a specific place on the system. It is also possible to add, if it is needed, a "/etc/ld.so.conf.d/haskell.conf" file to a new package like "haskell-runtime" and make all Haskell package depends on.<br>


</div><div><br>[1]<a href="http://www.haskell.org/ghc/docs/7.6.3/html/users_guide/using-shared-libs.html" target="_blank">http://www.haskell.org/ghc/docs/7.6.3/html/users_guide/using-shared-libs.html</a><br>
</div><div><br></div></div></div></div>