On Thu, Aug 5, 2010 at 11:47 AM, Dmitry Karpeev <span dir="ltr"><<a href="mailto:karpeev@mcs.anl.gov">karpeev@mcs.anl.gov</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Thu, Aug 5, 2010 at 11:42 AM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span> wrote:<br></div><div class="gmail_quote"><div class="im">
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div><div></div><div>On Thu, Aug 5, 2010 at 11:40 AM, Dmitry Karpeev <span dir="ltr"><<a href="mailto:karpeev@mcs.anl.gov" target="_blank">karpeev@mcs.anl.gov</a>></span> wrote:<br></div></div><div class="gmail_quote">

<div><div></div><div><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
What is the intended behavior of PetscDLSym when called on an empty handle: PetscDLSym(handle=PETSC_NULL, symbol, &value)<br>My understanding was that this should look for symbol in the symbol table of the main executable.<br>



This is based on what happens in the Windows case (#ifdef PETSC_HAVE_WINDOWS_H), <br>but when using dlopen (#ifdef PETSC_HAVE_DLFCN_H), this probably won't behave correctly,as currently implemented.  <br>This is because the above call will boil down to <br>



   value = dlsym((dlhandle_t)0, symbol), <br>which on many systems returns NULL (e.g., on Ubuntu 9.10).<br>There is a relatively easy fix, which is to obtain the handle of the main executable with, for example,<br>  dlhandle = dlopen(0,RTLD_LOCAL|RTLD_LAZY)<br>



followed by<br>  value = dlsym(dlhandle,symbol)<br><br>I have played around with it on my box, and it appears to work.<br>I can push that fix, if that's what we decide we want, and if it doesn't alter the currently expected behavior.<br>



There is one caveat: symbols can be dlsym'ed from the executable only if they are exported as dynamically-loadable,<br>which is not the default behavior for linking executable (so as not to pollute the dynamic symbol table).<br>



On linux the linker needs to get -Wl,--export-dynamic, but it would be nice to enable some sort of portable option at compile time.<br></blockquote><div><br></div></div></div><div>This is sharedLinkerFlags.</div></div></blockquote>
</div></div></blockquote><div><br></div><div>Whoops this is wrong. Its something different.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote">
<div class="im"><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"><div class="gmail_quote"><div> </div></div></blockquote></div><div>Sorry, I meant configure-time option.<br>
</div></div></blockquote><div><br></div><div>Yes, it should be a configure option.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote">
<div>Does sharedLinkerFlags alter the behavior of CLINKER?<br></div></div></blockquote><div><br></div><div>I thought we fixed LDFLAGS, but maybe not.</div><div><br></div><div>  Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="gmail_quote"><div>Unless there is another way to link an executable.<br><font color="#888888"><br>Dmitry.<br> <br></font></div><div class="im"><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">

<div class="gmail_quote"><div><br></div><div>
  Matt</div><div><div> </div><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">Incidentally, currently there appears to be no way to supply additional linker flags, as used to be the case with LDFLAGS.<br>


<font color="#888888">
<br>Dmitry.</font></blockquote></div></div><font color="#888888">-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>

-- Norbert Wiener<br>

</font></blockquote></div></div><br>
</blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener<br>