<div dir="ltr">Hi,<div><br></div><div>I've made some changes to the LLVM backend of GHC to make it use llvm-general to output bitcode rather than pretty printing human readable LLVM assembly. However, I've been having trouble linking the required libraries (llvm-general and its transitive dependencies). The steps I've taken so far are to put the required libraries in the build tree under libraries, and added them to the packages file, to PACKAGES_STAGE0 and PACKAGES_STAGE1 in <a href="http://ghc.mk">ghc.mk</a>, and to the build depends section in compiler/<a href="http://ghc.cabal.in">ghc.cabal.in</a>.</div>

<div><br></div><div>The build fails in phase 1 when trying to link utf8-string (a dependency of llvm-general) during the build of llvm-general, with:</div><div><div>Loading package utf8-string-0.3.7 ... <command line>: can't load .so/.DLL for: <a href="http://libHSutf8-string-0.3.7.so">libHSutf8-string-0.3.7.so</a> (<a href="http://libHSutf8-string-0.3.7.so">libHSutf8-string-0.3.7.so</a>: cannot open shared object file: No such file or directory)</div>

</div><div><br></div><div>The problem seems to be that with pre-existing library dependencies, the system-wide libraries at /usr/lib/ghc-7.6.3/<libname>/ are pulled in, whereas with the new dependencies, versions within the build tree (e.g. at libraries/utf8-string/dist-install/build/) are tried instead, despite these new libraries being installed globally within the same parent directory and being listed by ghc-pkg (no errors upon ghc-pkg check either).</div>

<div><br></div><div>For example, in compiler/stage1/<a href="http://package-data.mk">package-data.mk</a>, compiler_stage1_DEP_LIB_DIRS_SEARCHPATH specifies /usr/lib/ghc-7.6.3/bytestring-0.10.0.2, and bytestring links successfully, but for utf8-string specifies <ghc-base-dir>/libraries/utf8-string/dist-boot/build.</div>

<div><br></div><div>I've read through the documentation on libraries for GHC but can't figure out how to make this work. Could anyone suggest how I could go about fixing this?</div><div><br></div><div>As a slightly related question, llvm-general depends on template-haskell. Will this cause problems when building GHC normally, since the stage 1 compiler does not support TH? If so is there any way to compile stage 2 directly using the stage 0 compiler?</div>

<div><br></div><div>Many thanks,</div><div>Alex</div></div>