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

cargo b failed (link stage) when the binary built(renamed) is running, linker exit code : 1104 #11446

Closed
ryanroe opened this issue Dec 1, 2022 · 2 comments
Labels
C-bug Category: bug

Comments

@ryanroe
Copy link

ryanroe commented Dec 1, 2022

Problem

cargo failed to link binary when the produced binary ( renamed ) is running.
as the screenshots shown below.

main rs - empty-app - Visual Studio Code 2022-12-01 11-03-36

Steps

  1. create an empty app with cargo new empty-app
  2. replace main.rs with
use std::io::stdin;

fn main() {
    println!("Hello, world!");
    let x = stdin().lines();
    for l in x {
        match l {
            Ok(line) => println!("{}", line),
            Err(_e) => {}
        }
    }
}
  1. execute cargo b
  2. find binary empty-app.exe in target/debug directory, rename it to some-other-name.exe
  3. execute .\some-other-name.exe and keep running
  4. change main.rs content, replace Hello, world! to other string
  5. execute cargo b again

Possible Solution(s)

No response

Notes

cargo b output

   Compiling empty-app v0.1.0 (D:\repo\empty-app)
error: linking with `link.exe` failed: exit code: 1104
  |
  = note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "C:\\Users\\Ryan\\AppData\\Local\\Temp\\rustcNJ3jEb\\symbols.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.1257hvqcejv2esas.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.154g9z7y0aptgnjx.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.1jh6m6of2fdtaiva.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.1le6xr6k633d5oua.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.1q7cii2gkj6euv6j.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.1ydo3euszh2hz1t2.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.2a4p2gezfx8o7b04.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.2myaldmj5ddmgg4w.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.2tk0rhgizd0wvxe9.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.2w2gprf0m1h6q0lx.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.2y8p8v0qydr06cf3.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.35idg17ctgior9bk.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.36uz7b029j2315mt.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.3bwkoty74pdz6amu.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.3fdlugx3abvvia7f.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.3lzhrk82cwog9g8p.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.3n0i5qj47b7geeak.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.3oerapjrylaanokw.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.3rhijsf0sj2fmzpw.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.3tsl0byem3e6pi5z.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.3xcuv3g0b25i0lk2.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.41d17nopm9ygq2zw.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.49pba4io6tsattu1.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.4h80sfpa5ir0v1jx.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.4j2qzqxztwqy1vkn.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.4jiofj70a8xkq48z.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.4mut4cgoeickpysh.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.4rrs5dqwsp16tcpm.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.55ft5o88qgnqov2d.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.5g81v3w50ar3d5d4.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.hov4jpa2cfm36rh.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.mkqwkla4i33xnq0.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.r6khc59illgk30z.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.rbopen7lp82319h.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.s4x4dtyze1igsjm.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.ugfl4fwmllv45lo.rcgu.o" "D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.ofu6q2mga2my6zc.rcgu.o" "/LIBPATH:D:\\repo\\empty-app\\target\\debug\\deps" "/LIBPATH:C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-fdaa63d6970be740.rlib" "C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-a684236a9da37ec6.rlib" "C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-85c151aafb35bf5c.rlib" "C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_detect-7dbe75e48c9029c0.rlib" "C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-78044ac8790346aa.rlib" "C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libminiz_oxide-8743285c70baade8.rlib" "C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libadler-b260ead09cc3ca75.rlib" "C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-200564555b6c364f.rlib" "C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-60e4ae6d068e334f.rlib" "C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-d74559c1731cb9bf.rlib" "C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-3d51e2979c44c27c.rlib" "C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-268ac0a196c81649.rlib" "C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-e74895db82cfb265.rlib" "C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-d805a250e2b7e197.rlib" "C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-3f507ba7adac1c2a.rlib" "kernel32.lib" "advapi32.lib" "userenv.lib" "kernel32.lib" "ws2_32.lib" "bcrypt.lib" "msvcrt.lib" "legacy_stdio_definitions.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.exe" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\Ryan\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
  = note: Non-UTF-8 output: LINK : fatal error LNK1104: \xce\xde\xb7\xa8\xb4\xf2\xbf\xaa\xce\xc4\xbc\xfe\xa1\xb0D:\\repo\\empty-app\\target\\debug\\deps\\empty_app.exe\xa1\xb1\r\n 

error: could not compile `empty-app` due to previous error

Version

cargo 1.65.0 (4bc8f24d3 2022-10-20)
release: 1.65.0
commit-hash: 4bc8f24d3e899462e43621aab981f6383a370365
commit-date: 2022-10-20
host: x86_64-pc-windows-msvc
libgit2: 1.5.0 (sys:0.15.0 vendored)
libcurl: 7.83.1-DEV (sys:0.4.55+curl-7.83.1 vendored ssl:Schannel)
os: Windows 10.0.22623 (Windows 10 Pro) [64-bit]
@ryanroe ryanroe added the C-bug Category: bug label Dec 1, 2022
@weihanglo
Copy link
Member

I feel like #11122 somehow fixes the issue. Could you try with beta toolchain with cargo +beta b?

@ryanroe
Copy link
Author

ryanroe commented Dec 9, 2022

yes , it fixes. 👍

I feel like #11122 somehow fixes the issue. Could you try with beta toolchain with cargo +beta b?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants