Skip to content

Commit

Permalink
skip python_bind ASR pass when using C backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Vipul-Cariappa committed Aug 5, 2024
1 parent 24f52fa commit 3d1b50e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/bin/lpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ int emit_c(const std::string &infile,
pass_manager.use_default_passes(true);
compiler_options.po.always_run = true;
compiler_options.po.run_fun = "f";
compiler_options.po.c_backend = true;

pass_manager.apply_passes(al, asr, compiler_options.po, diagnostics);

Expand Down
11 changes: 10 additions & 1 deletion src/libasr/pass/python_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,16 @@ void generate_body(Allocator &al, ASR::Function_t &f, SymbolTable &parent_scope)
ASRUtils::get_FunctionType(f)->m_deftype = ASR::deftypeType::Implementation;
}

void pass_python_bind(Allocator &al, ASR::TranslationUnit_t &unit, const PassOptions &/*pass_options*/) {
void pass_python_bind(Allocator &al, ASR::TranslationUnit_t &unit, const PassOptions &pass_options) {
if (pass_options.c_backend) {
// FIXME: C backend supports arrays, it is used in bindpy_02 to bindpy_04 tests.
// This pass currently does not handle any aggregate types.
// Once we include support for aggregate types, we should remove this check, and
// remove the `c_backend` variable from PassOptions.
// We will also need to remove the special handling of BindPython ABI in C
// backend as it would be handled by this ASR pass.
return;
}
bool bindpython_used = false;
for (auto &item : unit.m_symtab->get_scope()) {
if (ASR::is_a<ASR::Function_t>(*item.second)) {
Expand Down
1 change: 1 addition & 0 deletions src/libasr/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ struct PassOptions {
bool tree = false;
bool with_intrinsic_mods = false;
bool c_mangling = false;
bool c_backend = false;
};

struct CompilerOptions {
Expand Down

0 comments on commit 3d1b50e

Please sign in to comment.