numba: LLVM14 linux-aarch64 blocker

This issue is to document a blocker for using LLVM14 on linux-aarch64.

LLVM14 on Linux-aarch64 seems to have a bug (in probably MCJIT+RuntimeDyLd) that affect fails to load exporting symbols and/or setting up GOT info.

Symptom:

The following tests fails:

numba.tests.doc_examples.test_typed_list_usage.DocsTypedListUsageTest.test_ex_nested_list                   
numba.tests.doc_examples.test_typed_list_usage.DocsTypedListUsageTest.test_ex_inferred_list_jit             
numba.tests.doc_examples.test_typed_list_usage.DocsTypedListUsageTest.test_ex_inferred_list                 
numba.tests.doc_examples.test_typed_dict_usage.DocsTypedDictUsageTest.test_ex_typed_dict_njit               
numba.tests.doc_examples.test_typed_dict_usage.DocsTypedDictUsageTest.test_ex_typed_dict_from_cpython       
numba.tests.doc_examples.test_typed_dict_usage.DocsTypedDictUsageTest.test_ex_inferred_dict_njit            
numba.tests.doc_examples.test_parallel_chunksize.ChunksizeExamplesTest.test_unbalanced_example              
numba.tests.doc_examples.test_parallel_chunksize.ChunksizeExamplesTest.test_chunksize_with                  
numba.tests.doc_examples.test_literal_container_usage.DocsLiteralContainerUsageTest.test_ex_initial_value_dict_compile_time_consts
numba.tests.doc_examples.test_jitclass.DocsJitclassUsageTest.test_ex_jitclass_type_hints

They all segfault when executing JITed callback functions that are invoked by externally compiled functions. Most of the cases can be workaround by making the callback functions have internal linkage. However, ChunksizeExamplesTest failures cannot use this workaround due to requirement of how ufunc works in Numba.

A minimal reproducer for the ChunksizeExamplesTest problems is provided in this gist. Observations in the reproducer:

  • the bug can somehow be avoided by doing O0 on the problematic JIT function.
  • saving the problematic LLVM IR to file and running it in a fresh process works without problem.

I don’t know what to make off the first observation. The second observation seems to indicate the problem only occurs when multiple LLVM modules are loaded into MCJIT.

The above tests all works in LLVM11.

Related issues:

Future fixes:

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 18 (18 by maintainers)

Commits related to this issue

Most upvoted comments

With this patch applied to LLVM 14.0.6:

diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
index 3c7f4ec47eb8..205ee5273b27 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
@@ -2407,6 +2407,7 @@ Error RuntimeDyldELF::finalizeLoad(const ObjectFile &Obj,
   }

   GOTSectionID = 0;
+  GOTOffsetMap.clear();
   CurrentGOTIndex = 0;

   return Error::success();

with Numba and llvmlite main following the LLVM 14 merge:

(numballvm14) gmarkall@gm-agx:~/numbadev/numba$ python runtests.py numba.tests.doc_examples.test_typed_list_usage.DocsTypedListUsageTest numba.tests.doc_examples.test_parallel_chunksize.ChunksizeExamplesTest numba.tests.doc_examples.test_literal_container_usage.DocsLiteralContainerUsageTest numba.tests.doc_examples.test_jitclass.DocsJitclassUsageTest -v -m
Parallel: 9. Serial: 3
test_ex_literal_list (numba.tests.doc_examples.test_literal_container_usage.DocsLiteralContainerUsageTest) ... ok
test_ex_initial_value_list_compile_time_consts (numba.tests.doc_examples.test_literal_container_usage.DocsLiteralContainerUsageTest) ... ok
test_ex_literal_dict_compile_time_consts (numba.tests.doc_examples.test_literal_container_usage.DocsLiteralContainerUsageTest) ... ok
test_ex_inferred_list_jit (numba.tests.doc_examples.test_typed_list_usage.DocsTypedListUsageTest) ... ok
test_ex_jitclass (numba.tests.doc_examples.test_jitclass.DocsJitclassUsageTest) ... ok
test_ex_inferred_list (numba.tests.doc_examples.test_typed_list_usage.DocsTypedListUsageTest) ... ok
test_ex_jitclass_type_hints (numba.tests.doc_examples.test_jitclass.DocsJitclassUsageTest) ... ok
test_ex_nested_list (numba.tests.doc_examples.test_typed_list_usage.DocsTypedListUsageTest) ... ok
test_ex_initial_value_dict_compile_time_consts (numba.tests.doc_examples.test_literal_container_usage.DocsLiteralContainerUsageTest) ... ok
test_chunksize_manual (numba.tests.doc_examples.test_parallel_chunksize.ChunksizeExamplesTest) ... ok
test_chunksize_with (numba.tests.doc_examples.test_parallel_chunksize.ChunksizeExamplesTest) ... ok
test_unbalanced_example (numba.tests.doc_examples.test_parallel_chunksize.ChunksizeExamplesTest) ... ok

----------------------------------------------------------------------
Ran 12 tests in 95.065s

OK

All tests listed in the issue description pass. The runtime is huge, but I have a debug build of LLVM with assertions enabled, and LTO disabled for llvmlite (using LTO ICEd the old version of GCC on my Jetson install 😆 ).