Skip to content

Linking fails when using mimalloc on Windows with current nightly builds #140041

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

Closed
Greatness7 opened this issue Apr 19, 2025 · 1 comment
Closed
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Greatness7
Copy link

Code

My CI actions have started to fail on the linking stage in nightly builds (on Windows).

The error messages indicated it was something to do with mimalloc and indeed trying to compile a minimal test with mimalloc on --release triggers the same errors.

use mimalloc::MiMalloc;

#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;

fn main() {
    println!("Hello, world!");
}

Version it worked on

nightly-2025-03-09

Version with regression

nightly-2025-03-10

All versions I tried after 2025-03-10 are also experiencing this issues.

Backtrace

error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Users\\Admin\\Programs\\VisualStudio\\2022\\Community\\VC\\Tools\\MSVC\\14.43.34808\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "C:\\Users\\Admin\\AppData\\Local\\Temp\\rustc76KEBa\\symbols.o" "<2 object files omitted>" "C:\\Users\\Admin\\Projects\\test_mimalloc\\target\\release\\deps/{libmimalloc-ad67d45c7a502e86.rlib,liblibmimalloc_sys-b9c6bcbae022bf4a.rlib,liblibc-fa9e52f7b8cff268.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"
"legacy_stdio_definitions.lib" "kernel32.lib" "kernel32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib"
"dbghelp.lib" "/defaultlib:msvcrt" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Admin\\Programs\\VisualStudio\\2022\\Community\\VC\\Tools\\MSVC\\14.43.34808\\atlmfc\\lib\\x64" "/LIBPATH:C:\\Users\\Admin\\Projects\\test_mimalloc\\target\\release\\build\\libmimalloc-sys-3b898ff4937b9f62\\out" "/OUT:C:\\Users\\Admin\\Projects\\test_mimalloc\\target\\release\\deps\\test_mimalloc.exe" "/OPT:REF,ICF" "/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"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: liblibmimalloc_sys-b9c6bcbae022bf4a.rlib(5a07bf3761bb5df8-static.o) : error LNK2019: unresolved external symbol __imp_OpenProcessToken referenced in function win_enable_large_os_pages␍
          liblibmimalloc_sys-b9c6bcbae022bf4a.rlib(5a07bf3761bb5df8-static.o) : error LNK2019: unresolved external symbol __imp_AdjustTokenPrivileges referenced in function win_enable_large_os_pages␍
          liblibmimalloc_sys-b9c6bcbae022bf4a.rlib(5a07bf3761bb5df8-static.o) : error LNK2019: unresolved external symbol __imp_LookupPrivilegeValueA referenced in function win_enable_large_os_pages␍
          C:\Users\Admin\Projects\test_mimalloc\target\release\deps\test_mimalloc.exe : fatal error
LNK1120: 3 unresolved externals
@Greatness7 Greatness7 added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Apr 19, 2025
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 19, 2025
@jieyouxu
Copy link
Member

jieyouxu commented Apr 19, 2025

You need to explicitly link in advapi32.lib after #138233 since std no longer links in advapi32.lib. Duplicate of #139352, cf. #138621 and #139619.

@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-discussion Category: Discussion or questions that doesn't represent real issues. and removed C-bug Category: This is a bug. I-prioritize Issue: Indicates that prioritization has been requested for this issue. regression-untriaged Untriaged performance or correctness regression. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 19, 2025
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants