Repository navigation
Windows link: CodeView instead of DWARF in COFF objects (#1147); one CRT decision read from the link plan (#1267) - #1329
Merged
Conversation
added 2 commits
September 22, 2026 13:35
AsmPrinter emits DWARF whenever the module has no "CodeView" flag or sets "Dwarf Version"; Codegen.w set "Dwarf Version" 5 for every target, so a COFF object carried nine .debug_* sections that lld-link's /debug never read (the PDB is built from CodeView) and warned about on every link: "section name .debug_info is longer than 8 characters and will use a non-standard string table" (lld/COFF/Writer.cpp createSymbolAndStringTable, for each discardable long-named output section). A Windows target now sets the CodeView flag instead, so the PDB holds the debug info the runtime's dbghelp backtraces read; every other target keeps DWARF 5.
The LLVM/Clang SDK archives are built MultiThreaded (static UCRT). Their CRT was chosen in two places: build/compiler.w wrote libcpmt/libcmt into llvm_ld.rsp and set WITH_WINDOWS_CRT_STATIC=1 for its child, while Link.w chose the DLL runtime (msvcrt + ucrt + vcruntime) whenever that variable was unset. The compiler built as a program (with-stage1.exe build out/gen/main.w, the selfhost-windows failure probe) therefore linked libucrt.lib and ucrt.lib together: duplicate _invalid_parameter_noinfo and _wctype. link_stage_windows_crt_static is now the one place that decides, from the link's inputs: a link carrying the LLVM static bridge response file (@…/llvm_ld.rsp) is a static-CRT link; an ordinary program keeps the DLL runtime; WITH_WINDOWS_CRT_STATIC=1 still forces the static one. The rsp carries no CRT any more (the cross rsps never did); the environment override stays set by build/compiler.w for a pinned seed whose Link.w reads only the environment.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two Windows link-path defects, each root-caused and verified on the Windows 10 x64 box (
C:\with-ci\with, LLVM SDK 22.1.6, MSVC 14.51, Kit 10.0.26100, seed v0.15.2.1). One commit per fix.#1147 — nine
lld-link: warning: section name .debug_* is longer than 8 charactersCause.
src/Codegen.wdebug_init_moduleset the module flag"Dwarf Version" = 5for every target and never"CodeView".AsmPrinter::doInitialization(llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:593-604) creates aDwarfDebughandler whenever the CodeView flag is absent or a Dwarf version is set, so every COFF object we emit — user objects and the embedded runtime objects alike — carried DWARF.debug_abbrev/.debug_addr/.debug_info/.debug_line/.debug_line_str/.debug_names/.debug_rnglists/.debug_str/.debug_str_offsets. Link.w links with/debug(=/debug:full), which setsincludeDwarfChunks(lld/COFF/Driver.cpp:1783-1786), so those chunks land in the image as discardable long-named output sections andWriter::createSymbolAndStringTable(lld/COFF/Writer.cpp:1589) warns once per section. The PDB lld builds is made from CodeView, so the DWARF was dead weight in every Windows binary; the runtime's backtraces use dbghelpSymFromAddr, which reads the PDB.Fix. A Windows target sets
"CodeView" = 1and no Dwarf version; every other target keeps DWARF 5. CodeView covers every DI type Codegen emits (lowerTypehandlesDW_TAG_unspecified_type, basic, pointer, struct, member, subroutine).Box before (seed and stage1,
-e 'print("x")'):Seed-built
out/bootstrap-lib/rt_core.osections:.text .data .bss .xdata .rdata… .debug$S .debug_abbrev .debug_info .debug_rnglists .debug_str_offsets .debug_str .debug_addr .debug_names .pdata .debug_line .debug_line_strBox after (branch
src\main.exe build→out/release/bin/with.exe, whose embedded runtime objects are stage2-built):Stage2-compiled
rt/rt_core.wobject sections:.text .data .bss .xdata .rdata… .debug$S .debug$T .pdata; a stage2-compiled user object:.text .data .bss .rdata .debug$S .debug$T. Panic location still resolves (panic at C:/with-ci/tmp/bt.w:1:12: bt). Stage1 on the branch still shows the nine warnings because its embedded runtime objects are seed-built; they go away with the stage2/release compiler and with the next reseed. Darwin stage1 from this branch still emits__debug_*(checked with objdump on a hello object).#1267 —
duplicate symbol: _invalid_parameter_noinfo/_wctype(libucrt.lib vs ucrt.lib)Cause. The CRT was chosen in two places.
build/compiler.wwrotelibcpmt.lib+libcmt.libintoout/*/llvm_ld.rsp(lines 1889-1890) and setWITH_WINDOWS_CRT_STATIC=1for its own child (line 509);src/compiler/Link.wlink_stage_make_windows_llvm_link_command(line 667) addedmsvcprt msvcrt ucrt vcruntimewhenever that variable was unset. The SDK archives are built MultiThreaded (static UCRT) and carry/DEFAULTLIB:libucrtdirectives, sowith-stage1.exe build out/gen/main.w— the compiler as a program, the selfhost-windows failure probe — linked libucrt.lib (via the rsp's libcmt and the archives) and ucrt.lib (from Link.w) together.Fix.
link_stage_windows_crt_static(extras)in Link.w is the one decision, read from the link plan: a link carrying the LLVM static bridge response file (@…/llvm_ld.rsp) is a static-CRT link; an ordinary program keeps the DLL runtime that prebuilt Windows libraries expect;WITH_WINDOWS_CRT_STATIC=1still forces static. The native rsp no longer carries a CRT (the cross rsps never did). build/compiler.w keeps setting the env override because the pinned seed's Link.w reads only the environment.Box before (
out/bootstrap/bin/with-stage1.exe build out/gen/main.w -O1 -o out/probe-before.exe):Box after (branch stage1, same command):
and with the release compiler the same probe links with rc=0 and no warnings at all. (Running that release-built probe then reports
embedded bundle 'pcre2' was built for ABI … but this compiler is WITHABISHASTAMPv1XXXX…: the probe is the unstamped image — build.w'slink-compilerstamps.unstampedafter the link — which is outside both issues and pre-exists them.)Verification
with check src/main.wok;WITH=$PWD/src/main src/main build :devgreen (stage1 160 s).src\main.exe build :devgreen,:stage2green, fullbuildgreen (release compiler linked and running).test/marker; the box run above is the evidence. Battery not run (per instructions).