Repository: rust
Issue: On linker errors write command to file instead of printing to disk
Labels: A-linkage,A-diagnostics,T-compiler,D-verbose

### Current output

```Shell
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

```Shell
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/_