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

On linker errors write command to file instead of printing to disk #110763

Open
estebank opened this issue Apr 24, 2023 · 4 comments
Open

On linker errors write command to file instead of printing to disk #110763

estebank opened this issue Apr 24, 2023 · 4 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-linkage Area: linking into static, shared libraries and binaries D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@estebank
Copy link
Contributor

estebank commented Apr 24, 2023

Current output

error: linking with `cc` failed: exit status: 1
    |
    = note: LC_ALL="C" PATH="/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin:/Users/noahkelly/.cabal/bin:/Users/noahkelly/.ghcup/bin:/Users/noahkelly/.cargo/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/noahkelly/Downloads/apache-maven-3.8.2/bin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Applications/Wireshark.app/Contents/MacOS:/Users/noahkelly/.cargo/bin" VSLANG="1033" ZERO_AR_DATE="1" "cc" "-arch" "x86_64" "-m64" "/var/folders/9t/1d02qjxd6rd_2vrpg1_fd1y80000gn/T/rustcQswpeL/symbols.o" "/Users/noahkelly/Desktop/CAIS_0302/Presentation2/tutorials/rust_tutorial/target/debug/deps/rust_tutorial-82284bbf181b6391.12hqyt5gjqwogg3l.rcgu.o" "/Users/noahkelly/Desktop/CAIS_0302/Presentation2/tutorials/rust_tutorial/target/debug/deps/rust_tutorial-82284bbf181b6391.170m4bx95h60hgxl.rcgu.o" "/Users/noahkelly/Desktop/CAIS_0302/Presentation2/tutorials/rust_tutorial/target/debug/deps/rust_tutorial-82284bbf181b6391.2htc2bizz0xlomh4.rcgu.o" "/Users/noahkelly/Desktop/CAIS_0302/Presentation2/tutorials/rust_tutorial/target/debug/deps/rust_tutorial-82284bbf181b6391.32t7xrbq5e59nsg3.rcgu.o" "/Users/noahkelly/Desktop/CAIS_0302/Presentation2/tutorials/rust_tutorial/target/debug/deps/rust_tutorial-82284bbf181b6391.4ffg2fgund0et5fl.rcgu.o" "/Users/noahkelly/Desktop/CAIS_0302/Presentation2/tutorials/rust_tutorial/target/debug/deps/rust_tutorial-82284bbf181b6391.57snssrffpftjrce.rcgu.o" "/Users/noahkelly/Desktop/CAIS_0302/Presentation2/tutorials/rust_tutorial/target/debug/deps/rust_tutorial-82284bbf181b6391.20k16tb80xbjiv8t.rcgu.o" "-L" "/Users/noahkelly/Desktop/CAIS_0302/Presentation2/tutorials/rust_tutorial/target/debug/deps" "-L" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-8c7ba4cb14921aed.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-90e9ca565b042945.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libobject-464a0586d0933b26.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libmemchr-db3d1e5a32355b36.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-74798b95a0884a59.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgimli-d7b0a7d172fdaf84.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-c50e314035d07ff6.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd_detect-ed447ed716cd0465.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-4f8aa5a213a4f4a6.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libminiz_oxide-2c711c9d26ddd542.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libadler-ab666c0d9447875d.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-711ae8c2777323b0.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-dac435ef9b9ec5bd.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-16d13d5a3e9202fe.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-6817e59b6d2f2f20.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-316b477d50fb0f01.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-7ba55cce4735e904.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-399e1f4c06861f02.rlib" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-8bb525c7516034b0.rlib" "-lSystem" "-lc" "-lm" "-L" "/Users/noahkelly/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "-o" "/Users/noahkelly/Desktop/CAIS_0302/Presentation2/tutorials/rust_tutorial/target/debug/deps/rust_tutorial-82284bbf181b6391" "-Wl,-dead_strip" "-nodefaultlibs"  
    = note: xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error

Desired output

error: linking with `cc` failed: exit status: 1
    |
    = note: executed command written to `/Users/noahkelly/command.txt`
    = note: xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error

Rationale and extra context

Linker errors print the entire command that was executed before printing the output of the command. This is very useful to debug why the error occurred, but it obscures the executed command's explanation of the situation. We already print files to disk for really long paths, we should do the same for really long commands.

Anything else?

filed on behalf of https://www.reddit.com/r/rust/comments/12x2fg6/cant_run_hello_world/

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 24, 2023
@Mark-Simulacrum
Copy link
Member

My worry is that this makes it ~impossible to debug such errors if they occur in CI systems or elsewhere where that file would now be lost. I'm not sure if we already have a solution there (read $CI, at minimum?) but I think it's a real pain point.

I do think at minimum we should de-emphasize the wall of text - I wonder if there's any kind of terminal magic that might help there, similar to <details> on the web.

@jyn514
Copy link
Member

jyn514 commented Apr 26, 2023

cc #109979

@jyn514 jyn514 added A-linkage Area: linking into static, shared libraries and binaries D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. labels Apr 26, 2023
@estebank
Copy link
Contributor Author

@Mark-Simulacrum regarding CI, it has come up multiple times now that what is ideal for interactive terminals and what is ideal to debug CI output after the fact differs in exactly this way. That tells me we should bite the bullet and provide an env flag to tweak the output in a single place (and make the CI one the default, advertise how to set up the more user friendly version in rustup).

@Mark-Simulacrum
Copy link
Member

Definitely +1 to that, I think there's other things that may want a different default too (e.g., cargo may want to dump future incompat for similar reasons, we may not want to be incremental by default, etc.)

estebank added a commit to estebank/rust that referenced this issue Dec 4, 2024
Only print the entire linker command that failed if `--verbose` is set.

CC rust-lang#110763. Fix rust-lang#109979.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-linkage Area: linking into static, shared libraries and binaries D-verbose Diagnostics: Too much output caused by a single piece of incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants