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

tqchen 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 44eda85bf2 [Metal] Fix `GetFunction` of metal runtime (#18034)
44eda85bf2 is described below

commit 44eda85bf28a4feeec449218742edc420b2d4794
Author: Ruihang Lai <[email protected]>
AuthorDate: Tue Jun 3 17:57:49 2025 -0400

    [Metal] Fix `GetFunction` of metal runtime (#18034)
    
    This PR fixes a bug in `MetalModuleNode::GetFunction`.
    
    The lambda passed to autoreleasepool is supposed to return
    nothing. Prior to this PR, it returns a function at an early
    exit branch, which may cause the error of `EXC_BREAKPOINT`
    in Metal.
---
 CMakeLists.txt                    | 1 +
 ffi/cmake/Utils/Library.cmake     | 2 +-
 src/runtime/metal/metal_module.mm | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b45e5becf3..15a2244f81 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -525,6 +525,7 @@ if(BUILD_STATIC_RUNTIME)
   add_library(tvm_runtime STATIC
     $<TARGET_OBJECTS:tvm_runtime_objs>
     $<TARGET_OBJECTS:tvm_libinfo_objs>
+    $<TARGET_OBJECTS:tvm_ffi_objs>
     ${TVM_RUNTIME_EXT_OBJS}
   )
   set(NOTICE_MULTILINE
diff --git a/ffi/cmake/Utils/Library.cmake b/ffi/cmake/Utils/Library.cmake
index f391ee8fd4..cff7ca35a2 100644
--- a/ffi/cmake/Utils/Library.cmake
+++ b/ffi/cmake/Utils/Library.cmake
@@ -16,7 +16,7 @@
 # under the License.
 function(add_dsymutil target_name)
   # running dsymutil on macos to generate debugging symbols for backtraces
-  if(APPLE)
+  if(APPLE AND TVM_FFI_USE_LIBBACKTRACE)
     find_program(DSYMUTIL dsymutil)
     mark_as_advanced(DSYMUTIL)
     add_custom_command(TARGET ${target_name}
diff --git a/src/runtime/metal/metal_module.mm 
b/src/runtime/metal/metal_module.mm
index f7c59156cb..c1a5ccfdd1 100644
--- a/src/runtime/metal/metal_module.mm
+++ b/src/runtime/metal/metal_module.mm
@@ -267,7 +267,7 @@ ffi::Function MetalModuleNode::GetFunction(const String& 
name,
     auto it = fmap_.find(name);
     if (it == fmap_.end()) {
       ret = ffi::Function();
-      return ret;
+      return;
     }
     const FunctionInfo& info = it->second;
     MetalWrappedFunc f;

Reply via email to