[llvm-commits] [PATCH] Look up symbols in a specific library with DynamicLibrary

David Blaikie dblaikie at gmail.com
Wed Aug 10 22:16:29 PDT 2011


Apologies if this is unrelated, but given the topic of permanently
loading  dynamic libraries for use by clang (which itself can be used
as a library, if I'm not mistaken), I thought this might be relevant:

http://msdn.microsoft.com/en-us/library/ms683152(v=vs.85).aspx

"It is not safe to call FreeLibrary from DllMain. For more
information, see the Remarks section in DllMain."

(& DllMain is the entry point where global ctors and global dtors are
run - " Before unloading a library module, the system enables the
module to detach from the process by calling the module's DllMain
function, if it has one, with the DLL_PROCESS_DETACH value.")

So having globally loaded libraries which you'll have to unload in the
global dtor phase when clang's library gets unloaded would be unsafe.

Is this relevant? will you need to design around having another entry
point where things are cleaned up, perhaps?

- David



More information about the llvm-commits mailing list