Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bytecode compatibility #110

Open
mimoo opened this issue Feb 2, 2023 · 4 comments
Open

bytecode compatibility #110

mimoo opened this issue Feb 2, 2023 · 4 comments

Comments

@mimoo
Copy link
Contributor

mimoo commented Feb 2, 2023

I'm trying to run ocamldebug on some OCaml code that is linked to a Rust library (using ocaml-rs). I need to build to the bytecode format before I can do that with dune build some/path.bc but I get the following error:

Error: Error on dynamically loaded library: ./src/lib/crypto/kimchi_bindings/stubs/dllwires_15_stubs.so: Truncated file

I'm wondering if there's a way to make this work? Or if this is because FFI can't happen due to the bytecode format of OCaml

@tizoc
Copy link
Contributor

tizoc commented Feb 2, 2023

Hi, just pinged you. I had this same issue some time ago, but it is unrelated to ocaml-rs. Just copy the file manually after a regular build and before you try to build the bytecode program:

cp ./_build/cargo_kimchi_bindgen/debug/libwires_15_stubs.so src/lib/crypto/kimchi_bindings/stubs/dllwires_15_stubs.so

@mimoo
Copy link
Contributor Author

mimoo commented Feb 2, 2023

ah, Imma try that!

A coworker told me that this change also made it work: MinaProtocol/mina@b3ae083 but that it wouldn't work on mac

@mimoo
Copy link
Contributor Author

mimoo commented Feb 2, 2023

btw I think I don't have .so because I'm on mac?

❯ ls ./_build/cargo_kimchi_stubs/release 
build                  examples               libwires_15_stubs.a    libwires_15_stubs.rlib wires_15_stubs.d
deps                   incremental            libwires_15_stubs.d    wires_15_stubs

@tizoc
Copy link
Contributor

tizoc commented Feb 2, 2023

hmmm weird, I would expect to see a .dylib instead, but it is not there.

And the docs confirm that the "cdylib" crate type should produce that (EDIT: that change in the commit you linked was reverted later, but you need that "cdylib" there, I had to add it a while back when I hit the same issue as you)

--crate-type=cdylib, #![crate_type = "cdylib"] - A dynamic system library will be produced. This is used when compiling a dynamic library to be loaded from another language. This output type will create *.so files on Linux, *.dylib files on macOS, and *.dll files on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants