diff options
author | Ye Luo <yeluo@anl.gov> | 2024-03-27 18:40:57 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-27 18:40:57 -0500 |
commit | 19185d5a72565fce34521cb59d6c87232a86e0d4 (patch) | |
tree | 3b38a4b792a56cd0999ae79f01226d42c2d6611f | |
parent | 385e3e26c11fac9373bf7ba431b90b6f42682c84 (diff) | |
download | llvm-19185d5a72565fce34521cb59d6c87232a86e0d4.zip llvm-19185d5a72565fce34521cb59d6c87232a86e0d4.tar.gz llvm-19185d5a72565fce34521cb59d6c87232a86e0d4.tar.bz2 |
[Libomptarget] Make dynamic loading libffi more verbose. (#86891)
-rw-r--r-- | openmp/libomptarget/plugins-nextgen/host/dynamic_ffi/ffi.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/openmp/libomptarget/plugins-nextgen/host/dynamic_ffi/ffi.cpp b/openmp/libomptarget/plugins-nextgen/host/dynamic_ffi/ffi.cpp index c79daa7..c586ad1 100644 --- a/openmp/libomptarget/plugins-nextgen/host/dynamic_ffi/ffi.cpp +++ b/openmp/libomptarget/plugins-nextgen/host/dynamic_ffi/ffi.cpp @@ -11,6 +11,8 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/DynamicLibrary.h" + +#include "Shared/Debug.h" #include <memory> #include "DLWrap.h" @@ -37,15 +39,21 @@ uint32_t ffi_init() { std::string ErrMsg; auto DynlibHandle = std::make_unique<llvm::sys::DynamicLibrary>( llvm::sys::DynamicLibrary::getPermanentLibrary(FFI_PATH, &ErrMsg)); - if (!DynlibHandle->isValid()) + + if (!DynlibHandle->isValid()) { + DP("Unable to load library '%s': %s!\n", FFI_PATH, ErrMsg.c_str()); return DYNAMIC_FFI_FAIL; + } for (size_t I = 0; I < dlwrap::size(); I++) { const char *Sym = dlwrap::symbol(I); void *P = DynlibHandle->getAddressOfSymbol(Sym); - if (P == nullptr) + if (P == nullptr) { + DP("Unable to find '%s' in '%s'!\n", Sym, FFI_PATH); return DYNAMIC_FFI_FAIL; + } + DP("Implementing %s with dlsym(%s) -> %p\n", Sym, Sym, P); *dlwrap::pointer(I) = P; } @@ -53,8 +61,10 @@ uint32_t ffi_init() { #define DYNAMIC_INIT(SYMBOL) \ { \ void *SymbolPtr = DynlibHandle->getAddressOfSymbol(#SYMBOL); \ - if (!SymbolPtr) \ + if (!SymbolPtr) { \ + DP("Unable to find '%s' in '%s'!\n", #SYMBOL, FFI_PATH); \ return DYNAMIC_FFI_FAIL; \ + } \ SYMBOL = *reinterpret_cast<decltype(SYMBOL) *>(SymbolPtr); \ } DYNAMIC_INIT(ffi_type_void); |