I’m trying to run some hand written asm code in my ocaml program via c stubs using dune, but i cannot get it to work.
This is my dune file:
(library
(name c_test)
(extra_objects test)
(foreign_stubs (language c) (names file1)))
(rule
(targets test.o)
(deps test.asm)
(action (run nasm -f elf64 %{deps})))
I first tried without the extra_objects stanza, then the build of the library works fine, but it fails when linking the executable with undefined reference to 'ASM_Succ'
. When looking at the dune documentation, it seems like the extra_objects stanza is the solution to the problem. But then i get the following error.
/usr/bin/ld: lib/test.o: in function `ASM_Succ':
test.asm:(.text+0x0): multiple definition of `ASM_Succ'; lib/libc_test_stubs.a(test.o):test.asm:(.text+0x0): first defined here
It seems like dune is adding test.o into lib/libc_test_stubs.a and also using test.o directly making my function defined twice. If i remove test.o from libc_test_stubs.a the command that dune runs succeeds.
Am i doing something wrong, or is dune misbehaving? Is there some other stanza i should be using to get this to work?
Any help is highly appreciated!
3 posts - 2 participants