[SAOC 2026] ImportC Weekly Update #7
Niyati Jain
niyati.jainn15 at gmail.com
Thu Nov 5 09:28:06 UTC 2026
**SAOC 2026: ImportC Weekly Update #7**
This week I mainly worked on the dead-code scanner from last
update, the SEH catch-variable linkage, and getting curl, zlib
and sqlite actually verified against real MSVC headers.
`#24138` (https://github.com/dlang/dmd/pull/24138), from last
update's dead-code scanner for `#21266`, is now merged, which
then real `windows.h` broke it: two `__forceinline` functions
that only call each other, `RtlZeroVolatileMemory` calling
`RtlFillVolatileMemory`, nothing else calls either one, both got
kept alive, each vouching for the other, is fixed as `#24144`
(https://github.com/dlang/dmd/pull/24144), and rewritten as a
worklist, where a candidate's own body only gets scanned once
something outside the candidate set has already proven it's used.
But that fix had a bug of its own, which took me a while to
actually catch it. I'd tracked candidates in a
`bool[FuncDeclaration]` keyed by class reference that was fine on
every normal build, and failed only when dmd itself got built by
an old bootstrap compiler or by LDC, same thing that I'd already
faced earlier with `importCInlineReferenced`. Plain field on
`FuncDeclaration` instead, no AA. Tested it against the real
bootstrap/LDC matrix on a throwaway branch.
While I was on the SEH side of things, Nicholas asked whether one
can tell a `catch(Throwable)` apart from one that was synthesized
by ImportC lowering a C file's `__try`/`__except`, versus one
written in D. Turns out it's `Catch.internalCatch` plus the
enclosing module's filetype, and chasing that down is what led to
`#24141` (https://github.com/dlang/dmd/pull/24141): a catch
variable inside an `extern(C)` function was picking up C linkage
from the enclosing scope instead of D linkage, which broke
codegen for exactly this kind of synthesized catch.
`#24139` (https://github.com/dlang/dmd/pull/24139) also merged:
ImportC's `static` C globals were getting D's `static` instead of
C's actual internal linkage.
curl's real Windows TLS backend, `lib/vtls/schannel.c`, compiles
clean through ImportC against real `windows.h`/SSPI now.
sqlite's amalgamation compiles, links, and runs a real
create/insert/select through ImportC on both Windows and Linux.
`SQLITE_OMIT_SEH` on Windows, since ImportC can't give
`__try`/`__except` the exception context it needs,
`-U__SIZEOF_INT128__` on Linux so glibc's headers stop pulling in
a type dmd doesn't have, so I built the same amalgamation twice,
once through ImportC and once through a real `cl.exe` build on
sqlite's normal SEH path, and diffed the output: byte-for-byte
identical `sqlite3_libversion()`, with same query result both
times. zlib against real vcpkg `zlib.h` checks out the same way.
Next week: I'll work on regression tests for the intrinsics that
only needed declaring, and then start the macro survey for
Milestone 3.
Feedback and questions are welcome.
Thanks to Nicholas for the guidance throughout.
Best,
Niyati
More information about the Digitalmars-d
mailing list