-
Notifications
You must be signed in to change notification settings - Fork 30
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
Attempt at static ccall #131
Comments
Ok, here's a more elaborate example:
This doesn't even work (I get a segmentation fault), but if I replace Maybe I'm doing something wrong, or there is an issue with these functions from StaticTools I guess? |
Your |
You also don't need |
Oh, that was silly. I guess Julia converted it under the hood so it managed to work anyway with I modified my calling function to:
and it's still the same result: works with |
Yes, but for what I know, code containing The point in this second test would be to compile it with
but I didn't even get there. |
Oh, I'm just not being able to use |
Try with `@ccall`, it might just work nowdays
StaticCompiler actually doesn’t provide a `dlopen` unless I’m much mistaken so that’s probably giving you Libdl dlopen
|
is that something you do on mac? I'm on Linux... Yes, I thinkg StaticCompiler imports dlopen from Libdl... I just checked what Libdl.dlope does, and it is implemented in C, and esentially searches every possible path (including Julia's DL_LOAD_PATH, and every possible extension: https://github.com/JuliaLang/julia/blob/01ddf80f18fc618e20df307945a9c19e74005270/src/dlload.c#L263 |
Hmm, judging from @brenhinkeller's MPI example, maybe @symbolcall and linking via cflags is preferable to dlopen and dlsym? I mean, we would leave the trouble of finding the shared library to the c compiler... as long as we have anything we need in LD_LIBRARY_PATH, that could work. |
Oh wow sending from email really messed up the formatting on that.. I meant |
Lol. So you guys say that somehow ccall now should work with StaticCompiler? I tried to no sucess:
it compiles, but then it segfaults when run:
On the other hand, I can compile a call to
|
Hey, I said might :) |
That actually works for me
I wonder what the difference is? |
Wow, that's interesting. Something curious is that I get the segfault in line 1, so even if I add some inocent code before ccall, it fails:
By the way, @symbolcall works nicely for me:
From the last time I tried this I was left with the idea that |
I can also get "mean" to work with just symbolcall and a cflag to link to that library...
(I renamed clib.so to libmean.so, and also had to set the env variable for library paths in order to run the executable). |
Huh, interesting. Yeah, adding some ccall examples to the test suite seems like a good idea to me!
|
Hi,
Even though this is well beyond my skill level I'm trying to get something like a "static ccall" working... This is actually my second attempt, after a year or so...
From the last time, I got the idea that a the way to implement a "static ccall" would be to replace
ccall
with something like@ptrcall
, but we need to get the function's pointer somehow, and that is whatStaticTools.dlopen
does.So I guess the minimal example should be something that compiles a function which contains
StaticTools.dlopen
... Does this sound reasonable?Anyway, in the StaticTools docs I found a very small function
dltime()
, which could be worth trying to get to compile:Edit: silly me, I was forgetting to link with -ldl... this works...
Anyway, I'll try to continue with a more complex example that passes some arguments to the c function...
The text was updated successfully, but these errors were encountered: