cyx-6 commented on PR #254:
URL: https://github.com/apache/tvm-ffi/pull/254#issuecomment-4132649650

   > If we load the MSVC CRT into the process, will the COFFPlatform work?
   
   The MSVC CRT DLLs are already loaded in the host process — our 
DLLImportDefinitionGenerator resolves symbols from vcruntime140, ucrtbase, 
msvcp140, etc. The problem is that COFFPlatform requires a COFF ORC runtime 
library (orc_rt) to be built and loaded. Looking at the LLVM source, 
COFFPlatform needs to resolve ~10 runtime entry points like 
`__orc_rt_coff_platform_bootstrap`, `__orc_rt_coff_register_jitdylib`, 
`__orc_rt_coff_register_object_sections`, etc. It also aliases 
`_CxxThrowException` -> `__orc_rt_coff_cxx_throw_exception`
   
   The COFF ORC runtime does exist in compiler-rt, and it implements 
`__orc_rt_coff_cxx_throw_exception` — but with a big caveat: cross-module 
exception throwing is unfinished. So even if we build and load the COFF orc_rt, 
exception handling between host code and JIT code would abort(). The LLVM test 
suite does include COFF ORC tests (e.g., sehframe-handling.cpp, hello-world.cpp 
in compiler-rt/test/orc/TestCases/Windows/x86-64/), but these require a fully 
functional COFF runtime which hasn't been completed.
   
   In principle, if someone completes the COFF ORC runtime (especially the 
exception interop), COFFPlatform could work. But that's been stalled for 2+ 
years in LLVM. Our current approach (`InitFiniPlugin` + 
`DLLImportDefinitionGenerator`) gives us working C support without depending on 
the incomplete runtime.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to