Skip to content

[x86_64-pc-windows-gnullvm] Can't build proc macros using rust-lld, failing with undefined symbol: _DllMainCRTStartup #149813

@ColinFinck

Description

@ColinFinck

I created a new library using cargo new --lib testlib and turned it into a proc-macro by adding

[lib]
proc-macro = true

to its Cargo.toml. I also emptied its lib.rs.

Using nightly-2025-12-08-x86_64-pc-windows-gnullvm with RUSTFLAGS=-Clinker=rust-lld (as recommended in #146634 (comment)), I try to build it via cargo build.

I'm reproducibly getting the error:

   Compiling testlib v0.1.0 (C:\Users\Colin\testlib)
error: linking with `rust-lld` failed: exit code: 1
  |
  = note: "rust-lld" "-flavor" "gnu" "C:\\Users\\Colin\\AppData\\Local\\Temp\\rustcp7FqZO\\list.def" "-m" "i386pep" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-gnullvm\\lib\\self-contained\\dllcrt2.o" "C:\\Users\\Colin\\AppData\\Local\\Temp\\rustcp7FqZO\\symbols.o" "<1 object files omitted>" "C:\\Users\\Colin\\AppData\\Local\\Temp\\rustcp7FqZO\\rmeta.o" "<1 object files omitted>" "-Bstatic" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-gnullvm\\lib/{libproc_macro-*,librustc_literal_escaper-*,librustc_std_workspace_std-*,libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libcfg_if-*,libwindows_targets-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Bdynamic" "-lkernel32" "-lkernel32" "-lkernel32" "-lntdll" "-luserenv" "-lws2_32" "-ldbghelp" "-lunwind" "-lmingw32" "-lmingwex" "-lmsvcrt" "-lkernel32" "-luser32" "--nxcompat" "-L" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-gnullvm\\lib\\self-contained" "-o" "C:\\Users\\Colin\\testlib\\target\\debug\\deps\\testlib-0a32fbaff21869e9.dll" "--gc-sections" "-shared" "--out-implib=C:\\Users\\Colin\\testlib\\target\\debug\\deps\\libtestlib-0a32fbaff21869e9.dll.a"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: rust-lld: error: <root>: undefined symbol: _DllMainCRTStartup

This works fine for the x86_64-pc-windows-msvc target.

CC @mati865

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lldArea: Linkage issues specific to rust-lldC-external-bugCategory: issue that is caused by bugs in software beyond our control

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions