@@ -512,7 +512,7 @@ int compile_python_to_object_file(
512
512
const std::string &runtime_library_dir,
513
513
LCompilers::PassManager& pass_manager,
514
514
CompilerOptions &compiler_options,
515
- bool time_report)
515
+ bool time_report, bool arg_c= false )
516
516
{
517
517
Allocator al (4 *1024 );
518
518
LFortran::diag::Diagnostics diagnostics;
@@ -540,7 +540,8 @@ int compile_python_to_object_file(
540
540
diagnostics.diagnostics .clear ();
541
541
auto ast_to_asr_start = std::chrono::high_resolution_clock::now ();
542
542
LFortran::Result<LFortran::ASR::TranslationUnit_t*>
543
- r1 = LFortran::LPython::python_ast_to_asr (al, *ast, diagnostics, true ,
543
+ r1 = LFortran::LPython::python_ast_to_asr (al, *ast, diagnostics,
544
+ !(arg_c && compiler_options.disable_main ),
544
545
compiler_options.disable_main , compiler_options.symtab_only , infile);
545
546
auto ast_to_asr_end = std::chrono::high_resolution_clock::now ();
546
547
times.push_back (std::make_pair (" AST to ASR" , std::chrono::duration<double , std::milli>(ast_to_asr_end - ast_to_asr_start).count ()));
@@ -551,6 +552,12 @@ int compile_python_to_object_file(
551
552
return 2 ;
552
553
}
553
554
LFortran::ASR::TranslationUnit_t* asr = r1.result ;
555
+ if ( compiler_options.disable_main ) {
556
+ int err = LFortran::LPython::save_pyc_files (*asr, infile);
557
+ if ( err ) {
558
+ return err;
559
+ }
560
+ }
554
561
diagnostics.diagnostics .clear ();
555
562
556
563
// ASR -> LLVM
@@ -1065,7 +1072,8 @@ int main(int argc, char *argv[])
1065
1072
if (arg_c) {
1066
1073
if (backend == Backend::llvm) {
1067
1074
#ifdef HAVE_LFORTRAN_LLVM
1068
- return compile_python_to_object_file (arg_file, outfile, runtime_library_dir, lpython_pass_manager, compiler_options, time_report);
1075
+ return compile_python_to_object_file (arg_file, outfile, runtime_library_dir, lpython_pass_manager, compiler_options, time_report,
1076
+ arg_c);
1069
1077
#else
1070
1078
std::cerr << " The -c option requires the LLVM backend to be enabled. Recompile with `WITH_LLVM=yes`." << std::endl;
1071
1079
return 1 ;
0 commit comments