Skip to content

Commit

Permalink
Make Option -o work
Browse files Browse the repository at this point in the history
  • Loading branch information
Thirumalai-Shaktivel committed Jan 18, 2022
1 parent c2e65e8 commit ec14cb7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ src/libasr/config.h
share/jupyter/kernels/fortran/kernel.json
src/runtime/*.o.empty.c
python_ast.py
python_ast.h
ser.txt

### https://raw.github.com/github/gitignore/218a941be92679ce67d0484547e3e142b2f5f6f0/Global/macOS.gitignore
Expand Down
2 changes: 1 addition & 1 deletion build0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ python grammar/asdl_cpp.py
# Generate a Python AST from Python.asdl (Python)
python grammar/asdl_py.py
# Generate a Python AST from Python.asdl (C++)
python grammar/asdl_cpp.py grammar/Python.asdl src/lfortran/ast.h
python grammar/asdl_cpp.py grammar/Python.asdl src/lfortran/python_ast.h
# Generate a Fortran ASR from ASR.asdl (C++)
python grammar/asdl_cpp.py grammar/ASR.asdl src/libasr/asr.h

Expand Down
2 changes: 1 addition & 1 deletion ci/build.xsh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ cp lpython-$lpython_version/test-bld/src/runtime/*.mod src/runtime/
# Run some simple compilation tests, works everywhere:
src/bin/lpython --version
# Compile and link separately
src/bin/lpython -c examples/expr2.f90 -o expr2.o
src/bin/lpython -c examples/expr2.py -o expr2.o
src/bin/lpython -o expr2 expr2.o
./expr2

Expand Down
9 changes: 7 additions & 2 deletions src/bin/lfortran.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1507,11 +1507,11 @@ int main(int argc, char *argv[])
LFORTRAN_ASSERT(false);
}
}

if (arg_c) {
if (backend == Backend::llvm) {
#ifdef HAVE_LFORTRAN_LLVM
return compile_to_object_file(arg_file, outfile, false,
compiler_options);
return compile_python_to_object_file(arg_file, outfile, compiler_options);
#else
std::cerr << "The -c option requires the LLVM backend to be enabled. Recompile with `WITH_LLVM=yes`." << std::endl;
return 1;
Expand All @@ -1537,10 +1537,15 @@ int main(int argc, char *argv[])
std::cerr << "Compiling Python files to object files requires the LLVM backend to be enabled. Recompile with `WITH_LLVM=yes`." << std::endl;
return 1;
#endif
} else {
throw LFortran::LFortranException("Unsupported backend.");
}
if (err) return err;
return link_executable({tmp_o}, outfile, runtime_library_dir,
backend, static_link, true, compiler_options);
} else {
return link_executable(arg_files, outfile, runtime_library_dir,
backend, static_link, true, compiler_options);
}
} catch(const LFortran::LFortranException &e) {
std::cerr << "Internal Compiler Error: Unhandled exception" << std::endl;
Expand Down

0 comments on commit ec14cb7

Please sign in to comment.