[SAOC 2026] ImportC Weekly Update #6

Niyati Jain niyati.jainn15 at gmail.com
Fri Oct 30 06:42:03 UTC 2026


**SAOC 2026: ImportC Weekly Update #6**

This week I finally got SQLite's amalgamation compiling and 
linking through ImportC on Windows.

The blocker from last update is fixed: taking the address of a 
`dllimport` function in a static initializer was asserting in 
`dcast.d` instead of just working, which is exactly what SQLite's 
static syscall table in `os_win.c` does. Allowed it properly, 
with a regression test 
(https://github.com/niy-ati/dmd/blob/importc-forceinline-dce/compiler/test/runnable/test20270b.c).

That also confirmed the root cause behind `#20270` 
(https://github.com/dlang/dmd/issues/20270), unreferenced 
`__forceinline` wrappers in `windows.h`, which no longer 
reproduces.

`__va_start` is implemented for MSVC-style varargs (`#20374`, 
https://github.com/dlang/dmd/issues/20374). `vadefs.h`/`stdarg.h` 
define `va_start` in terms of it on x64, so it needed a 
parser-level rewrite into a call to `core.stdc.stdarg.va_start`, 
otherwise it would bind to a wrapper function's own stack frame 
instead of the real caller's.

Also fixed `#20709` (https://github.com/dlang/dmd/issues/20709), 
the `size_t`/object-import identifier conflict that was blocking 
SQLite and curl from compiling alongside druntime.

The other MSVC intrinsics SQLite and `windows.h` pull in, 
`_ReadWriteBarrier`, `_InterlockedCompareExchange`, `__umulh`, 
and about 30 more that just needed declaring through ImportC's 
existing `function_decl(ignore, ...)` pragma rather than new 
codegen, since they're resolved by the real MSVC runtime at link 
time.

zlib now compiles, links, and runs through ImportC against the 
real `zlib.h` on Windows and Linux.

On `#21266` (https://github.com/dlang/dmd/issues/21266): the 
version I reverted last update had a bug, the scan for 
unreferenced `inline`/`__forceinline` functions ran after the 
normal inliner had already rewritten those call sites, so it 
could never see the real uses. Fixed it by scanning earlier and 
checking the resolved call target directly, with a regression 
test 
(https://github.com/niy-ati/dmd/blob/importc-forceinline-dce/compiler/test/runnable/test21266.c), going through review with Nicholas on the rest of it now.
Branch: 
https://github.com/niy-ati/dmd/tree/importc-forceinline-dce

Next week I'm moving on to curl's `schannel.c` for the Windows 
TLS backend, then regression tests for the intrinsics that only 
needed declaring so far.

Feedback and questions are welcome.

Best,
Niyati


More information about the Digitalmars-d mailing list