This is an automated email from the ASF dual-hosted git repository.

mshr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 485a309dcd [FFI] Fix system library symbol lookup (#18298)
485a309dcd is described below

commit 485a309dcdd9044d252b52aee81c07fa1c62dfa7
Author: Ruihang Lai <[email protected]>
AuthorDate: Wed Sep 10 00:29:02 2025 -0400

    [FFI] Fix system library symbol lookup (#18298)
---
 ffi/src/ffi/extra/library_module_system_lib.cc | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/ffi/src/ffi/extra/library_module_system_lib.cc 
b/ffi/src/ffi/extra/library_module_system_lib.cc
index e93c6602c2..9d077fec33 100644
--- a/ffi/src/ffi/extra/library_module_system_lib.cc
+++ b/ffi/src/ffi/extra/library_module_system_lib.cc
@@ -69,12 +69,25 @@ class SystemLibrary final : public Library {
   explicit SystemLibrary(const String& symbol_prefix) : 
symbol_prefix_(symbol_prefix) {}
 
   void* GetSymbol(const String& name) final {
+    // The `name` might or might not already contain the symbol prefix.
+    // Therefore, we check both with and without the prefix.
     String name_with_prefix = symbol_prefix_ + name;
-    return reg_->GetSymbol(name_with_prefix);
+    void* symbol = reg_->GetSymbol(name_with_prefix);
+    if (symbol != nullptr) {
+      return symbol;
+    }
+    return reg_->GetSymbol(name);
   }
 
   void* GetSymbolWithSymbolPrefix(const String& name) final {
+    // The `name` might or might not already contain the symbol prefix.
+    // Therefore, we check both with and without the prefix.
     String name_with_prefix = symbol::tvm_ffi_symbol_prefix + symbol_prefix_ + 
name;
+    void* symbol = reg_->GetSymbol(name_with_prefix);
+    if (symbol != nullptr) {
+      return symbol;
+    }
+    name_with_prefix = symbol::tvm_ffi_symbol_prefix + name;
     return reg_->GetSymbol(name_with_prefix);
   }
 

Reply via email to