[Mlir-commits] [mlir] c86c96a - [mlir] Load dynamic libraries in JitRunner from absolute paths so that GDB can find the symbol tables.

Christian Sigg llvmlistbot at llvm.org
Thu Feb 18 22:33:47 PST 2021


Author: Christian Sigg
Date: 2021-02-19T07:33:35+01:00
New Revision: c86c96a710720296b6e904170f0e157d3c7dcc84

URL: https://github.com/llvm/llvm-project/commit/c86c96a710720296b6e904170f0e157d3c7dcc84
DIFF: https://github.com/llvm/llvm-project/commit/c86c96a710720296b6e904170f0e157d3c7dcc84.diff

LOG: [mlir] Load dynamic libraries in JitRunner from absolute paths so that GDB can find the symbol tables.

Reviewed By: mehdi_amini, ftynse

Differential Revision: https://reviews.llvm.org/D96759

Added: 
    

Modified: 
    mlir/lib/ExecutionEngine/JitRunner.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/ExecutionEngine/JitRunner.cpp b/mlir/lib/ExecutionEngine/JitRunner.cpp
index 9c67f27ccb22..cf32c083b050 100644
--- a/mlir/lib/ExecutionEngine/JitRunner.cpp
+++ b/mlir/lib/ExecutionEngine/JitRunner.cpp
@@ -158,8 +158,16 @@ static Error compileAndExecute(Options &options, ModuleOp module,
   // If shared library implements custom mlir-runner library init and destroy
   // functions, we'll use them to register the library with the execution
   // engine. Otherwise we'll pass library directly to the execution engine.
-  SmallVector<StringRef, 4> libs(options.clSharedLibs.begin(),
-                                 options.clSharedLibs.end());
+  SmallVector<SmallString<256>, 4> libPaths;
+
+  // Use absolute library path so that gdb can find the symbol table.
+  transform(
+      options.clSharedLibs, std::back_inserter(libPaths),
+      [](std::string libPath) {
+        SmallString<256> absPath(libPath.begin(), libPath.end());
+        cantFail(llvm::errorCodeToError(llvm::sys::fs::make_absolute(absPath)));
+        return absPath;
+      });
 
   // Libraries that we'll pass to the ExecutionEngine for loading.
   SmallVector<StringRef, 4> executionEngineLibs;
@@ -171,8 +179,8 @@ static Error compileAndExecute(Options &options, ModuleOp module,
   SmallVector<MlirRunnerDestroyFn> destroyFns;
 
   // Handle libraries that do support mlir-runner init/destroy callbacks.
-  for (auto libPath : libs) {
-    auto lib = llvm::sys::DynamicLibrary::getPermanentLibrary(libPath.data());
+  for (auto &libPath : libPaths) {
+    auto lib = llvm::sys::DynamicLibrary::getPermanentLibrary(libPath.c_str());
     void *initSym = lib.getAddressOfSymbol("__mlir_runner_init");
     void *destroySim = lib.getAddressOfSymbol("__mlir_runner_destroy");
 


        


More information about the Mlir-commits mailing list