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

Simplify the error output on failed Command invocation #1397

Merged
merged 2 commits into from
Feb 14, 2025

Conversation

madsmtm
Copy link
Collaborator

@madsmtm madsmtm commented Feb 10, 2025

Passing around the program we wanted to execute in command_helpers.rs is unnecessary, we can retrieve it from Command::get_program instead when required, and that path is usually more descriptive anyhow.

Motivation

I'm currently debugging this. The error that cc-rs gives is:

error occurred: Command "sccache" "aarch64-unknown-fuchsia-clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=aarch64-unknown-fuchsia" "-I" "/checkout/src/llvm-project/compiler-rt/lib/builtins" "-fno-builtin" "-fvisibility=hidden" "-ffreestanding" "-fomit-frame-pointer" "-ffile-prefix-map=/checkout/src/llvm-project/compiler-rt=." "-DCOMPILER_RT_HAS_FLOAT16" "-DVISIBILITY_HIDDEN" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/aarch64-unknown-fuchsia/release/build/compiler_builtins-6830d4e928982f93/out/670c1ed24249df13-aarch64.o" "-c" "/checkout/src/llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64.c" with args aarch64-unknown-fuchsia-clang did not execute successfully (status code exit status: 1).

This was confusing, as "aarch64-unknown-fuchsia-clang" is really the compiler and not "args". Besides, I didn't actually need to know that the tool we "wanted" to invoke; that is evident from the pretty-printed command line arguments.

With this PR, the above error would have been:

error occurred: command did not execute successfully (status code 1): "sccache" "aarch64-unknown-fuchsia-clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=aarch64-unknown-fuchsia" "-I" "/checkout/src/llvm-project/compiler-rt/lib/builtins" "-fno-builtin" "-fvisibility=hidden" "-ffreestanding" "-fomit-frame-pointer" "-ffile-prefix-map=/checkout/src/llvm-project/compiler-rt=." "-DCOMPILER_RT_HAS_FLOAT16" "-DVISIBILITY_HIDDEN" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/aarch64-unknown-fuchsia/release/build/compiler_builtins-6830d4e928982f93/out/670c1ed24249df13-aarch64.o" "-c" "/checkout/src/llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64.c"

Which is shorter, and makes it clearer where the command starts and ends (after the colon and at the end of the line).

Don't pass the "program" we wanted to execute around, retrieve it from
`Command::get_program` instead when required.

Also make error messages easier to read.
Copy link
Collaborator

@NobodyXu NobodyXu left a comment

Choose a reason for hiding this comment

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

Thanks, just one minor nit for error message

src/command_helpers.rs Outdated Show resolved Hide resolved
Co-authored-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
@madsmtm madsmtm requested a review from NobodyXu February 14, 2025 11:23
@NobodyXu NobodyXu merged commit fcf940e into rust-lang:main Feb 14, 2025
73 checks passed
@madsmtm madsmtm deleted the simplify-cmd-display branch February 14, 2025 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants