Skip to content
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

fix: force recompilation when output_debug flag is set. #2898

Merged
merged 5 commits into from
Sep 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: pass output_debug to save_program again
TomAFrench committed Sep 29, 2023
commit d74ac75c990df7ca35ce9d692a3d5f45d5cfe82a
30 changes: 26 additions & 4 deletions tooling/nargo_cli/src/cli/compile_cmd.rs
Original file line number Diff line number Diff line change
@@ -82,6 +82,7 @@ pub(crate) fn run(
np_language,
&opcode_support,
&args.compile_options,
args.output_debug,
)?;

// Save build artifacts to disk.
@@ -99,14 +100,22 @@ pub(super) fn compile_workspace(
np_language: Language,
opcode_support: &BackendOpcodeSupport,
compile_options: &CompileOptions,
output_debug: bool,
) -> Result<(Vec<CompiledProgram>, Vec<CompiledContract>), CliError> {
let is_opcode_supported = |opcode: &_| opcode_support.is_opcode_supported(opcode);

// Compile all of the packages in parallel.
let program_results: Vec<(FileManager, CompilationResult<CompiledProgram>)> = binary_packages
.par_iter()
.map(|package| {
compile_program(workspace, package, compile_options, np_language, &is_opcode_supported)
compile_program(
workspace,
package,
compile_options,
output_debug,
np_language,
&is_opcode_supported,
)
})
.collect();
let contract_results: Vec<(FileManager, CompilationResult<CompiledContract>)> =
@@ -138,15 +147,22 @@ pub(crate) fn compile_bin_package(
workspace: &Workspace,
package: &Package,
compile_options: &CompileOptions,
output_debug: bool,
np_language: Language,
is_opcode_supported: &impl Fn(&Opcode) -> bool,
) -> Result<CompiledProgram, CliError> {
if package.is_library() {
return Err(CompileError::LibraryCrate(package.name.clone()).into());
}

let (file_manager, compilation_result) =
compile_program(workspace, package, compile_options, np_language, &is_opcode_supported);
let (file_manager, compilation_result) = compile_program(
workspace,
package,
compile_options,
output_debug,
np_language,
&is_opcode_supported,
);

let program = report_errors(compilation_result, &file_manager, compile_options.deny_warnings)?;

@@ -157,6 +173,7 @@ fn compile_program(
workspace: &Workspace,
package: &Package,
compile_options: &CompileOptions,
output_debug: bool,
np_language: Language,
is_opcode_supported: &impl Fn(&Opcode) -> bool,
) -> (FileManager, CompilationResult<CompiledProgram>) {
@@ -190,7 +207,12 @@ fn compile_program(
nargo::ops::optimize_program(program, np_language, &is_opcode_supported)
.expect("Backend does not support an opcode that is in the IR");

save_program(optimized_program.clone(), package, &workspace.target_directory_path(), false);
save_program(
optimized_program.clone(),
package,
&workspace.target_directory_path(),
output_debug,
);

(context.file_manager, Ok((optimized_program, warnings)))
}