Hi,
I have been trying to use the new ORC jit to execute a c function using c++ that was compiled to llvm bytecode (clang++.exe -c -g -emit-llvm -std=c++2a -o CxxJit.bc CxxJit.cpp).
I guess the first thing I need to say is that I am on windows, this could explain why I have those issues.
The file to jit is this:
#include “CxxJit.h”
#include <stdio.h>
#include
extern “C”
{
void doWork()
{
std::vector<int32_t> vec(10000);
printf(“doWork() = %d \n”, 12);
}
}
Now If I only have the printf everything works but when I try to create a std::vector It fails to lookup the symbol. In the error stream I have one symbol not found and a bunch of symbol that failed to materialize.
JIT session error: Symbols not found: { ??3@YAXPEAX_K@Z }
Failed to materialize symbols: { ??0?$vector@HV?$allocator@H@std@@@std@@QEAA@_KAEBV?$allocator@H@1@@Z, doWork, ?_Myfirst@?$vector@HV?$allocator@H@std@@@std@@AEAAAEAPEAHXZ, ??$forward@AEBV?$allocator@H@std@@@std@@YAAEBV?$allocator@H@0@AEBV10@@Z, ?_Get_second@?$_Compressed_pair@V?$allocator@H@std@@V?$_Vector_val@U?$_Simple_types@H@std@@@2@$00@std@@QEAAAEAV?$_Vector_val@U?$_Simple_types@H@std@@@2@XZ, ?_Tidy@?$vector@HV?$allocator@H@std@@@std@@AEAAXXZ, ?_Orphan_all@_Container_base0@std@@QEAAXXZ, ??1?$vector@HV?$allocator@H@std@@@std@@QEAA@XZ, ??$?0AEBV?$allocator@H@std@@$$V@?$_Compressed_pair@V?$allocator@H@std@@V?$_Vector_val@U?$_Simple_types@H@std@@@2@$00@std@@QEAA@U_One_then_variadic_args_t@1@AEBV?$allocator@H@1@@Z, ?_Release@_Fake_proxy_ptr_impl@std@@QEAAXXZ, ??0?$allocator@H@std@@QEAA@XZ, ?_Getal@?$vector@HV?$allocator@H@std@@@std@@AEAAAEAV?$allocator@H@2@XZ, ??$_Allocate@$0BA@U_Default_allocate_traits@std@@$0A@@std@@YAPEAX_K@Z, ?_Allocate@_Default_allocate_traits@std@@SAPEAX_K@Z, ??_C@_0BD@OLBABOEK@vector?$DMT?$DO?5too?5long?$AA@, ??1?$_Tidy_guard@V?$vector@HV?$allocator@H@std@@@std@@@std@@QEAA@XZ, ?_Destroy@?$vector@HV?$allocator@H@std@@@std@@AEAAXPEAH0@Z, ?_Getal@?$vector@HV?$allocator@H@std@@@std@@AEBAAEBV?$allocator@H@2@XZ, main, ??$_Construct_n_copies_of_ty@U_Value_init_tag@std@@@?$vector@HV?$allocator@H@std@@@std@@AEAAX_KAEBU_Value_init_tag@1@@Z, ??0_Fake_proxy_ptr_impl@std@@QEAA@AEBU_Fake_allocator@1@AEBU_Container_base0@1@@Z, ?_Buy_nonzero@?$vector@HV?$allocator@H@std@@@std@@AEAAX_K@Z, ?_Orphan_all@?$vector@HV?$allocator@H@std@@@std@@AEAAXXZ, ??$_Allocate_manually_vector_aligned@U_Default_allocate_traits@std@@@std@@YAPEAX_K@Z, ?_Mylast@?$vector@HV?$allocator@H@std@@@std@@AEAAAEAPEAHXZ, ?max_size@?$vector@HV?$allocator@H@std@@@std@@QEBA_KXZ, ??$_Zero_range@PEAH@std@@YAPEAHQEAH0@Z, ?max_size@?$_Default_allocator_traits@V?$allocator@H@std@@@std@@SA_KAEBV?$allocator@H@2@@Z, ?_Adjust_manually_vector_aligned@std@@YAXAEAPEAXAEA_K@Z, ?deallocate@?$allocator@H@std@@QEAAXQEAH_K@Z, ?max@?$numeric_limits@_J@std@@SA_JXZ, ??$_Uninitialized_value_construct_n@PEAH_KV?$allocator@H@std@@@std@@YAPEAHPEAH_KAEAV?$allocator@H@0@@Z, ??$_Destroy_range@V?$allocator@H@std@@@std@@YAXPEAH0AEAV?$allocator@H@0@@Z, ?_Get_data@?$vector@HV?$allocator@H@std@@@std@@AEAAAEAV?$_Vector_val@U?$_Simple_types@H@std@@@2@XZ, ?_Get_first@?$_Compressed_pair@V?$allocator@H@std@@V?$_Vector_val@U?$_Simple_types@H@std@@@2@$00@std@@QEAAAEAV?$allocator@H@2@XZ, ??$_Min_value@_K@std@@YAAEB_KAEB_K0@Z, ??$_Get_size_of_n@$03@std@@YA_K_K@Z, ?_Ufill@?$vector@HV?$allocator@H@std@@@std@@AEAAPEAHPEAH_KU_Value_init_tag@2@@Z, ??$_Uninitialized_value_construct_n1@PEAH_KV?$allocator@H@std@@@std@@YAPEAHPEAH_KAEAV?$allocator@H@0@U?$integral_constant@_N$00@0@@Z, ??0?$_Vector_val@U?$_Simple_types@H@std@@@std@@QEAA@XZ, ?_Buy_raw@?$vector@HV?$allocator@H@std@@@std@@AEAAX_K@Z, ?allocate@?$allocator@H@std@@QEAAPEAH_K@Z, ?_Get_first@?$_Compressed_pair@V?$allocator@H@std@@V?$_Vector_val@U?$_Simple_types@H@std@@@2@$00@std@@QEBAAEBV?$allocator@H@2@XZ, ??$_Deallocate@$0BA@$0A@@std@@YAXPEAX_K@Z, ?_Xlength@?$vector@HV?$allocator@H@std@@@std@@CAXXZ }
You can see the code that I am using here:
https://gist.github.com/monamimani/1d8c5287eeaf83d5a6f619699d0c52c4
There is a bunch of reason I can imagine why this would happen:
- The symbol are not there, I recently discover this llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr); but it doesn’t change anything.,
- I am using this helper class http://llvm.org/doxygen/classllvm_1_1orc_1_1LLJIT.html, maybe the setup is not complet. I tried to compare with the example https://llvm.org/docs/tutorial/BuildingAJIT1.html, maybe I missed something.
- The other thing I am considering is that llvm::orc::RTDyldObjectLinkingLayer is not working on windows and I would need to use llvm::orc::LegacyRTDyldObjectLinkingLayer ( because of the bool ExportedSymbolsOnly parameter in the findSymbol function.
Does anybody have a hint about what I might try to fix this?
Thanks a lot.
Emmanuel