Unpin cc and upgrade to the latest version by tgross35 · Pull Request #131070 · rust-lang/rust (original) (raw)

I've recently tried to update the nightly we use in Wasmtime's CI and it's failing. After that I minimized the CI failure and ran a "bisection on github" which yielded this regression range. Within that range is this PR updating the cc crate, and the specific error we're running into looks like:

CUSTOMBUILD : error : linking with `link.exe` failed: exit code: 1120 [D:\a\wasmtime\wasmtime\target\c-api-build\wasmtime-crate.vcxproj]
    |
    = note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX64\\x64\\link.exe" "/DEF:C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\rustcQmo3vX\\lib.def" "/NOLOGO" "C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\rustcQmo3vX\\symbols.o" "D:\\a\\wasmtime\\wasmtime\\target\\aarch64-pc-windows-msvc\\release\\deps\\wasmtime.wasmtime.5d0bb5c93767783-cgu.0.rcgu.o" "C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\rustcQmo3vX\\libwasmtime-23b1ceb4a4c3125e.rlib" "C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\rustcQmo3vX\\libstd-cc044fac50b9bc2f.rlib" "D:\\a\\wasmtime\\wasmtime\\target\\aarch64-pc-windows-msvc\\release\\deps\\libcompiler_builtins-bac3a61622f83a04.rlib" "legacy_stdio_definitions.lib" "C:\\Users\\runneradmin\\.cargo\\registry\\src\\index.crates.io-6f17d22bba15001f\\windows_aarch64_msvc-0.52.6\\lib\\windows.0.52.0.lib" "kernel32.lib" "kernel32.lib" "advapi32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "dbghelp.lib" "/defaultlib:libcmt" "/NXCOMPAT" "/LIBPATH:C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.41.34120\\atlmfc\\lib\\arm64" "/LIBPATH:D:\\a\\wasmtime\\wasmtime\\target\\aarch64-pc-windows-msvc\\release\\build\\wasmtime-e3ab72304732b115\\out" "/LIBPATH:C:\\Users\\runneradmin\\.cargo\\registry\\src\\index.crates.io-6f17d22bba15001f\\windows_aarch64_msvc-0.52.6\\lib" "/OUT:D:\\a\\wasmtime\\wasmtime\\target\\aarch64-pc-windows-msvc\\release\\deps\\wasmtime.dll" "/OPT:REF,ICF" "/DLL" "/IMPLIB:D:\\a\\wasmtime\\wasmtime\\target\\aarch64-pc-windows-msvc\\release\\deps\\wasmtime.dll.lib" "/DEBUG" "/PDBALTPATH:%_PDB%" "/NATVIS:C:\\Users\\runneradmin\\.rustup\\toolchains\\nightly-2024-10-03-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\runneradmin\\.rustup\\toolchains\\nightly-2024-10-03-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\runneradmin\\.rustup\\toolchains\\nightly-2024-10-03-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\runneradmin\\.rustup\\toolchains\\nightly-2024-10-03-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
    = note:    Creating library D:\a\wasmtime\wasmtime\target\aarch64-pc-windows-msvc\release\deps\wasmtime.dll.lib and object D:\a\wasmtime\wasmtime\target\aarch64-pc-windows-msvc\release\deps\wasmtime.dll.expΓÉì
wasmtime.wasmtime.5d0bb5c93767783-cgu.0.rcgu.o : error LNK2019: unresolved external symbol memcpy referenced in function _ZN132_$LT$alloc..vec..Vec$LT$T$C$A$GT$$u20$as$u20$alloc..vec..spec_extend..SpecExtend$LT$$RF$T$C$core..slice..iter..Iter$LT$T$GT$$GT$$GT$11spec_extend17hd634bb8c4092ac00EΓÉì [D:\a\wasmtime\wasmtime\target\c-api-build\wasmtime-crate.vcxproj]
...
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.41.34120\lib\x64\legacy_stdio_definitions.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'ARM64'ΓÉì [D:\a\wasmtime\wasmtime\target\c-api-build\wasmtime-crate.vcxproj]
C:\Program Files (x86)\Windows Kits\10\lib\10.0.20348.0\um\x64\kernel32.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'ARM64'ΓÉì [D:\a\wasmtime\wasmtime\target\c-api-build\wasmtime-crate.vcxproj]
C:\Program Files (x86)\Windows Kits\10\lib\10.0.20348.0\um\x64\advapi32.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'ARM64'ΓÉì [D:\a\wasmtime\wasmtime\target\c-api-build\wasmtime-crate.vcxproj]
C:\Program Files (x86)\Windows Kits\10\lib\10.0.20348.0\um\x64\ntdll.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'ARM64'ΓÉì [D:\a\wasmtime\wasmtime\target\c-api-build\wasmtime-crate.vcxproj]
C:\Program Files (x86)\Windows Kits\10\lib\10.0.20348.0\um\x64\userenv.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'ARM64'ΓÉì [D:\a\wasmtime\wasmtime\target\c-api-build\wasmtime-crate.vcxproj]
C:\Program Files (x86)\Windows Kits\10\lib\10.0.20348.0\um\x64\ws2_32.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'ARM64'ΓÉì [D:\a\wasmtime\wasmtime\target\c-api-build\wasmtime-crate.vcxproj]
C:\Program Files (x86)\Windows Kits\10\lib\10.0.20348.0\um\x64\dbghelp.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'ARM64'ΓÉì [D:\a\wasmtime\wasmtime\target\c-api-build\wasmtime-crate.vcxproj]
D:\a\wasmtime\wasmtime\target\aarch64-pc-windows-msvc\release\deps\wasmtime.dll : fatal error LNK1120: 15 unresolved externalsΓÉì [D:\a\wasmtime\wasmtime\target\c-api-build\wasmtime-crate.vcxproj]
            
  
CUSTOMBUILD : error : could not compile `wasmtime-c-api` (lib) due to 1 previous error [D:\a\wasmtime\wasmtime\target\c-api-build\wasmtime-crate.vcxproj]

I unfortunately can't reproduce this locally and I think it's likely relatively specific to the setup of CI. I for example don't know what toolchain components are installed on github actions on Windows for the various bits and pieces here.

All that's to say that I think this PR's update is the likely cause of the build issue we're running into. I certainly won't go so far as to say that this is the component at fault, it's probably just uncovering something about how we're configuring CI wrong or something like that.

Specifically the shape of the issue is:

If I had to hazard a guess what I would suspect is happening is that MSBuild doesn't know it's doing a cross compile (I have no idea how one would configure it to do so if this is the case) and so it's setting some env vars which this cc crate update is then picking up and forwarding to rustc and somehow causing x64 libs to be used instead of arm64 libs.

Apologies for the long explanation here, but what I wanted to ask here is (a) if this is a known "change" that might happen with updating cc and (b) is there someone who might be best to ping about this and help figure out a good solution here? (e.g. an issue here, an issue on cc, just go fix this in Wasmtime, etc)