Error in build using AOT

Hi @manupa-arm, @areusch,

I was trying to generate build (AOT enabled) as follows:

    def _make_session(temp_dir, zephyr_board, west_cmd, mod):
        config_main_stack_size = None

        project_options = {
            "project_type": "host_driven",
            "west_cmd": west_cmd,
            "verbose": False,
            "zephyr_board": zephyr_board,
        }
        if config_main_stack_size is not None:
            project_options["config_main_stack_size"] = config_main_stack_size

        project = tvm.micro.generate_project(
            temp_dir,
            mod,
            temp_dir + "/project",
            project_options,
        )
        project.build()
        project.flash()
        return tvm.micro.Session(project.transport())

    TARGET = tvm.target.target.micro("stm32f746xx") # Specifying target hardware architecture
    BOARD = "nucleo_f746zg" # Specifying exact board name, used by zephyr later to create binary

    repo_root = subprocess.check_output(["git", "rev-parse", "--show-toplevel"], encoding='utf-8').strip()
    project_dir = os.path.join(repo_root, "apps", "microtvm", "zephyr", "template_project")
    temp_file_directory = repo_root

    def build_flash(mod,TARGET,params,input_mcu,node,iteration):
         RUNTIME = Runtime(“crt”, {“system-lib”: True})
         EXECUTOR = Executor("aot")
         with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
             c_mod = relay.build(mod, target=TARGET, executor=EXECUTOR, runtime=RUNTIME, params=params)
         with _make_session(project_dir, BOARD, "west", c_mod) as session:
            graph_mod = tvm.micro.create_local_debug_executor(graph, session.get_system_lib(), session.device, dump_root= temp_file_directory)
            graph_mod.set_input(**c_mod.get_params())    
            graph_mod.run() 
            tvm_output = graph_mod.get_output(0).asnumpy()

But the build throws following error:

warning: TEST_RANDOM_GENERATOR (defined at subsys/random/Kconfig:8) was assigned the value 'y' but
got the value 'n'. Check these unsatisfied dependencies: (!ENTROPY_HAS_DRIVER) (=n). See
http://docs.zephyrproject.org/latest/reference/kconfig/CONFIG_TEST_RANDOM_GENERATOR.html and/or look
up TEST_RANDOM_GENERATOR in the menuconfig/guiconfig interface. The Application Development Primer,
Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
helpful too.

-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/vagrant/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
CMake Deprecation Warning at /home/vagrant/zephyr/modules/lib/civetweb/CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Configuring done
-- Generating done
-- Build files have been written to: /home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/build
INFO:__main__:run (in cwd: /home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/build): make -j2
[  1%] Generating misc/generated/syscalls.json, misc/generated/struct_tags.json
[  2%] Built target parse_syscalls_target
[  2%] Generating include/generated/kobj-types-enum.h, include/generated/otype-to-str.h
[  3%] Generating include/generated/syscall_dispatch.c, include/generated/syscall_list.h
[  3%] Built target syscall_list_h_target
[  3%] Built target kobj_types_h_target
[  4%] Generating include/generated/driver-validation.h
[  4%] Built target driver_validation_h_target
[  5%] Building C object zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj
[  5%] Building CXX object CMakeFiles/microtvm_rpc_server.dir/crt/src/runtime/crt/microtvm_rpc_server/rpc_server.cc.obj
[  6%] Linking CXX static library libmicrotvm_rpc_server.a
[  6%] Built target microtvm_rpc_server
[  7%] Building C object CMakeFiles/microtvm_rpc_common.dir/crt/src/runtime/crt/microtvm_rpc_common/crcccitt.c.obj
[  7%] Building CXX object CMakeFiles/microtvm_rpc_common.dir/crt/src/runtime/crt/microtvm_rpc_common/frame_buffer.cc.obj
[  8%] Building CXX object CMakeFiles/microtvm_rpc_common.dir/crt/src/runtime/crt/microtvm_rpc_common/framing.cc.obj
[  9%] Building CXX object CMakeFiles/microtvm_rpc_common.dir/crt/src/runtime/crt/microtvm_rpc_common/session.cc.obj
[  9%] Building CXX object CMakeFiles/microtvm_rpc_common.dir/crt/src/runtime/crt/microtvm_rpc_common/write_stream.cc.obj
[ 10%] Linking CXX static library libmicrotvm_rpc_common.a
[ 10%] Built target microtvm_rpc_common
[ 11%] Building C object CMakeFiles/common.dir/crt/src/runtime/crt/common/crt_backend_api.c.obj
[ 11%] Building C object CMakeFiles/common.dir/crt/src/runtime/crt/common/crt_runtime_api.c.obj
[ 12%] Building C object CMakeFiles/common.dir/crt/src/runtime/crt/common/func_registry.c.obj
[ 12%] Building C object CMakeFiles/common.dir/crt/src/runtime/crt/common/ndarray.c.obj
[ 13%] Building C object CMakeFiles/common.dir/crt/src/runtime/crt/common/packed_func.c.obj
[ 14%] Linking C static library libcommon.a
[ 14%] Built target offsets
[ 14%] Building C object CMakeFiles/tvm_model.dir/model/codegen/host/src/default_lib0.c.obj
[ 14%] Built target common
[ 15%] Building C object CMakeFiles/tvm_model.dir/model/codegen/host/src/default_lib1.c.obj
CMakeFiles/tvm_model.dir/build.make:75: recipe for target 'CMakeFiles/tvm_model.dir/model/codegen/host/src/default_lib0.c.obj' failed
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib0.c:87:17: error: conflicting types for 'tvmgen_default_run_model'
   87 | TVM_DLL int32_t tvmgen_default_run_model(void* args, void* type_code, int num_args, void* out_value, void* out_type_code, void* resource_handle);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib0.c:57:17: note: previous declaration of 'tvmgen_default_run_model' was here
   57 | TVM_DLL int32_t tvmgen_default_run_model(TVMValue* args, int* type_code, int num_args, TVMValue* out_value, int* out_type_code);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/tvm_model.dir/model/codegen/host/src/default_lib0.c.obj] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 15%] Generating include/generated/offsets.h
[ 15%] Built target offsets_h
[ 15%] Built target zephyr_generated_headers
[ 15%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf.c.obj
[ 16%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc32_sw.c.obj
[ 17%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc16_sw.c.obj
[ 17%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc8_sw.c.obj
[ 18%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc7_sw.c.obj
[ 18%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/dec.c.obj
[ 19%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/fdtable.c.obj
[ 20%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/hex.c.obj
[ 20%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/notify.c.obj
[ 21%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/printk.c.obj
[ 22%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/onoff.c.obj
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c: In function 'tvmgen_default_run_model':
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:1999:42: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 1999 |   (((DLTensor*)tvm_value_8)[0].data) = (*(void* *)(&(_1)));
      |                                          ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2053:39: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2053 |   (((DLTensor*)tvm_value_17)[0].data) = __tvm_param__p0;
      |                                       ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2056:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2056 |   (((DLTensor*)tvm_value_19)[0].data) = (*(void* *)(&(_2)));
      |                                           ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2093:39: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2093 |   (((DLTensor*)tvm_value_21)[0].data) = __tvm_param__p1;
      |                                       ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2094:39: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2094 |   (((DLTensor*)tvm_value_22)[0].data) = __tvm_param__p2;
      |                                       ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2097:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2097 |   (((DLTensor*)tvm_value_24)[0].data) = (*(void* *)(&(_3)));
      |                                           ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2129:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2129 |   (((DLTensor*)tvm_value_30)[0].data) = (*(void* *)(&(_4)));
      |                                           ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2163:39: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2163 |   (((DLTensor*)tvm_value_35)[0].data) = __tvm_param__p3;
      |                                       ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2166:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2166 |   (((DLTensor*)tvm_value_37)[0].data) = (*(void* *)(&(_5)));
      |                                           ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2229:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2229 |   (((DLTensor*)tvm_value_52)[0].data) = (*(void* *)(&(_6)));
      |                                           ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2274:39: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2274 |   (((DLTensor*)tvm_value_54)[0].data) = __tvm_param__p4;
      |                                       ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2275:39: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2275 |   (((DLTensor*)tvm_value_55)[0].data) = __tvm_param__p5;
      |                                       ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2278:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2278 |   (((DLTensor*)tvm_value_57)[0].data) = (*(void* *)(&(_7)));
      |                                           ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2310:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2310 |   (((DLTensor*)tvm_value_63)[0].data) = (*(void* *)(&(_8)));
      |                                           ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2347:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2347 |   (((DLTensor*)tvm_value_70)[0].data) = (*(void* *)(&(_9)));
      |                                           ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2410:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2410 |   (((DLTensor*)tvm_value_85)[0].data) = (*(void* *)(&(_10)));
      |                                           ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2455:39: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2455 |   (((DLTensor*)tvm_value_87)[0].data) = __tvm_param__p6;
      |                                       ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2456:39: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2456 |   (((DLTensor*)tvm_value_88)[0].data) = __tvm_param__p7;
      |                                       ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2459:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2459 |   (((DLTensor*)tvm_value_90)[0].data) = (*(void* *)(&(_11)));
      |                                           ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2491:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2491 |   (((DLTensor*)tvm_value_96)[0].data) = (*(void* *)(&(_12)));
      |                                           ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2528:44: warning: dereferencing type-punned pointer will break striCMakeFiles/Makefile2:2239: recipe for target 'CMakeFiles/tvm_model.dir/all' failed
ct-aliasing rules [-Wstrict-aliasing]
 2528 |   (((DLTensor*)tvm_value_103)[0].data) = (*(void* *)(&(_13)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2591:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2591 |   (((DLTensor*)tvm_value_118)[0].data) = (*(void* *)(&(_14)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2636:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2636 |   (((DLTensor*)tvm_value_120)[0].data) = __tvm_param__p8;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2637:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2637 |   (((DLTensor*)tvm_value_121)[0].data) = __tvm_param__p9;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2640:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2640 |   (((DLTensor*)tvm_value_123)[0].data) = (*(void* *)(&(_15)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2672:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2672 |   (((DLTensor*)tvm_value_129)[0].data) = (*(void* *)(&(_16)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2709:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2709 |   (((DLTensor*)tvm_value_136)[0].data) = (*(void* *)(&(_17)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2772:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2772 |   (((DLTensor*)tvm_value_151)[0].data) = (*(void* *)(&(_18)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2817:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2817 |   (((DLTensor*)tvm_value_153)[0].data) = __tvm_param__p10;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2818:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2818 |   (((DLTensor*)tvm_value_154)[0].data) = __tvm_param__p11;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2821:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2821 |   (((DLTensor*)tvm_value_156)[0].data) = (*(void* *)(&(_19)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2853:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2853 |   (((DLTensor*)tvm_value_162)[0].data) = (*(void* *)(&(_20)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2890:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2890 |   (((DLTensor*)tvm_value_169)[0].data) = (*(void* *)(&(_21)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2953:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2953 |   (((DLTensor*)tvm_value_184)[0].data) = (*(void* *)(&(_22)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2998:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2998 |   (((DLTensor*)tvm_value_186)[0].data) = __tvm_param__p12;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2999:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2999 |   (((DLTensor*)tvm_value_187)[0].data) = __tvm_param__p13;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3002:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3002 |   (((DLTensor*)tvm_value_189)[0].data) = (*(void* *)(&(_23)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3034:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3034 |   (((DLTensor*)tvm_value_195)[0].data) = (*(void* *)(&(_24)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3071:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3071 |   (((DLTensor*)tvm_value_202)[0].data) = (*(void* *)(&(_25)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3134:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3134 |   (((DLTensor*)tvm_value_217)[0].data) = (*(void* *)(&(_26)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3179:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 3179 |   (((DLTensor*)tvm_value_219)[0].data) = __tvm_param__p14;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3180:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 3180 |   (((DLTensor*)tvm_value_220)[0].data) = __tvm_param__p15;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3183:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3183 |   (((DLTensor*)tvm_value_222)[0].data) = (*(void* *)(&(_27)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3215:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3215 |   (((DLTensor*)tvm_value_228)[0].data) = (*(void* *)(&(_28)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3252:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3252 |   (((DLTensor*)tvm_value_235)[0].data) = (*(void* *)(&(_29)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3315:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3315 |   (((DLTensor*)tvm_value_250)[0].data) = (*(void* *)(&(_30)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3360:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 3360 |   (((DLTensor*)tvm_value_252)[0].data) = __tvm_param__p16;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3361:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 3361 |   (((DLTensor*)tvm_value_253)[0].data) = __tvm_param__p17;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3364:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3364 |   (((DLTensor*)tvm_value_255)[0].data) = (*(void* *)(&(_31)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3387:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3387 |   (((DLTensor*)tvm_value_258)[0].data) = (*(void* *)(&(_32)));
      |                                            ^~~~~~~~~~~~~~~~~
make[1]: *** [CMakeFiles/tvm_model.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 22%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/rb.c.obj
[ 23%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/sem.c.obj
[ 24%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/thread_entry.c.obj
[ 24%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/timeutil.c.obj
[ 25%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/work_q.c.obj
[ 26%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/heap.c.obj
[ 26%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/heap-validate.c.obj
[ 27%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_complete.c.obj
[ 28%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/ring_buffer.c.obj
[ 28%] Building C object zephyr/CMakeFiles/zephyr.dir/misc/generated/configs.c.obj
[ 29%] Building C object zephyr/CMakeFiles/zephyr.dir/soc/arm/st_stm32/stm32f7/soc.c.obj
[ 30%] Building C object zephyr/CMakeFiles/zephyr.dir/soc/arm/st_stm32/common/stm32cube_hal.c.obj
[ 30%] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/cpp/cpp_init_array.c.obj
[ 31%] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/cpp/cpp_ctors.c.obj
[ 31%] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/cpp/cpp_dtors.c.obj
[ 32%] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/cpp/cpp_virtual.c.obj
[ 33%] Building CXX object zephyr/CMakeFiles/zephyr.dir/subsys/cpp/cpp_vtable.cpp.obj
[ 33%] Building CXX object zephyr/CMakeFiles/zephyr.dir/subsys/cpp/cpp_new.cpp.obj
[ 34%] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/power/reboot.c.obj
[ 35%] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/interrupt_controller/intc_exti_stm32.c.obj
[ 35%] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/clock_control/clock_stm32_ll_common.c.obj
[ 36%] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/clock_control/clock_stm32f2_f4_f7.c.obj
[ 37%] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/pinmux/stm32/pinmux_stm32.c.obj
[ 37%] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/timer/sys_clock_init.c.obj
[ 38%] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/timer/cortex_m_systick.c.obj
[ 39%] Linking CXX static library libzephyr.a
[     39%] Built target zephyr
    > make: *** [all] Error 2
    > Makefile:90: recipe for target 'all' failed

Do you know what might be the issue?

There is no build and flashing error when AOT compilation is not enabled:

c_mod = relay.build(mod, target=TARGET, runtime=RUNTIME, params=params)

hmmm, this might be a regression related to https://github.com/apache/tvm/pull/9501, though i think we should be testing this use case. which git revision are you using?

cc @mousius, i will try to repro next week when I get some spare cycles.

I am using version = “0.9.dev0”

@asnecemnnit I think that’s the unreleased version–do you mind telling me what git rev-parse HEAD says (or if that’s not a commit on main, perhaps git merge-base origin/main HEAD)?

@areusch thanks for the quick reply :). git rev-parse HEAD says d3a83b5d01384c898bfc0f54b08bd2235ad63e9c

Hi @asnecemnnit

I’ve just had a look through this, and it looks like there’s an incompatibility between the options you’ve specified:

AOT doesn’t use the system-lib and it creates a conflict if you have both the AOT signature and the system library (previous issue raised around this).

@asnecemnnit could you try removing {"system-lib": True} and see if that works?

@areusch, I think crt + graph = system lib but not cpp + graph, so we can’t easily default this right now?

Hi @Mousius,

As per your suggestion I replaced

RUNTIME = Runtime(“crt”, {“system-lib”: True})

by

RUNTIME = Runtime(“crt”)

Now I am getting following error during linking:

[ 97%] Linking CXX executable zephyr_prebuilt.elf
/home/vagrant/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.2.0/../../../../arm-zephyr-eabi/bin/ld: ../libcommon.a(crt_runtime_api.c.obj): in function `SystemLibraryCreate':
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/crt/src/runtime/crt/common/crt_runtime_api.c:210: undefined reference to `TVMSystemLibEntryPoint'
collect2: error: ld returned 1 exit status
make[2]: *** [zephyr/zephyr_prebuilt.elf] Error 1
make[1]: *** [zephyr/CMakeFiles/zephyr_prebuilt.dir/all] Error 2
make: *** [all] Error 2
zephyr/CMakeFiles/zephyr_prebuilt.dir/build.make:119: recipe for target 'zephyr/zephyr_prebuilt.elf' failed
CMakeFiles/Makefile2:2528: recipe for target 'zephyr/CMakeFiles/zephyr_prebuilt.dir/all' failed
Makefile:90: recipe for target 'all' failed

@asnecemnnit sorry I missed this reply. I see what’s up now–you’re trying to do something unsupported right now. Specifically, you can’t use AOT with host_driven (e.g. RPC-based) projects right now. PR 9697 lays the foundation for fixing this. We had an internal tracking issue for this, but I’ve now posted a public issue as part of the microTVM roadmap which just launched a few days ago.