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

Trivial program depending on the "boring" crate fails to link with current stable Rust (1.78) on Windows #124839

Closed
shahn opened this issue May 7, 2024 · 3 comments
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues.

Comments

@shahn
Copy link
Contributor

shahn commented May 7, 2024

A trivial crate only depending on the boring crate fails to to link on Windows since Rust 1.78

use boring::x509::X509;

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

This works with 1.77.2-x86_64-pc-windows-msvc:

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>

On stable, this happens:

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
@shahn shahn added the C-bug Category: This is a bug. label May 7, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 7, 2024
@ChrisDenton
Copy link
Contributor

I think it would be better to report this to the boring repo first as they'll likely have the most context for what could be going wrong with your build. I'm not able to reproduce this myself.

__std_find_trivial_1 looks like an internal symbol for the MSVC C++ runtime so not directly to do with Rust itself. One thing that can cause that issue is mixing different runtimes together but that's unlikely to be the case in a trivial crate.

@shahn
Copy link
Contributor Author

shahn commented May 7, 2024

Also reported to boring here: cloudflare/boring#235 I thought this repo here was more appropriate as it works with the previous stable.

@shahn
Copy link
Contributor Author

shahn commented May 13, 2024

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. Thanks!

@shahn shahn closed this as completed May 13, 2024
@jieyouxu jieyouxu added C-discussion Category: Discussion or questions that doesn't represent real issues. and removed C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues.
Projects
None yet
Development

No branches or pull requests

4 participants