Skip to content

Regression: linker error 1120 on Windows / Beta #140555

Closed as duplicate of#139352
Closed as duplicate of#139352
@SWilson4

Description

@SWilson4

I'm one of the maintainers of liboqs, an open-source C library for post-quantum cryptography. One of our other projects is a Rust wrapper for the library. We run tests in CI on Linux / Mac / Windows with Stable / Beta / Nightly Rust.

Some time ago, our Windows / Nightly builds started failing with what appears to be a linker error. I am fairly certain that this is due to a change in Rust, as CI had previously passed on the same commit, and I don't believe there were any GitHub runner updates. The same error is now causing our Beta Rust builds to fail. These had previously passed, which seems to confirm that it is indeed a change in Rust triggering the failure.

I am unfortunately out of my depth when dealing with the intricacies of Rust and Windows, but I thought it best to report it here.

Code

Here is a failing GitHub Actions run. I've also copied the relevant portion of the logs below in the backtrace section.

I expected the build to pass, as it had previously on the same commit.

Version it worked on

It most recently worked on: beta-x86_64-pc-windows-msvc - rustc 1.86.0-beta.7 (7824ede 2025-03-22)

Version with regression

beta-x86_64-pc-windows-msvc - rustc 1.87.0-beta.4 (a594829 2025-04-12)

Backtrace

Backtrace

cargo test
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
  env:
    RUST_MIN_STACK: 20971520
    RUSTFLAGS: -C link-arg=/STACK:20971520
    LLVM_PATH: D:\a\_temp\llvm
    LD_LIBRARY_PATH: D:\a\_temp\llvm\lib;
    DYLD_LIBRARY_PATH: D:\a\_temp\llvm\lib;undefined
    LIBCLANG_PATH: D:\a\_temp\llvm\bin\
    OPENSSL_ROOT_DIR: C:/Program Files/OpenSSL
    CARGO_TERM_COLOR: always
    CARGO_INCREMENTAL: 0
    RUST_BACKTRACE: 1
    CACHE_ON_FAILURE: false
   Compiling oqs-sys v0.10.1+liboqs-0.12.0 (D:\a\liboqs-rust\liboqs-rust\oqs-sys)
   Compiling oqs v0.10.1 (D:\a\liboqs-rust\liboqs-rust\oqs)
error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.43.34808\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\rustchMnDTj\\symbols.o" "<9 object files omitted>" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib/{libtest-*,libgetopts-*,libunicode_width-*,librustc_std_workspace_std-*}.rlib" "D:\\a\\liboqs-rust\\liboqs-rust\\target\\debug\\deps/{liboqs_sys-332d94876817d713.rlib,liblibc-124eb4bee469bbec.rlib}.rlib" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib/{libstd-*,libpanic_unwind-*,libwindows_targets-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libunwind-*,libcfg_if-*,liballoc-*,librustc_std_workspace_core-*,libcore-*,libcompiler_builtins-*}.rlib" "kernel32.lib" "C:/Program Files/OpenSSL\\lib\\libcrypto.lib" "D:\\a\\liboqs-rust\\liboqs-rust\\target\\debug\\build\\oqs-sys-c82817a9d50dfd24\\out\\lib\\oqs.lib" "legacy_stdio_definitions.lib" "kernel32.lib" "kernel32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "dbghelp.lib" "/defaultlib:msvcrt" "/NXCOMPAT" "/LIBPATH:C:/Program Files/OpenSSL\\lib" "/LIBPATH:D:\\a\\liboqs-rust\\liboqs-rust\\target\\debug\\build\\oqs-sys-c82817a9d50dfd24\\out\\lib" "/LIBPATH:D:\\a\\liboqs-rust\\liboqs-rust\\target\\debug\\build\\oqs-sys-c82817a9d50dfd24\\out\\lib64" "/OUT:D:\\a\\liboqs-rust\\liboqs-rust\\target\\debug\\deps\\oqs-5ff10ce6b35c7119.exe" "/OPT:REF,NOICF" "/DEBUG" "/PDBALTPATH:%_PDB%" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\libstd.natvis" "/STACK:20971520"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note:    Creating library D:\a\liboqs-rust\liboqs-rust\target\debug\deps\oqs-5ff10ce6b35c7119.lib and object D:\a\liboqs-rust\liboqs-rust\target\debug\deps\oqs-5ff10ce6b35c7119.exp␍
          LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library␍
          oqs.lib(rand.obj) : error LNK2019: unresolved external symbol __imp_CryptAcquireContextA referenced in function OQS_randombytes_system␍
          oqs.lib(rand.obj) : error LNK2019: unresolved external symbol __imp_CryptReleaseContext referenced in function OQS_randombytes_system␍
          oqs.lib(rand.obj) : error LNK2019: unresolved external symbol __imp_CryptGenRandom referenced in function OQS_randombytes_system␍
          D:\a\liboqs-rust\liboqs-rust\target\debug\deps\oqs-5ff10ce6b35c7119.exe : fatal error LNK1120: 3 unresolved externals␍
          

error: could not compile `oqs` (lib test) due to 1 previous error
Error: Process completed with exit code 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions