I'm studying apps/bundle_deploy example code which runs on crt runtime. This 
function was called at the beginning to pre-load all operator functions:

```
// src/runtime/crt/crt_backend_api.c:
int TVMBackendRegisterSystemLibSymbol(const char* name, void* ptr) {
  g_fexecs = vrealloc(g_fexecs, sizeof(TVMPackedFunc) * (g_fexecs_count + 1));
  snprintf(g_fexecs[g_fexecs_count].name, 
sizeof(g_fexecs[g_fexecs_count].name), "%s", name);
  g_fexecs[g_fexecs_count].fexec = ptr;
  g_fexecs_count++;
  return 0;
}
```

However, I cannot find where this function was called by browsing source code. 
A brutal grep search indicates this one might be built within llvm host-side.

```
$ grep -R SystemLibSymbol *
Binary file apps/bundle_deploy/build/demo_static matches
Binary file apps/bundle_deploy/build/model.o matches
Binary file apps/bundle_deploy/build/bundle_static.o matches
Binary file apps/bundle_deploy/build/bundle.so matches
Binary file build/libtvm.so matches
Binary file build/libtvm_runtime.so matches
Binary file build/CMakeFiles/tvm.dir/src/target/llvm/codegen_cpu.cc.o matches
Binary file build/CMakeFiles/tvm.dir/src/target/llvm/codegen_blob.cc.o matches
Binary file build/CMakeFiles/tvm.dir/src/target/codegen.cc.o matches
Binary file build/CMakeFiles/tvm.dir/src/runtime/system_library.cc.o matches
Binary file build/CMakeFiles/tvm_runtime.dir/src/runtime/system_library.cc.o 
matches
include/tvm/runtime/c_backend_api.h:TVM_DLL int 
TVMBackendRegisterSystemLibSymbol(const char* name, void* ptr);
rust/runtime/src/module/syslib.rs:pub extern "C" fn 
TVMBackendRegisterSystemLibSymbol(
src/target/llvm/codegen_blob.cc:    // Create TVMBackendRegisterSystemLibSymbol 
function
src/target/llvm/codegen_blob.cc:                               
llvm::Twine("TVMBackendRegisterSystemLibSymbol"), module.get());
src/target/llvm/codegen_cpu.cc:        llvm::Function::ExternalLinkage, 
"TVMBackendRegisterSystemLibSymbol", module_.get());
src/target/codegen.cc:    os << "extern int 
TVMBackendRegisterSystemLibSymbol(const char*, void*);\n";
src/target/codegen.cc:       << "TVMBackendRegisterSystemLibSymbol(\"" << 
runtime::symbol::tvm_dev_mblob << "\", (void*)"
src/runtime/system_library.cc:int TVMBackendRegisterSystemLibSymbol(const char* 
name, void* ptr) {
src/runtime/crt/crt_backend_api.c:int TVMBackendRegisterSystemLibSymbol(const 
char* name, void* ptr) {

```

Gdb calling stack shows it was called by __tvm_module_startup:
```
TVMBackendRegisterSystemLibSymbol(const char * ....)
__tvm_module_startup
__libc_csu_init
libc.so.6!__libc_start_main(int (*)(int, char...)
_start
```

Can anyone help point out how is __tvm_module_startup being invoked in source 
code or linker script somewhere?





---
[Visit 
Topic](https://discuss.tvm.ai/t/how-is-tvm-module-startup-invoked/6891/1) to 
respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click 
here](https://discuss.tvm.ai/email/unsubscribe/5df7375045bead9d7a5b2fd6778c202dd5ff70de3b50e543d0d733bb2d5f6215).

Reply via email to