Skip to content

Exporting symbols with 8445 characters or more gets them subdivided into multiple symbols on Windows #148074

@Fulgen301

Description

@Fulgen301

I tried this code (reproducer attached: test.rs.txt):

#[unsafe(no_mangle)]
fn AAAA....8445 As in total....A() {}

I expected to see this happen: It works.

Instead, this happened: It gets turned into two symbols:

error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Program Files\\Microsoft Visual Studio\\18\\Insiders\\VC\\Tools\\MSVC\\14.50.35503\\bin\\HostX64\\x64\\link.exe" "/DEF:C:\\Users\\tokgeo\\AppData\\Local\\Temp\\rustc6LxeaL\\lib.def" "/NOLOGO" "C:\\Users\\tokgeo\\AppData\\Local\\Temp\\rustc6LxeaL\\symbols.o" "<2 object files omitted>" "<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-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "kernel32.lib" "kernel32.lib" "kernel32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "dbghelp.lib" "/defaultlib:msvcrt" "/NXCOMPAT" "/OUT:test.dll" "/OPT:REF,NOICF" "/DLL" "/IMPLIB:test.dll.lib" "/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: lib.def : error LNK2001: Nicht aufgelöstes externes Symbol "A".␍
          lib.def : error LNK2001: Nicht aufgelöstes externes Symbol "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

followed by the rest of the As.

Keeping the symbol name at <= 8444 characters links with no issues.

Meta

rustc --version --verbose:

rustc 1.92.0-nightly (1d23d0680 2025-10-22)
binary: rustc
commit-hash: 1d23d06800271f651fad07bf22bf5e298138972e
commit-date: 2025-10-22
host: x86_64-pc-windows-msvc
release: 1.92.0-nightly
LLVM version: 21.1.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-windows-msvcToolchain: MSVC, Operating system: Windowsneeds-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions