From d327e41a5dfe84b8c9c6e21e45092941f937e189 Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Mon, 13 Oct 2025 15:13:34 +0200 Subject: [PATCH 1/7] Strip debug info from Rust targets --- earthly/rust/stdcfgs/cargo_config.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/earthly/rust/stdcfgs/cargo_config.toml b/earthly/rust/stdcfgs/cargo_config.toml index 317a7a845..23162c67b 100644 --- a/earthly/rust/stdcfgs/cargo_config.toml +++ b/earthly/rust/stdcfgs/cargo_config.toml @@ -1,3 +1,5 @@ +# cspell: words debuginfo + # Use MOLD linker where possible, but ONLY in CI applicable targets. # Configure how Docker container targets build. @@ -48,6 +50,7 @@ lto = "thin" panic = "unwind" incremental = false codegen-units = 16 +strip = "debuginfo" [profile.test] opt-level = 3 From b1d87056994aef8931734eff47c62c2691e06b68 Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Tue, 14 Oct 2025 17:05:18 +0200 Subject: [PATCH 2/7] Conditional stripping (off by default) --- earthly/rust/scripts/std_build.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/earthly/rust/scripts/std_build.py b/earthly/rust/scripts/std_build.py index e9239aedd..780f33302 100755 --- a/earthly/rust/scripts/std_build.py +++ b/earthly/rust/scripts/std_build.py @@ -12,6 +12,7 @@ from python import exec_manager from python.utils import fix_quoted_earthly_args + # This script is run inside the `build` stage. # This is set up so that ALL build steps are run and it will fail if any fail. # This improves visibility into all issues that need to be corrected for `build` @@ -136,11 +137,11 @@ def cargo_depgraph(runner: exec_manager.ParallelRunner, *, verbose: bool = False def cargo_modules_lib( - runner: exec_manager.ParallelRunner, - lib: str, - *, - docs: bool = True, - verbose: bool = False, + runner: exec_manager.ParallelRunner, + lib: str, + *, + docs: bool = True, + verbose: bool = False, ) -> None: """Check if we have any Orphans.""" runner.run( @@ -168,12 +169,12 @@ def cargo_modules_lib( def cargo_modules_bin( - runner: exec_manager.ParallelRunner, - package: str, - bin_file: str, - *, - docs: bool = True, - verbose: bool = False, + runner: exec_manager.ParallelRunner, + package: str, + bin_file: str, + *, + docs: bool = True, + verbose: bool = False, ) -> None: """Check if we have any Orphans.""" runner.run( @@ -306,6 +307,11 @@ def main() -> None: # noqa: C901, PLR0915 default="", help="The list of binaries `cargo-modules` docs to build and make a smoke tests on them.", ) + parser.add_argument( + "--strip", + action="store_true", + help="Flag to strip binary artifacts.", + ) args = parser.parse_args() libs = filter(lambda lib: lib.strip() and len(lib.strip()) > 0, args.libs.split(",")) @@ -372,7 +378,8 @@ def main() -> None: # noqa: C901, PLR0915 help_check(results, bin_name, verbose=args.verbose) ldd(results, bin_name) readelf(results, bin_name) - strip(results, bin_name) + if args.strip: + strip(results, bin_name) results.print() if not results.ok(): From bcb53275cb4c43d651cc0ab5a255a84f0e53b859 Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Tue, 14 Oct 2025 23:32:14 +0200 Subject: [PATCH 3/7] Fix formatting: --- earthly/rust/scripts/std_build.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/earthly/rust/scripts/std_build.py b/earthly/rust/scripts/std_build.py index 780f33302..7fc056924 100755 --- a/earthly/rust/scripts/std_build.py +++ b/earthly/rust/scripts/std_build.py @@ -137,11 +137,11 @@ def cargo_depgraph(runner: exec_manager.ParallelRunner, *, verbose: bool = False def cargo_modules_lib( - runner: exec_manager.ParallelRunner, - lib: str, - *, - docs: bool = True, - verbose: bool = False, + runner: exec_manager.ParallelRunner, + lib: str, + *, + docs: bool = True, + verbose: bool = False, ) -> None: """Check if we have any Orphans.""" runner.run( From 2ce21bb8167b910dd7389d04332d40e898324df6 Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Wed, 15 Oct 2025 00:28:05 +0200 Subject: [PATCH 4/7] Fix example --- earthly/rust/scripts/std_build.py | 12 ++++++------ examples/rust/.cargo/config.toml | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/earthly/rust/scripts/std_build.py b/earthly/rust/scripts/std_build.py index 7fc056924..a4ba4b575 100755 --- a/earthly/rust/scripts/std_build.py +++ b/earthly/rust/scripts/std_build.py @@ -169,12 +169,12 @@ def cargo_modules_lib( def cargo_modules_bin( - runner: exec_manager.ParallelRunner, - package: str, - bin_file: str, - *, - docs: bool = True, - verbose: bool = False, + runner: exec_manager.ParallelRunner, + package: str, + bin_file: str, + *, + docs: bool = True, + verbose: bool = False, ) -> None: """Check if we have any Orphans.""" runner.run( diff --git a/examples/rust/.cargo/config.toml b/examples/rust/.cargo/config.toml index 317a7a845..20b60d01f 100644 --- a/examples/rust/.cargo/config.toml +++ b/examples/rust/.cargo/config.toml @@ -48,6 +48,7 @@ lto = "thin" panic = "unwind" incremental = false codegen-units = 16 +strip = "debuginfo" [profile.test] opt-level = 3 From c4de79a9b905000870fd1cb3321ed412bb89b7bb Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Wed, 15 Oct 2025 00:36:19 +0200 Subject: [PATCH 5/7] Fix spellcheck --- earthly/rust/scripts/std_build.py | 1 - examples/rust/.cargo/config.toml | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/earthly/rust/scripts/std_build.py b/earthly/rust/scripts/std_build.py index a4ba4b575..e508bae96 100755 --- a/earthly/rust/scripts/std_build.py +++ b/earthly/rust/scripts/std_build.py @@ -12,7 +12,6 @@ from python import exec_manager from python.utils import fix_quoted_earthly_args - # This script is run inside the `build` stage. # This is set up so that ALL build steps are run and it will fail if any fail. # This improves visibility into all issues that need to be corrected for `build` diff --git a/examples/rust/.cargo/config.toml b/examples/rust/.cargo/config.toml index 20b60d01f..23162c67b 100644 --- a/examples/rust/.cargo/config.toml +++ b/examples/rust/.cargo/config.toml @@ -1,3 +1,5 @@ +# cspell: words debuginfo + # Use MOLD linker where possible, but ONLY in CI applicable targets. # Configure how Docker container targets build. From 472827fb2009b74249bb6a25cec1b4c283d58e87 Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Tue, 21 Oct 2025 10:37:00 +0200 Subject: [PATCH 6/7] Remove stripping for Rust targets --- earthly/rust/scripts/std_build.py | 8 +------- earthly/rust/stdcfgs/cargo_config.toml | 3 --- examples/rust/.cargo/config.toml | 3 --- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/earthly/rust/scripts/std_build.py b/earthly/rust/scripts/std_build.py index e508bae96..e66ce30a6 100755 --- a/earthly/rust/scripts/std_build.py +++ b/earthly/rust/scripts/std_build.py @@ -12,6 +12,7 @@ from python import exec_manager from python.utils import fix_quoted_earthly_args + # This script is run inside the `build` stage. # This is set up so that ALL build steps are run and it will fail if any fail. # This improves visibility into all issues that need to be corrected for `build` @@ -306,11 +307,6 @@ def main() -> None: # noqa: C901, PLR0915 default="", help="The list of binaries `cargo-modules` docs to build and make a smoke tests on them.", ) - parser.add_argument( - "--strip", - action="store_true", - help="Flag to strip binary artifacts.", - ) args = parser.parse_args() libs = filter(lambda lib: lib.strip() and len(lib.strip()) > 0, args.libs.split(",")) @@ -377,8 +373,6 @@ def main() -> None: # noqa: C901, PLR0915 help_check(results, bin_name, verbose=args.verbose) ldd(results, bin_name) readelf(results, bin_name) - if args.strip: - strip(results, bin_name) results.print() if not results.ok(): diff --git a/earthly/rust/stdcfgs/cargo_config.toml b/earthly/rust/stdcfgs/cargo_config.toml index 23162c67b..317a7a845 100644 --- a/earthly/rust/stdcfgs/cargo_config.toml +++ b/earthly/rust/stdcfgs/cargo_config.toml @@ -1,5 +1,3 @@ -# cspell: words debuginfo - # Use MOLD linker where possible, but ONLY in CI applicable targets. # Configure how Docker container targets build. @@ -50,7 +48,6 @@ lto = "thin" panic = "unwind" incremental = false codegen-units = 16 -strip = "debuginfo" [profile.test] opt-level = 3 diff --git a/examples/rust/.cargo/config.toml b/examples/rust/.cargo/config.toml index 23162c67b..317a7a845 100644 --- a/examples/rust/.cargo/config.toml +++ b/examples/rust/.cargo/config.toml @@ -1,5 +1,3 @@ -# cspell: words debuginfo - # Use MOLD linker where possible, but ONLY in CI applicable targets. # Configure how Docker container targets build. @@ -50,7 +48,6 @@ lto = "thin" panic = "unwind" incremental = false codegen-units = 16 -strip = "debuginfo" [profile.test] opt-level = 3 From 399b078393e19d4a95139eef411cdc1dd3948071 Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Tue, 21 Oct 2025 10:44:41 +0200 Subject: [PATCH 7/7] Fix linter --- earthly/rust/scripts/std_build.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/earthly/rust/scripts/std_build.py b/earthly/rust/scripts/std_build.py index e66ce30a6..b9dfcde79 100755 --- a/earthly/rust/scripts/std_build.py +++ b/earthly/rust/scripts/std_build.py @@ -12,7 +12,6 @@ from python import exec_manager from python.utils import fix_quoted_earthly_args - # This script is run inside the `build` stage. # This is set up so that ALL build steps are run and it will fail if any fail. # This improves visibility into all issues that need to be corrected for `build` @@ -231,14 +230,7 @@ def readelf(results: exec_manager.Results, bin_file: str) -> None: ) -def strip(results: exec_manager.Results, bin_file: str) -> None: - """Strip.""" - results.add( - exec_manager.cli_run(f"strip -v target/release/{bin_file}", name=f"strip for '{bin_file}'", verbose=True), - ) - - -def main() -> None: # noqa: C901, PLR0915 +def main() -> None: # noqa: C901 """Rust Standard Build.""" # Force color output in CI rich.reconfigure(color_system="256")