Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 17 additions & 1 deletion tools/hermes/src/charon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,23 @@ pub fn run_charon(args: &Args, roots: &Roots, packages: &[HermesArtifact]) -> Re
// deterministic ordering for testing (not important in production).
let mut start_from = artifact.start_from.clone();
start_from.sort();
cmd.arg("--start-from").arg(start_from.join(","));

let start_from_str = start_from.join(",");
// OS command-line length limits (Windows is ~32k; Linux `ARG_MAX` is
// usually larger, but variable)
const ARG_CHAR_LIMIT: usize = 32_768;
Comment on lines +43 to +45
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better code organization and to signal that this constant is not dependent on the loop, consider defining ARG_CHAR_LIMIT and its explanatory comment outside the for loop, for example, at the function level. While const means no runtime cost, this improves readability and maintainability.

if start_from_str.len() > ARG_CHAR_LIMIT {
// FIXME: Pass the list of entry points to Charon via a file instead
// of the command line.
bail!(
"The list of Hermes entry points for package '{}' is too large ({} bytes). \n\
This exceeds safe OS command-line limits.",
Comment on lines +50 to +51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The indentation on this line will be included in the final error message string, which is likely not intended and will result in a large amount of whitespace at the beginning of the second line of the error message. Consider removing the leading spaces for cleaner output.

                "The list of Hermes entry points for package '{}' is too large ({} bytes). \nThis exceeds safe OS command-line limits.",

artifact.name.package_name,
start_from_str.len()
);
}

cmd.arg("--start-from").arg(start_from_str);

// Separator for the underlying cargo command
cmd.arg("--");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
failure
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The list of Hermes entry points for package 'large_pkg' is too large
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "large_pkg"
version = "0.1.0"
edition = "2021"

[dependencies]
Loading
Loading