-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BindPython ASR Pass: aggregate type conversions #2803
BindPython ASR Pass: aggregate type conversions #2803
Conversation
and refactoring
Backend does not support yet.
7f1e901
to
45a774a
Compare
It looks like ❯ lp --jit --enable-cpython --fast ./bindpy_06.py
Internal Compiler Error: Unhandled exception
Traceback (most recent call last):
Binary file "/home/vipul/Workspace/python/lpython/src/bin/lpython", in _start()
Binary file "/lib64/libc.so.6", in __libc_start_main_alias_2()
Binary file "/lib64/libc.so.6", in __libc_start_call_main()
File "/home/vipul/Workspace/python/lpython/src/bin/lpython.cpp", line 2218, in main()
return compile_python_using_llvm(arg_file, "", runtime_library_dir,
File "/home/vipul/Workspace/python/lpython/src/bin/lpython.cpp", line 1119, in compile_python_using_llvm()
res = fe.get_llvm3(*asr, pass_manager, diagnostics, infile);
File "/home/vipul/Workspace/python/lpython/src/lpython/python_evaluator.cpp", line 466, in LCompilers::PythonCompiler::get_llvm3(LCompilers::ASR::TranslationUnit_t&, LCompilers::PassManager&, LCompilers::diag::Diagnostics&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
run_fn, global_underscore_name, infile);
File "/home/vipul/Workspace/python/lpython/src/libasr/codegen/asr_to_llvm.cpp", line 10246, in LCompilers::asr_to_llvm(LCompilers::ASR::TranslationUnit_t&, LCompilers::diag::Diagnostics&, llvm::LLVMContext&, Allocator&, LCompilers::PassManager&, LCompilers::CompilerOptions&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
pass_manager.apply_passes(al, &asr, co.po, diagnostics);
File "/home/vipul/Workspace/python/lpython/src/libasr/pass/pass_manager.h", line 311, in LCompilers::PassManager::apply_passes(Allocator&, LCompilers::ASR::TranslationUnit_t*, LCompilers::PassOptions&, LCompilers::diag::Diagnostics&)
apply_passes(al, asr, _with_optimization_passes, pass_options,
File "/home/vipul/Workspace/python/lpython/src/libasr/pass/pass_manager.h", line 169, in LCompilers::PassManager::apply_passes(Allocator&, LCompilers::ASR::TranslationUnit_t*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, LCompilers::PassOptions&, LCompilers::diag::Diagnostics&)
_passes_db[passes[i]](al, *asr, pass_options);
File "/home/vipul/Workspace/python/lpython/src/libasr/pass/inline_function_calls.cpp", line 540, in LCompilers::pass_inline_function_calls(Allocator&, LCompilers::ASR::TranslationUnit_t&, LCompilers::PassOptions const&)
v.visit_TranslationUnit(unit);
File "/home/vipul/Workspace/python/lpython/src/libasr/../libasr/asr.h", line 48863, in LCompilers::ASR::CallReplacerOnExpressionsVisitor<LCompilers::InlineFunctionCallVisitor>::visit_TranslationUnit(LCompilers::ASR::TranslationUnit_t const&)
this->visit_symbol(*a.second);
File "/home/vipul/Workspace/python/lpython/src/libasr/../libasr/asr.h", line 5370, in LCompilers::ASR::BaseVisitor<LCompilers::InlineFunctionCallVisitor>::visit_symbol(LCompilers::ASR::symbol_t const&)
void visit_symbol(const symbol_t &b) { visit_symbol_t(b, self()); }
File "/home/vipul/Workspace/python/lpython/src/libasr/../libasr/asr.h", line 5073, in visit_symbol_t<LCompilers::InlineFunctionCallVisitor>()
case symbolType::Module: { v.visit_Module((const Module_t &)x); return; }
File "/home/vipul/Workspace/python/lpython/src/libasr/../libasr/asr.h", line 48881, in LCompilers::ASR::CallReplacerOnExpressionsVisitor<LCompilers::InlineFunctionCallVisitor>::visit_Module(LCompilers::ASR::Module_t const&)
this->visit_symbol(*a.second);
File "/home/vipul/Workspace/python/lpython/src/libasr/../libasr/asr.h", line 5370, in LCompilers::ASR::BaseVisitor<LCompilers::InlineFunctionCallVisitor>::visit_symbol(LCompilers::ASR::symbol_t const&)
void visit_symbol(const symbol_t &b) { visit_symbol_t(b, self()); }
File "/home/vipul/Workspace/python/lpython/src/libasr/../libasr/asr.h", line 5074, in visit_symbol_t<LCompilers::InlineFunctionCallVisitor>()
case symbolType::Function: { v.visit_Function((const Function_t &)x); return; }
File "/home/vipul/Workspace/python/lpython/src/libasr/pass/inline_function_calls.cpp", line 493, in LCompilers::InlineFunctionCallVisitor::visit_Function(LCompilers::ASR::Function_t const&)
ASR::CallReplacerOnExpressionsVisitor<InlineFunctionCallVisitor>::visit_Function(x);
File "/home/vipul/Workspace/python/lpython/src/libasr/../libasr/asr.h", line 48901, in LCompilers::ASR::CallReplacerOnExpressionsVisitor<LCompilers::InlineFunctionCallVisitor>::visit_Function(LCompilers::ASR::Function_t const&)
self().transform_stmts(xx.m_body, xx.n_body);
File "/home/vipul/Workspace/python/lpython/src/libasr/pass/inline_function_calls.cpp", line 516, in LCompilers::InlineFunctionCallVisitor::transform_stmts(LCompilers::ASR::stmt_t**&, unsigned long&)
visit_stmt(*m_body[i]);
File "/home/vipul/Workspace/python/lpython/src/libasr/../libasr/asr.h", line 5387, in LCompilers::ASR::BaseVisitor<LCompilers::InlineFunctionCallVisitor>::visit_stmt(LCompilers::ASR::stmt_t const&)
void visit_stmt(const stmt_t &b) { visit_stmt_t(b, self()); }
File "/home/vipul/Workspace/python/lpython/src/libasr/../libasr/asr.h", line 5098, in visit_stmt_t<LCompilers::InlineFunctionCallVisitor>()
case stmtType::Assignment: { v.visit_Assignment((const Assignment_t &)x); return; }
File "/home/vipul/Workspace/python/lpython/src/libasr/pass/inline_function_calls.cpp", line 499, in LCompilers::InlineFunctionCallVisitor::visit_Assignment(LCompilers::ASR::Assignment_t const&)
ASR::CallReplacerOnExpressionsVisitor<InlineFunctionCallVisitor>::visit_Assignment(x);
File "/home/vipul/Workspace/python/lpython/src/libasr/../libasr/asr.h", line 49095, in LCompilers::ASR::CallReplacerOnExpressionsVisitor<LCompilers::InlineFunctionCallVisitor>::visit_Assignment(LCompilers::ASR::Assignment_t const&)
self().call_replacer();
File "/home/vipul/Workspace/python/lpython/src/libasr/pass/inline_function_calls.cpp", line 485, in LCompilers::InlineFunctionCallVisitor::call_replacer()
replacer.replace_expr(*current_expr);
File "/home/vipul/Workspace/python/lpython/src/libasr/../libasr/asr.h", line 47751, in LCompilers::ASR::BaseExprReplacer<LCompilers::InlineFunctionCall>::replace_expr(LCompilers::ASR::expr_t*)
self().replace_FunctionCall(down_cast<ASR::FunctionCall_t>(x));
File "/home/vipul/Workspace/python/lpython/src/libasr/pass/inline_function_calls.cpp", line 288, in LCompilers::InlineFunctionCall::replace_FunctionCall(LCompilers::ASR::FunctionCall_t*)
call_arg_var = PassUtils::create_auxiliary_variable_for_expr(x_m_args_i, arg_name, al, current_scope, assign_stmt);
File "/home/vipul/Workspace/python/lpython/src/libasr/pass/pass_utils.cpp", line 781, in LCompilers::PassUtils::create_auxiliary_variable_for_expr(LCompilers::ASR::expr_t*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, Allocator&, LCompilers::SymbolTable*&, LCompilers::ASR::stmt_t*&)
ASR::asr_t* expr_sym = ASR::make_Variable_t(al, expr->base.loc, current_scope, s2c(al, name), nullptr, 0,
LCompilersException: Not implemented 6 I am thinking of skipping |
integration_tests/CMakeLists.txt
Outdated
@@ -666,6 +666,7 @@ RUN(NAME bindpy_02 LABELS cpython c_py EXTRA_ARGS --link-numpy COPY_TO | |||
RUN(NAME bindpy_03 LABELS cpython c_py EXTRA_ARGS --link-numpy NOFAST COPY_TO_BIN bindpy_03_module.py) | |||
RUN(NAME bindpy_04 LABELS cpython c_py EXTRA_ARGS --link-numpy NOFAST COPY_TO_BIN bindpy_04_module.py) | |||
RUN(NAME bindpy_05 LABELS llvm_py c_py EXTRA_ARGS --enable-cpython COPY_TO_BIN bindpy_05_module.py REQ_PY_VER 3.10) | |||
RUN(NAME bindpy_06 LABELS llvm_py EXTRA_ARGS --enable-cpython COPY_TO_BIN bindpy_06_module.py REQ_PY_VER 3.10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add NOFAST to this. Also, I think we should be testing this with cpython
as well to ensure what we support also works with CPython. We should not support something that is not supported with CPython.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should test bindpy_05.py with CPython.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bindpy_05.py
with cpython fails with:
Traceback (most recent call last):
File "/home/vipul/Workspace/python/lpython/integration_tests/bindpy_05.py", line 3, in <module>
@ccall(header="Python.h")
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vipul/Workspace/python/lpython/src/runtime/lpython/lpython.py", line 482, in wrap
func = CTypes(func, c_shared_lib, c_shared_lib_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vipul/Workspace/python/lpython/src/runtime/lpython/lpython.py", line 372, in __init__
self.cf = self.library[self.name]
~~~~~~~~~~~~^^^^^^^^^^^
File "/usr/lib64/python3.12/ctypes/__init__.py", line 397, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: /home/vipul/Workspace/python/lpython/src/runtime/lpython/../liblpython_runtime.so: undefined symbol: Py_Initialize
I have added cpython for bindpy_06
and NOFAST
flag.
0355b39
to
ca09e53
Compare
No description provided.