summaryrefslogtreecommitdiff
path: root/llvm/lib/Support/DynamicLibrary.cpp
AgeCommit message (Collapse)Author
2025-06-09[Support][Cygwin] Fix handling of Process symbol lookup. (#143072)jeremyd2019
In Unix/DynamicLibrary.inc, it was already known that Cygwin required use of `RTLD_DEFAULT` as the `Handle` parameter to `DLSym` to search all modules for a symbol. Unfortunately, RTLD_DEFAULT is defined as NULL, so the existing checks of the `Process` handle meant `DLSym` would never be called on Cygwin. Use the existing `&Invalid` sentinel instead of `nullptr` for the `Process` handle.
2022-10-03Add functionality to load dynamic libraries temporarilyMichael Holman
Previously, it was possible to load dynamic libraries which would be unloaded on llvm_shutdown(), but recently ManagedStatic removal changed this so that loaded libraries really can't ever be unloaded. This functionality was very useful, and so to add it back in a more explicit way, I've added new getLibrary() and closeLibrary() methods to allow callers to use the very convenient platform independent abstraction that LLVM has for dynamic libraries. As a specific use case, the onnx-mlir project was using this functionality with an API that allows instancing LLVM so you can compile a shared library, and then load that library, and eventually close the instance (and library) and compile something else. This change to llvm_shutdown causes libraries to leak and also locks the libraries for the entire duration of the program which prevents reusing library names. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D134763
2022-08-25ManagedStatic: remove from DynamicLibraryNicolai Hähnle
v2: - fix Windows build issues Differential Revision: https://reviews.llvm.org/D129127
2022-08-03Revert "ManagedStatic: remove from DynamicLibrary"Nicolai Hähnle
This reverts commit 38817af6a7271aee0581c56eaea44b8c4cf5ecc7. Buildbots report a Windows build error. Revert until I can look at it more carefully.
2022-08-03ManagedStatic: remove from DynamicLibraryNicolai Hähnle
Differential Revision: https://reviews.llvm.org/D129127
2022-06-12[Support] Use default member initialization (NFC)Kazu Hirata
Identified with modernize-use-default-member-init.
2022-03-11Cleanup include: TableGenserge-sans-paille
This also includes a few cleanup from Support. Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D121331
2021-07-01[flang] Revert "PoC for Flang Driver Plugins"Andrzej Warzynski
This patch has not been reviewed and was commited by accident. This reverts commit 788a5d4afe6407e647454a9832a7b4a27fba06bf.
2021-07-01PoC for Flang Driver PluginsStuart Ellis
2021-01-28[Support] Add some missing namespace closure comments. NFCI.Simon Pilgrim
Fixes some clang-tidy warnings.
2021-01-19[llvm] Use llvm::find (NFC)Kazu Hirata
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-04-29s/LLVM_ON_WIN32/_WIN32/, llvmNico Weber
LLVM_ON_WIN32 is set exactly with MSVC and MinGW (but not Cygwin) in HandleLLVMOptions.cmake, which is where _WIN32 defined too. Just use the default macro instead of a reinvented one. See thread "Replacing LLVM_ON_WIN32 with just _WIN32" on llvm-dev and cfe-dev. No intended behavior change. This moves over all uses of the macro, but doesn't remove the definition of it in (llvm-)config.h yet. llvm-svn: 331127
2017-07-12Allow clients to specify search order of DynamicLibraries.Frederich Munch
Summary: Different JITs and other clients of LLVM may have different needs in how symbol resolution should occur. Reviewers: v.g.vassilev, lhames, karies Reviewed By: v.g.vassilev Subscribers: pcanal, llvm-commits Differential Revision: https://reviews.llvm.org/D33529 llvm-svn: 307849
2017-05-26Fix the ManagedStatic list ordering when using ↵Frederich Munch
DynamicLibrary::addPermanentLibrary. Summary: r295737 included a fix for leaking libraries loaded via. DynamicLibrary::addPermanentLibrary. This created a problem where static constructors in a library could insert llvm::ManagedStatic objects before DynamicLibrary would register it's own ManagedStatic, meaning a crash could occur at shutdown. r301562 exasperated this problem by cleaning up the DynamicLibrary ManagedStatic during llvm_shutdown. Reviewers: v.g.vassilev, lhames, efriedma Reviewed By: efriedma Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33581 llvm-svn: 304027
2017-04-27Refactor DynamicLibrary so searching for a symbol will have a defined order andFrederich Munch
libraries are properly unloaded when llvm_shutdown is called. Summary: This was mostly affecting usage of the JIT, where storing the library handles in a set made iteration unordered/undefined. This lead to disagreement between the JIT and native code as to what the address and implementation of particularly on Windows with stdlib functions: JIT: putenv_s("TEST", "VALUE") // called msvcrt.dll, putenv_s JIT: getenv("TEST") -> "VALUE" // called msvcrt.dll, getenv Native: getenv("TEST") -> NULL // called ucrt.dll, getenv Also fixed is the issue of DynamicLibrary::getPermanentLibrary(0,0) on Windows not giving priority to the process' symbols as it did on Unix. Reviewers: chapuni, v.g.vassilev, lhames Reviewed By: lhames Subscribers: danalbert, srhines, mgorny, vsk, llvm-commits Differential Revision: https://reviews.llvm.org/D30107 llvm-svn: 301562
2017-04-24Revert "Refactor DynamicLibrary so searching for a symbol will have a ↵Frederich Munch
defined order" The i686-mingw32-RA-on-linux bot is still having errors. This reverts commit r301236. llvm-svn: 301240
2017-04-24Refactor DynamicLibrary so searching for a symbol will have a defined order andFrederich Munch
libraries are properly unloaded when llvm_shutdown is called. Summary: This was mostly affecting usage of the JIT, where storing the library handles in a set made iteration unordered/undefined. This lead to disagreement between the JIT and native code as to what the address and implementation of particularly on Windows with stdlib functions: JIT: putenv_s("TEST", "VALUE") // called msvcrt.dll, putenv_s JIT: getenv("TEST") -> "VALUE" // called msvcrt.dll, getenv Native: getenv("TEST") -> NULL // called ucrt.dll, getenv Also fixed is the issue of DynamicLibrary::getPermanentLibrary(0,0) on Windows not giving priority to the process' symbols as it did on Unix. Reviewers: chapuni, v.g.vassilev, lhames Reviewed By: lhames Subscribers: danalbert, srhines, mgorny, vsk, llvm-commits Differential Revision: https://reviews.llvm.org/D30107 llvm-svn: 301236
2017-04-24Revert "Refactor DynamicLibrary so searching for a symbol will have a ↵Frederich Munch
defined order.” The changes are causing the i686-mingw32 build to fail. This reverts commit r301153, and the changes for a separate warning on i686-mingw32 in r301155 and r301156. llvm-svn: 301157
2017-04-24Fix warning converting from boolean to pointer introduced in r301153.Frederich Munch
This reverts commit r301155, which was incorrect. llvm-svn: 301156
2017-04-24Fix warning converting from void* to boolean introduced in r301153.Frederich Munch
llvm-svn: 301155
2017-04-24Refactor DynamicLibrary so searching for a symbol will have a defined order andFrederich Munch
libraries are properly unloaded when llvm_shutdown is called. Summary: This was mostly affecting usage of the JIT, where storing the library handles in a set made iteration unordered/undefined. This lead to disagreement between the JIT and native code as to what the address and implementation of particularly on Windows with stdlib functions: JIT: putenv_s("TEST", "VALUE") // called msvcrt.dll, putenv_s JIT: getenv("TEST") -> "VALUE" // called msvcrt.dll, getenv Native: getenv("TEST") -> NULL // called ucrt.dll, getenv Also fixed is the issue of DynamicLibrary::getPermanentLibrary(0,0) on Windows not giving priority to the process' symbols as it did on Unix. Reviewers: chapuni, v.g.vassilev, lhames Reviewed By: lhames Subscribers: danalbert, srhines, mgorny, vsk, llvm-commits Differential Revision: https://reviews.llvm.org/D30107 llvm-svn: 301153
2017-04-21[Test commit] Remove extra newline.Frederich Munch
llvm-svn: 301046
2017-03-02Reland r296442 with modifications reverted in r296463.Vassil Vassilev
Original commit message: "Allow externally dlopen-ed libraries to be registered as permanent libraries. This is also useful in cases when llvm is in a shared library. First we dlopen the llvm shared library and then we register it as a permanent library in order to keep the JIT and other services working. Patch reviewed by Vedant Kumar (D29955)!" llvm-svn: 296774
2017-02-28Revert r296442 (and r296443), "Allow externally dlopen-ed libraries to be ↵NAKAMURA Takumi
registered as permanent libraries." It broke clang/test/Analysis/checker-plugins.c llvm-svn: 296463
2017-02-28Allow externally dlopen-ed libraries to be registered as permanent libraries.Vassil Vassilev
This is also useful in cases when llvm is in a shared library. First we dlopen the llvm shared library and then we register it as a permanent library in order to keep the JIT and other services working. Patch reviewed by Vedant Kumar (D29955)! llvm-svn: 296442
2017-02-21Do not leak OpenedHandles.Vassil Vassilev
Reviewed by Vedant Kumar (D30178) llvm-svn: 295737
2016-11-30[Support] Use HAVE_DLOPEN to guard dlopen(3) usagePavel Labath
Summary: The usage was previously guarded by HAVE_DLFCN. This breaks on Android with LLVM_BUILD_STATIC as the platform does not provide a static version of libdl. Using HAVE_DLOPEN fixes it as the code will only get used if we are actually able to link an executable using dlopen. Reviewers: rafael, beanz Subscribers: tberghammer, danalbert, llvm-commits Differential Revision: https://reviews.llvm.org/D26504 llvm-svn: 288246
2015-06-09Add more wrappers for symbol APIs to the C API.Eli Bendersky
This represents some of the functionality we expose in the llvmlite Python binding. Patch by Antoine Pitrou Differential Revision: http://reviews.llvm.org/D10222 llvm-svn: 239411
2014-08-27Revert "Limit the symbol search in DynamicLibrary to the module that was ↵Zachary Turner
opened." This reverts commit r216563, which breaks lli's dynamic symbol resolution. llvm-svn: 216569
2014-08-27Limit the symbol search in DynamicLibrary to the module that was opened.Zachary Turner
Differential Revision: http://reviews.llvm.org/D5030 Reviewed By: Reid Kleckner, Rafael Espindola llvm-svn: 216563
2014-06-20Fix .cpp files claiming to be header filesHans Wennborg
llvm-svn: 211334
2014-04-09[C++11] Replace some comparisons with 'nullptr' with simple boolean checks ↵Craig Topper
to reduce verbosity. llvm-svn: 205829
2014-04-07[C++11] Make use of 'nullptr' in the Support library.Craig Topper
llvm-svn: 205697
2014-01-07Re-sort all of the includes with ./utils/sort_includes.py so thatChandler Carruth
subsequent changes are easier to review. About to fix some layering issues, and wanted to separate out the necessary churn. Also comment and sink the include of "Windows.h" in three .inc files to match the usage in Memory.inc. llvm-svn: 198685
2013-11-13Make sure LLVMLoadLibraryPermanently gets an extern "C" symbol.Benjamin Kramer
Otherwise it's impossible to use it. Also don't include C++ headers in a C header. llvm-svn: 194581
2013-11-06Add newline at EOF in DynamicLibrary.cppPeter Zotov
llvm-svn: 194144
2013-11-06[llvm-c] Specify explicit namespace in LLVMLoadLibraryPermanentlyPeter Zotov
Presence of using namespace llvm depended on several #ifdef's, and this broke the build on mswin32. llvm-svn: 194142
2013-11-06[llvm-c] Expose LLVMLoadLibraryPermanentlyPeter Zotov
Original patch by Chris Wailes llvm-svn: 194139
2013-09-18Make DynamicLibrary use ManagedStatic. This is pretty simple and should just ↵Filip Pizlo
work as advertised - but it does have the caveat that calls to DynamicLibrary::AddSymbol will "reset" if you shutdown llvm and try to come back for seconds. This is a subtle behavior change, but I'm assuming that nobody is affected by it. llvm-svn: 190946
2013-09-18Revert r190921. It broke Windows.Filip Pizlo
I'll roll it back in when I have a chance to look at it in detail. llvm-svn: 190923
2013-09-18Make DynamicLibrary use ManagedStatic. This is pretty simple and should just ↵Filip Pizlo
work as advertised - but it does have the caveat that calls to DynamicLibrary::AddSymbol will "reset" if you shutdown llvm and try to come back for seconds. This is a subtle behavior change, but I'm assuming that nobody is affected by it. llvm-svn: 190921
2013-01-13Remove redundant 'llvm::' qualificationsDmitri Gribenko
llvm-svn: 172358
2012-12-03Use the new script to sort the includes of every file under lib.Chandler Carruth
Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] llvm-svn: 169131
2012-09-04Fix Android build of gtest and lib/Support.Evgeniy Stepanov
llvm-svn: 163131
2011-08-22Make DynamicLibrary thread-safe w/r/t call to dlerror() after dlopen(). PR10718Jordy Rose
llvm-svn: 138260
2011-08-17Static fields require an out-of-line definition. Fix DynamicLibrary for real.Jordy Rose
llvm-svn: 137844
2011-08-17Use DynamicLibrary instances as a way to get symbols from a specific ↵Jordy Rose
library. Preparation for upcoming (preliminary) support for plugins for the static analyzer. llvm-svn: 137791
2010-12-07Don't leak the mutex when loading dynamic libraries.Owen Anderson
llvm-svn: 121119
2010-11-29Merge System into Support.Michael J. Spencer
llvm-svn: 120298