@@ -2656,18 +2656,21 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
26562656 comp_ctx -> comp_data = comp_data ;
26572657
26582658 /* Create LLVM context, module and builder */
2659- comp_ctx -> orc_thread_safe_context = LLVMOrcCreateNewThreadSafeContext ();
2660- if (!comp_ctx -> orc_thread_safe_context ) {
2661- aot_set_last_error ("create LLVM ThreadSafeContext failed." );
2659+ /* Construct an LLVMContext directly, note:
2660+ different from non LAZY JIT mode, no need to dispose this context, if
2661+ will be disposed when the thread safe context is disposed */
2662+ comp_ctx -> context = LLVMContextCreate ();
2663+ if (!comp_ctx -> context ) {
2664+ aot_set_last_error ("create LLVM Context failed." );
26622665 goto fail ;
26632666 }
26642667
2665- /* Get a reference to the underlying LLVMContext, note:
2666- different from non LAZY JIT mode, no need to dispose this context,
2667- if will be disposed when the thread safe context is disposed */
2668- if (!( comp_ctx -> context = LLVMOrcThreadSafeContextGetContext (
2669- comp_ctx -> orc_thread_safe_context ))) {
2670- aot_set_last_error ( "get context from LLVM ThreadSafeContext failed." );
2668+ /* Wrap the LLVM context in a thread safe context. */
2669+ comp_ctx -> orc_thread_safe_context =
2670+ LLVMOrcCreateNewThreadSafeContextFromLLVMContext ( comp_ctx -> context );
2671+ if (!comp_ctx -> orc_thread_safe_context ) {
2672+ aot_set_last_error (
2673+ "Create LLVM ThreadSafeContext from LLVMContext failed." );
26712674 goto fail ;
26722675 }
26732676
0 commit comments