rust-lang / rust-lang/rust

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

Open
#148,074 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug needs-triage O-windows-msvc
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached test.rs.txt reproducer on x86_64-pc-windows-msvc using the reported nightly rustc and link.exe. Compare exported symbols at 8444 and 8445 characters, then trace the compiler's Windows symbol-export path to identify where the name is split. Done means the long symbol links as one symbol without breaking the existing shorter case.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.