Rust project now fails to link with MSVC: failure during conversion to COFF: file invalid or corrupt

Hey y'all :slight_smile:
Back in 2021, a Rust project of mine used to compile and run successfully with nightly-2021-08-14.
Now I wanted to revive this project & compile it but some deps didn't compile with the old nightly, so I upgraded the nightly in the rust-toolchain file to nightly-2024-08-01.
After updating the code (catching up with all the things that changed in the nightly since then, such as box -> Box::new) it compiles fine, but it fails to link, any idea why?
I'm always getting this error:

error: linking with `link.exe` failed: exit code: 1123
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "C:\\Users\\me\\AppData\\Local\\Temp\\rustc4DB9cm\\symbols.o" "D:\\proj\\target\\release\\deps\\proj.proj.e1f6d66c0a3659b5-cgu.0.rcgu.o" "/LIBPATH:D:\\proj\\target\\release\\deps" "/LIBPATH:D:\\proj\\target\\release\\build\\proj-a435a92ee1325e51\\out" "/LIBPATH:D:\\proj\\target\\release\\build\\blake3-0165509668cf7289\\out" "/LIBPATH:D:\\proj\\target\\release\\build\\blake3-0165509668cf7289\\out" "/LIBPATH:D:\\dev\\3rdparty\\_libs-x64" "/LIBPATH:C:\\Users\\me\\scoop\\persist\\rustup\\.cargo\\registry\\src\\index.crates.io-6f17d22bba15001f\\windows_x86_64_msvc-0.52.6\\lib" "/LIBPATH:D:\\proj\\target\\release\\build\\gui-68b3ab57e9f12b01\\out" "/LIBPATH:D:\\proj\\target\\release\\build\\imgui-sys-f068edb3bb8f0d32\\out" "/LIBPATH:D:\\proj\\target\\release\\build\\brotli-sys-d5c4d525ad9af481\\out" "/LIBPATH:C:\\Users\\me\\scoop\\persist\\rustup\\.rustup\\toolchains\\nightly-2024-08-01-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "resource.lib" "C:\\Users\\me\\AppData\\Local\\Temp\\rustc4DB9cm\\libimgui_sys-4e794d072441861e.rlib" "C:\\Users\\me\\AppData\\Local\\Temp\\rustc4DB9cm\\libbrotli_sys-d88c750fa964a47a.rlib" "C:\\Users\\me\\AppData\\Local\\Temp\\rustc4DB9cm\\libblake3-e9bea6e998b6787f.rlib" "C:\\Users\\me\\AppData\\Local\\Temp\\rustc4DB9cm\\libstd-39d183c18e3d9b62.rlib" "C:\\Users\\me\\scoop\\persist\\rustup\\.rustup\\toolchains\\nightly-2024-08-01-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-52cf0af3505933f1.rlib" "resource.lib" "opengl32.lib" "iphlpapi.lib" "ws2_32.lib" "kernel32.lib" "windows.0.52.0.lib" "windows.0.52.0.lib" "windows.0.52.0.lib" "windows.0.52.0.lib" "advapi32.lib" "bcrypt.lib" "advapi32.lib" "legacy_stdio_definitions.lib" "sqlite3.lib" "advapi32.lib" "cfgmgr32.lib" "comctl32.lib" "credui.lib" "dwmapi.lib" "fwpuclnt.lib" "gdi32.lib" "imm32.lib" "kernel32.lib" "msimg32.lib" "ntdll.lib" "ole32.lib" "opengl32.lib" "secur32.lib" "shcore.lib" "shell32.lib" "shlwapi.lib" "synchronization.lib" "user32.lib" "uxtheme.lib" "winspool.lib" "ws2_32.lib" "kernel32.lib" "advapi32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "kernel32.lib" "kernel32.lib" "/defaultlib:msvcrt" "/NXCOMPAT" "/LIBPATH:C:\\Users\\me\\scoop\\persist\\rustup\\.rustup\\toolchains\\nightly-2024-08-01-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:D:\\proj\\target\\release\\deps\\proj.exe" "/OPT:REF,ICF" "/DEBUG" "/PDBALTPATH:%_PDB%" "/NATVIS:C:\\Users\\me\\scoop\\persist\\rustup\\.rustup\\toolchains\\nightly-2024-08-01-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\me\\scoop\\persist\\rustup\\.rustup\\toolchains\\nightly-2024-08-01-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\me\\scoop\\persist\\rustup\\.rustup\\toolchains\\nightly-2024-08-01-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\me\\scoop\\persist\\rustup\\.rustup\\toolchains\\nightly-2024-08-01-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
  = note: CVTRES : fatal error CVT1100: duplicate resource.  type:VERSION, name:1, language:0x0409
          LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt

(Full error with word wrap for easier readability: https://dpaste.com/F2H43DQVG#wrap)

I already tried cargo clean several times and updating my MSVC build essentials.
Same error! Any idea why?
I'd appreciate any hint! :slight_smile:

1 Like

Ah, I figured it out:
Both the top-level crate and a sub-crate are using winres in their build.rs to set the version (and for some reason that didn't cause an error in 2021).

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.