FS#43197 - [llvm-ocaml] Cannot use ocaml with llvm: undefined symbol, missing external function

Attached to Project: Arch Linux
Opened by Alain Kalker (ackalker) - Monday, 22 December 2014, 17:05 GMT
Last edited by Evangelos Foutras (foutrelis) - Sunday, 04 January 2015, 22:51 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Evangelos Foutras (foutrelis)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:

TL;DR

- Please rebuild llvm-ocaml against latest ocaml version.
- Link info for llvm ocaml package appears to be broken.

llvm-ocaml appears to be out of sync with the latest ocaml package.
Trying to build [1] produces the following error (full log attached to this issue):

File "ipl_llvm.ml", line 1:
Error: The files /usr/lib/ocaml/pervasives.cmi and /usr/lib/ocaml/llvm.cmi
make inconsistent assumptions over interface Pervasives

Rebuilding the llvm package against the latest ocaml and reinstalling the llvm, llvm-libs, llvm-ocaml and clang packages resolved the above problem.

However, a new, related issue pops up, A clean build of [1] now produces the following error:

ocamlc -g -ccopt -lstdc++ llvm.cma llvm_executionengine.cma llvm_analysis.cma llvm_scalar_opts.cma llvm_target.cma llvm_bitwriter.cma var.cmo base.cmo value.cmo term.cmo eval.cmo printing.cmo reify.cmo ctx.cmo check_term.cmo initial.cmo expr.cmo check_expr.cmo lex.cmo syntax.cmo ipl_compile.cmo ipl_llvm.cmo test_llvm.cmo -o test_llvm
File "_none_", line 1:
Error: Error on dynamically loaded library: /usr/lib/ocaml/dllllvm.so: /usr/lib/ocaml/dllllvm.so: undefined symbol: LLVMGetFirstUse
Makefile:113: recipe for target 'test_llvm' failed
make: *** [test_llvm] Error 2

To investigate, I tried building a custom toplevel containing the llvm bindings:

$ ocamlmktop -o llvmtop llvm.cma
File "_none_", line 1:
Error: Error on dynamically loaded library: /usr/lib/ocaml/dllllvm.so: /usr/lib/ocaml/dllllvm.so: undefined symbol: LLVMGetFirstUse

$ pacgrep LLVMGetFirstUse llvm-libs # personal script
$ pacgrep LLVMGetFirstUse llvm-libs
Binary file /usr/lib/libLLVM-3.5.0.so matches
Binary file /usr/lib/libLLVM-3.5.so matches

It appears the link information for llvm linking dllllvm.so with libLLVM-*.so is broken. Could this be an RPATH issue? (it appears that RPATH is being forcibly removed in the PKGBUILD).

Additional info:
* package version(s)
ocaml 4.02.1-1
llvm 3.5.0-2.1
llvm-libs 3.5.0-2.1
llvm-ocaml 3.5.0-2.1
* config and/or log files etc.


Steps to reproduce:
$ ocamlmktop -o llvmtop llvm.cma
File "_none_", line 1:
Error: Error on dynamically loaded library: /usr/lib/ocaml/dllllvm.so: /usr/lib/ocaml/dllllvm.so: undefined symbol: LLVMGetFirstUse
This task depends upon

Closed by  Evangelos Foutras (foutrelis)
Sunday, 04 January 2015, 22:51 GMT
Reason for closing:  Fixed
Additional comments about closing:  llvm 3.5.0-3
Comment by Alain Kalker (ackalker) - Monday, 22 December 2014, 17:06 GMT Comment by Alain Kalker (ackalker) - Monday, 22 December 2014, 19:18 GMT
I managed to get the example in [2] working by hacking up this:

$ ocamlc -cc g++ llvm.cma llvm_bitreader.cma bc.cmo -o bc

and turning it into the following ugly monstrosity:

$ ocamlc -verbose -custom -cclib "$(llvm-config --libs) /usr/lib/ocaml/dllllvm_bitreader.so /usr/lib/ocaml/dllllvm.so /usr/lib/libLLVM-3.5.so" -cc g++ llvm.cma llvm_bitreader.cma bc.cmo -o bc

[2]: http://nopaniers.calepin.co/getting-started-with-ocaml-bindings-for-llvm.html
Comment by Evangelos Foutras (foutrelis) - Tuesday, 23 December 2014, 12:25 GMT
Thanks for the detailed report. I've pushed llvm 3.5.0-3 which should fix both issues.

The OCaml .so libs were indeed underlinked which I've reported upstream: http://llvm.org/bugs/show_bug.cgi?id=22014

Please note that intuitionistic still won't build because Llvm_executionengine is broken in LLVM 3.5.
Comment by Alain Kalker (ackalker) - Tuesday, 23 December 2014, 20:15 GMT
Thanks for looking into this, I'm forward to the update.
Comment by Alain Kalker (ackalker) - Tuesday, 23 December 2014, 20:16 GMT
*looking forward

Loading...