Good questions -- I'd like to fix it so that LLVM returns a catchable error
in these cases, but I have to sort through if that is actually possible
since there are multiple places where linking occurs. If you just wanted to
test if a particular symbol is available you can use the C API function
dlsym:

C = terralib.includecstring [[
    #include <dlfcn.h>
   void * rtld_default() { return RTLD_DEFAULT; } //its defined as a macro,
so wrap it in a function
]]
if  0 ~= C.dlsym(C.rtld_default(),"counter") then
  --symbol is defined
end


> On a related but separate note, if program P loads a library  L via
> dyn.load, can L view all the symbols of P?


This depends on how P is built and what OS it is on, unfortunately. The
'terra' program is built so that its public APIs terra_, lua_, etc. are
visible to any library loaded (see, -Wl,-export-dynamic in the makefile),
but many programs are not built this way by default.

-- Zach

On Tue, Mar 3, 2015 at 5:12 PM, Saptarshi Guha <[email protected]>
wrote:

> Hello,
> I have an includec like
>
> X=  terralib.includecstring [[
>             SEXP counter(SEXP );
>     ]]'
>
> I would like to chck if 'counter' can be resolved.
>
> For example, if counter is not resolved, this happens
>
> LLVM ERROR: Program used external function 'collect' which could not be
> resolved!
>
> But, X.counter != nil, X.count is a <terra function>.
>
> How can i check if it has been resolved?
>
> On a related but separate note, if program P loads a library  L via
> dyn.load, can L view all the symbols of P?
>
> Cheers
> Saptarshi
>
>
> _______________________________________________
> terralang mailing list
> [email protected]
> https://mailman.stanford.edu/mailman/listinfo/terralang
>
>
_______________________________________________
terralang mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/terralang

Reply via email to