cloudflare / boring

BoringSSL bindings for the Rust programming language.
364 stars 110 forks source link

Fails to link on Windows when using Rust 1.78 #235

Closed shahn closed 5 months ago

shahn commented 6 months ago

A trivial program with a dependency only on boring fails to link for me with Rust 1.78 (it worked with 1.77.2):

use boring::x509::X509;

fn main() {
    let _ = X509::from_pem(b"asdf");
}

Rust 1.77.2:

PS C:\tmp\boring> cargo build
   Compiling boring v0.1.0 (C:\tmp\boring)
    Finished dev [unoptimized + debuginfo] target(s) in 1.00s
PS C:\tmp\boring>

stable (1.78):

PS C:\tmp\boring> cargo +stable build

   Compiling boring v0.1.0 (C:\tmp\boring)
error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "C:\\Users\\user\\AppData\\Local\\Temp\\rustc0NHGBX\\symbols.o" "C:\\\tmp\\boring\\target\\debug\\deps\\boring.2jlughmndoexyiwh.rcgu.o" "C:\\\tmp\\boring\\target\\debug\\deps\\boring.2yrexzklv8c4pfhd.rcgu.o" "C:\\\tmp\\boring\\target\\debug\\deps\\boring.3i3wlln2yqe41rgi.rcgu.o" "C:\\\tmp\\boring\\target\\debug\\deps\\boring.4bmx8z19jbrxftdv.rcgu.o" "C:\\\tmp\\boring\\target\\debug\\deps\\boring.vmsglvi7ovexyko.rcgu.o" "C:\\\tmp\\boring\\target\\debug\\deps\\boring.53xuyg0bs05zelmu.rcgu.o" "/LIBPATH:C:\\\tmp\\boring\\target\\debug\\deps" "/LIBPATH:C:\\\tmp\\boring\\target\\debug\\build\\boring-sys-b51cacf343bed7f9\\out/build/crypto/Debug" "/LIBPATH:C:\\\tmp\\boring\\target\\debug\\build\\boring-sys-b51cacf343bed7f9\\out/build/ssl/Debug" "/LIBPATH:C:\\\tmp\\boring\\target\\debug\\build\\boring-sys-b51cacf343bed7f9\\out/build/Debug" "/LIBPATH:C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\\tmp\\boring\\target\\debug\\deps\\libboring-e48545e9b07e8b21.rlib" "C:\\\tmp\\boring\\target\\debug\\deps\\libonce_cell-cdfa8588fc406c03.rlib" "C:\\\tmp\\boring\\target\\debug\\deps\\liblibc-5672dc8f5c8ece50.rlib" "C:\\\tmp\\boring\\target\\debug\\deps\\libboring_sys-5b85f471da5382a6.rlib" "C:\\\tmp\\boring\\target\\debug\\deps\\libforeign_types-3c353a3c6f008471.rlib" "C:\\\tmp\\boring\\target\\debug\\deps\\libforeign_types_shared-3db669988f9cd3a6.rlib" "C:\\\tmp\\boring\\target\\debug\\deps\\libbitflags-e6881f9c7f522b07.rlib" "C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-49e3d1aefc00cc02.rlib" "C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-42f4cb2417289cd4.rlib" "C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-99c77609a4536a8b.rlib" "C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_detect-af9ffb3c6d3f8ec7.rlib" "C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-a6bfe0548f994b2d.rlib" "C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-61f07eb10bc24cc3.rlib" "C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-2fb3f9083307133a.rlib" "C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-6892c9ede6f0d6e6.rlib" "C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-788771c7bce73875.rlib" "C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-8a4c192e8601db8f.rlib" "C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-4bf403d115b018c3.rlib" "C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-48aa4c2213e4ac50.rlib" "C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-34df001b737926cd.rlib" "legacy_stdio_definitions.lib" "kernel32.lib" "advapi32.lib" "kernel32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "kernel32.lib" "ws2_32.lib" "kernel32.lib" "msvcrt.lib" "/NXCOMPAT" "/LIBPATH:C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:C:\\\tmp\\boring\\target\\debug\\deps\\boring.exe" "/OPT:REF,NOICF" "/DEBUG" "/PDBALTPATH:%_PDB%" "/NATVIS:C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\\Rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
  = note: libboring_sys-5b85f471da5382a6.rlib(encrypted_client_hello.obj) : error LNK2019: unresolved external symbol __std_find_trivial_1 referenced in function "unsigned char const * __cdecl __std_find_trivial<unsigned char const ,char>(unsigned char const *,unsigned char const *,char)" (??$__std_find_trivial@$$CBED@@YAPEBEPEBE0D@Z)
          C:\tmp\boring\target\debug\deps\boring.exe : fatal error LNK1120: 1 unresolved externals

error: could not compile `boring` (bin "boring") due to 1 previous error

Already reported to Rust itself here: https://github.com/rust-lang/rust/issues/124839

shahn commented 5 months ago

I figured out the problem, it was related to the Visual Studio tools being outdated. Uninstalling 2019 version of the tools and installing according to https://rust-lang.github.io/rustup/installation/windows-msvc.html worked for me with Rust 1.78.