Skip to content

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

Closed as duplicate of#139352
@Greatness7

Description

@Greatness7

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-discussionCategory: Discussion or questions that doesn't represent real issues.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions