<div dir="ltr"><div dir="ltr">On Tue, Jul 9, 2019 at 8:42 AM Jed Brown <<a href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> writes:<br>
<br>
> On Mon, Jul 8, 2019 at 10:37 PM Jed Brown via petsc-dev <<br>
> <a href="mailto:petsc-dev@mcs.anl.gov" target="_blank">petsc-dev@mcs.anl.gov</a>> wrote:<br>
><br>
>> "Smith, Barry F. via petsc-dev" <<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank">petsc-dev@mcs.anl.gov</a>> writes:<br>
>><br>
>> >> On Jul 8, 2019, at 9:53 PM, Jakub Kruzik via petsc-dev <<br>
>> <a href="mailto:petsc-dev@mcs.anl.gov" target="_blank">petsc-dev@mcs.anl.gov</a>> wrote:<br>
>> >><br>
>> >> Just to clarify, the suggested solution is a plug-in sitting anywhere<br>
>> in the PETSc source tree with postponed compilation and using<br>
>> __attribute__((constructor)) to register (as in libCEED) for static<br>
>> libraries?<br>
>> ><br>
>> >   Yes, this is my understanding. Good luck.<br>
>><br>
>> There is some nontrivial infrastructure that would be needed for this<br>
>> model.<br>
>><br>
>> 1. This new component needs to be built into a new library such as<br>
>>    libpetsc-plugin.a (when static).<br>
>><br>
>> 2. Users need to know when they should link this module.  They'll need a<br>
>>    link line something like -lpetsc-plugin -lslepc -lpetsc in this case.<br>
>>    It would need to be specified correctly in makefiles and pkg-config.<br>
>><br>
>> 3. Anything with __attribute__((constructor)) runs *before* main, thus<br>
>>    before PetscInitialize.  There would need to be a new mechanism to<br>
>>    register a callback to be run at the end of PetscInitialize.<br>
>><br>
><br>
> I think the simpler course it just to declare that this does not work<br>
> outside of dynamic linking.<br>
> The number of platforms that do not have dynamic linking is small, and we<br>
> are not putting<br>
> anything critical here. This decision can be reevaluated, but for now it<br>
> makes everything much<br>
> much simpler.<br>
<br>
For the library to be loaded automatically, you would define a runpath,<br>
perhaps defaulting to<br>
<br>
  $(dirname /path/to/lib/libpetsc.so)/petsc/plugins<br>
<br>
that would be scanned and each shared library in that directory would be<br>
PetscDLLibraryOpen'd?<br>
</blockquote></div><br clear="all"><div>Exactly. And its very easy to override with existing options, so no lockin.</div><div><br></div><div>   Matt</div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>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</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>