-
Notifications
You must be signed in to change notification settings - Fork 413
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 + c stubs not working as expected #108
Comments
|
Hm, but
opam switch is supposed to set it right? But regardless, my executable isn't public, can I still somehow run it? I can make it public, but it seems annoying to have to make executables just to run them. |
Well, it only points to things that are installed. In your example the dll for the stubs is in _build/... As long as the library with the stubs is public you'll be able to run it with |
Hmm, I'm still unable to run the bytecode binary this way. Even after setting CAML_LD_LIBRARY_PATH to what
Seems like CAML_LD_LIBRARY_PATH is set correctly here but the bytecode isn't running. |
Does the |
It didn't exist, thanks for the hint. My library was actually public, but i still ran into that error. Looks like I still needed to build the native target to run the bytecode executable. Note sure if that's expected.
|
Hmm, I see. Technically to build the byte-code executable you don't need the stub. You need it to run it though. Technically we could make the .bc depend on all the stubs. However, then you might want to use in a custom rule and it's starting to become complicated as jbuilder must set I wonder if something needs to be done. I kind of prefer to encourage to just use the native version. Especially it is available even when there is no |
OK, then I think leaving a note about the current situation is enough. This isn't an issue in practice anyway. |
I added a note about byte-code executables in the manual |
I experienced a related issue. I fail to load from utop a library defined with a c-stubs. Utop say "Cannot load required shared library. Cannot open shared object file: No such file or directory. ". Indeed, the shared library is installed by jbuilder/opam in a directory named stubslibs instead of stublibs.
|
I ran into the same issue a few days ago. Which version of opam/opam-installer are you using? (ping @AltGr) |
As @trefis notes, it's entirely to do with a very long-standing bug in opam-installer. You can fix it locally by updating to opam2 beta 4, but I think this makes a very strong case for having Note that installs via opam should be unaffected - there is (intentional) code duplication between opam and opam-installer, so as long as your opam file doesn't incorrectly try to run |
I'm suggesting that An opam file should never include a |
Thanks for this explanation. It makes me notice that the projects ported to jbuilder removed the Indeed, in my case, I left a line |
I'm facing this issue too. The stubs are defined like this in a package
In the same package there is another library In a package
I can run like this and it works
if |
@diml I think this issue has enough negative consequences that it should be addressed - loading stubs in utop is quite useful. Here's another odd situation where this bug can break things: a ppx that uses a C stub will not work on a bytecode only switch. Quite unlikely this will ever happen, but we'd like to make sure bytecode works in all circumstances. |
Anyways, building the dll's for bytecode exe's is simple enough, but it's just part of the story. We also need to add it CAML_LD_LIBRARY_PATH somehow. Would an action that appends to a |
Note that when native compilation is not available or when the user sets the modes to just To support running non-custom bytecode programs, we need to add a notion of runtime dependencies. Essentially, whenever we execute (rule
(deps <deps> ... .../dllstub1.so .../dllstub2.so)
(action (run .../prog.bc ...))) Regarding |
I'm having the same problem(s) trying to drop the dependency of Infer to Core. I am adding a small Is this the expected behavior? If so, is there a less "aggressive" target that I could run to force the creation of the symlink? |
|
See ocaml/dune#108 for why we need this weird code. Also remove references to InferUnit, which has been dead for some time
We have the same problem in Coq; there is a bytecode version of We will be able to workaround that with a (fragile) custom build rule, but it'd be great if |
Can you link to the commit that implements this custom rule? I would like to compare it with the "brittleness" of my hack for Infer. |
@yakobowski this is what we use:
can you point out to the Infer hack? Thanks! |
We add a , this fixes the Coq part of coq#9727 , the Dune part is still open ocaml/dune#108 at but this PR includes a workaround. Unfortunately we have to introduce a small inefficiency in the build process as we build both byte and native versions of plugins for this work reliable. As this is a choice done during bootstrap it won't be easy to fix until we have our own `dune coqtop` command and we can control the rules depending on the final target. This should affect the `check` target so still fast builds should be possible, but if this is a problem we could add a `byteboot` target to help.
We add a shim for running the byte version of coqtop. This fixes the Coq part of coq#9727 , the Dune part is still open at ocaml/dune#108 but this PR includes a workaround. Unfortunately we have to introduce a small inefficiency in the build process as we build both byte and native versions of plugins for this work reliable. As this is a choice done during bootstrap it won't be easy to fix until we have our own `dune coqtop` command and we can control the rules depending on the final target. This should affect the `check` target so still fast builds should be possible, but if this is a problem we could add a `byteboot` target to help.
It is in yakobowski/infer@5fb3548, referenced above. But it is a Makefile-based solution, I would much prefer a Dune-based one. |
I guess you can as we do and have an alias that pulls the stubs and the binary; but indeed it is a gross hack as you can see. |
Hi ! I just had the same issue (I baked a toy example in https://github.com/vsiles/dune-debug-test)
|
See ocaml/dune#108 for why we need this weird code. Also remove references to InferUnit, which has been dead for some time
@vsiles Thank you! I searched everywhere for a thousand years and you saved my life! |
Just a tweak to @vsiles solution: rather than passing
|
Thanks for this info. Do you know in which version |
The PR to deprecate it is not merged yet: ocaml/ocaml#9236 The new option was introduced in 4.10. |
I hit this issue using ctypes + mdx. The mdx stanza creates `mdx-gen.ml, but mdx-gen.bc fails to run. It dlopens the stub fine, but the dynamic linked library itself is not found (missing symbol). Mac OSX |
We're still running into this (see @Khady's post above; we have a pretty pervasive hack involving Unfortunately, that doesn't seem to be helpful in the case mentioned by @frejsoya — I can't feed $ export CAML_LD_LIBRARY_PATH="$scriptdir/../../_build/default/backend/ahrefskit:$CAML_LD_LIBRARY_PATH"
$ dune runtest --verbose
... SNIP ...
Running[1]: (cd _build/default/backend/COMPONENT/client && ./mdx_gen.bc using_ppx.mld) > _build/default/backend/COMPONENT/client/.mdx/using_ppx.mld.corrected
File "backend/COMPONENT/client/dune", line 36, characters 0-67:
36 | (mdx
37 | (files using_ppx.mld)
38 | (libraries COMPONENT.ppx_COMPONENT))
Command [1] got signal ABRT:
$ (cd _build/default/backend/COMPONENT/client && ./mdx_gen.bc using_ppx.mld) > _build/default/backend/COMPONENT/client/.mdx/using_ppx.mld.corrected
Fatal error: cannot load shared library dllahrefskit_stubs_stubs
Reason: dllahrefskit_stubs_stubs.so: cannot open shared object file: No such file or directory Unfortunately, the thing-under-test is a ppx; which doesn't accept $ dune runtest
... SNIP ...
File "backend/COMPONENT/client/dune", line 36, characters 0-67:
36 | (mdx
37 | (files using_ppx.mld)
38 | (libraries COMPONENT.ppx_COMPONENT))
/usr/bin/ld: cannot find -lmysql_stubs
/usr/bin/ld: cannot find -lmurmur3_stubs
/usr/bin/ld: cannot find -lmariadb_stubs
/usr/bin/ld: cannot find -lctypes_stubs
... SNIP ...
/usr/bin/ld: cannot find -lcurl_stubs
collect2: error: ld returned 1 exit status
File "_none_", line 1:
Error: Error while building custom runtime system Is there any workaround to this that will function in a ppx-rewriter binary, when using |
@ELLIOTTCABLE i made this pr #8784 some time ago. Which might be related. I should have followed up on it :) For non-installed shared libraries, at build time and + avoiding global env flags, it is possible to use relative paths to the binary with |
See this repo:
https://github.com/rgrinberg/jbuilder-c-stubs
Am I doing something wrong here?
The text was updated successfully, but these errors were encountered: