Repository navigation
win32: add missing intrin.h/dbghelp.h headers so tcc can build vc/v_win.c (i386) - #98
Conversation
…in.c (i386) Mirrors the fix applied to thirdparty-windows-amd64 in vlang#96. The 32-bit branch's _mingw.h predefines __INTRIN_H_ at line 140, the same guard that silently skipped a ported real intrin.h's body on amd64 - confirmed before porting these files rather than assumed. Neither intrin.h nor dbghelp.h existed on this branch prior to this commit, identical to amd64's pre-vlang#96 state. Co-Authored-By: WOZCODE <contact@withwoz.com>
Per an adversarial review of vlang#98 (2 findings, each confirmed by all 3 independent lenses): - intrin.h cited "_mingw.h line ~146" for the __INTRIN_H_ guard, but that's the amd64 branch's line, carried over unedited from vlang#96. This branch's own line is 140. Dropped the specific number entirely (it will drift again the next time either branch's _mingw.h changes) in favor of pointing at the macro name to grep for. - dbghelp.h claimed the windows.h -> intrin.h -> dbghelp.h include order "has been verified to build" - true on the amd64 sibling (a real forced-MSVC/TCC build was run for vlang#96), not true here: no i386 TCC toolchain or V build target was available to verify this branch, as vlang#98's own description already discloses. The claim as shipped would outlive that disclosure once the PR closes, so a future reader of just this file would take it as settled fact. Removed the claim and pointed at vlang#98 for the real status instead. Co-Authored-By: WOZCODE <contact@withwoz.com>
|
Ran an adversarial review pass on this PR (3 lenses: doc-accuracy, sibling-parity, arch-correctness; 3 adversarial refuters per candidate). 6 raw candidates, all confirmed, collapsing into 2 distinct real issues (the rest were repeat findings of the same two from different lenses):
Both fixed in 2893cc1 - comment-only changes, no No correctness/build-behavior findings survived review - the architecture-correctness lens specifically checked the |
medvednikov
left a comment
There was a problem hiding this comment.
Reviewed the i386 port at 2893cc17d3c30904f509486ace121b3d197473b4, comparing its added headers with #96 and checking relevant definitions in this branch's own _mingw.h, _mingw_unicode.h, and winapi/winnt.h. CI status/results were not considered.
No actionable correctness issue found in the header integration reviewed. A real i386 TinyCC/bootstrap build remains unverified.
The empty intrin.h shim has an independent guard and no missing include dependencies. The latest comment-only changes avoid both the amd64-specific line-number claim and any assertion that this branch has been build-tested.
The DbgHelp wrapper defines _IMAGEHLP64 only under _WIN64; it does not accidentally force the native 32-bit aliases to their 64-bit counterparts. The explicit 64-bit DbgHelp interfaces remain declared alongside the 32-bit variants, as intended. IMAGEAPI retains the branch's WINAPI/stdcall convention. I checked the extra dependencies of the non-_WIN64 IMAGE_DEBUG_INFORMATION declaration: the bundled winnt.h supplies PIMAGE_FUNCTION_ENTRY, PFPO_DATA, and PIMAGE_COFF_SYMBOLS_HEADER. _mingw_unicode.h is also present. The _dbg_common.h blob matches both #96 and upstream mingw-w64 exactly (aa94da4a79260cc06e801c37d6343a3efbda5a48).
The push/pop packing helpers deliberately have no once-only include guard, so repeated pairing restores the caller's packing state. The documented requirement to include <windows.h> before <dbghelp.h> still applies.
Validation: source inspection plus isolated Clang syntax/layout probes of the shim and packing helpers' active contents for both Windows pointer widths. All 12 configurations passed, including an already-defined __INTRIN_H_, repeated inclusion, nested packing restoration, and RC_INVOKED/lint bypasses (-Wno-pragma-pack suppresses the expected cross-header packing-change warning). These are not full DbgHelp/bundled-header compilation or ABI-runtime tests.
Before treating this port as empirically build-verified, the useful remaining check is a real i386 tcc.exe -c smoke test using <windows.h>, <intrin.h>, and <dbghelp.h>, followed by the intended V bootstrap. I did not run either: this environment lacks Windows execution and a V compiler, and direct checkout downloads fail DNS resolution. I am not inferring a passing i386 build from the amd64 report.
|
Did exactly the check you suggested: extracted the real i386 tcc.exe from this branch (with its libtcc.dll and lib/libgc-1.dll dependencies colocated - without them it fails to launch at all with a misleading STATUS_INVALID_IMAGE_FORMAT, not a missing-header error), and ran it against the actual vc/v_win.c using makev.bat's exact build_bootstrap_with_tcc flags, with this PR's headers plus the branch's existing include tree. Result: it gets further than before, but doesn't fully succeed, for two reasons neither of which is in this PR's headers:
So: this PR's own content is fine (confirmed by both the adversarial review and by real compilation getting past the exact code path it touches), but a full i386 bootstrap needs #100 and, more substantially, whatever #99 resolves to. |
Ported from thirdparty-windows-amd64, where this file is a pre-existing part of the base bundle (not something #96/#98 added). It does not exist anywhere on thirdparty-windows-i386. Confirmed via a real build: without this file, compiling vc/v_win.c with this branch's tcc.exe fails at v_win.c:58 on #include <psapi.h>. With it added, the build gets substantially further (to v_win.c:682, an unrelated _Bool/_Atomic feature gap in this branch's older 0.9.27 tcc.exe vs. amd64's 0.9.28rc build - see #99, which this PR does not attempt to fix). The ported file's one arch-sensitive spot (PSAPI_WORKING_SET_BLOCK's VirtualPage bitfield width) already branches correctly on _WIN64, which is unset for this branch's i386 target. Co-Authored-By: WOZCODE <contact@withwoz.com>
|
Follow-up at The head is unchanged from my previous review, which found no actionable correctness issue in this header port. There is no new source fix to re-review, and I am not requesting another code change to these six files based on this follow-up. Thanks for attempting the real i386 bootstrap. The report usefully separates the missing One validation distinction remains: the reported run stops at an error in This follow-up verifies the unchanged head and assesses the new report; it does not claim a new full source review or independent execution of the author's test. I did not run Windows TCC, the standalone smoke test, or a V bootstrap in this pass. The previous source-review conclusion stands; complete i386 bootstrap success is not established by this update. |
|
Ran the standalone Setup
Results
A second file that also calls So the headers in this PR are fine for the i386 branch, and #96's headers already work for a 32-bit target through the amd64 bundle's cross compiler.
The guard is deliberate: CI generates Question for maintainers Not covered: linking or running anything that uses DbgHelp, running any Windows binary (all checks were header parses with Linux-hosted cross builds of the same sources), and the shipped |
Summary
thirdparty-windows-i386per @JalonSolov's question there.include/intrin.h,include/dbghelp.h, and dbghelp's dependenciespoppack.h,pshpack4.h,psdk_inc/_dbg_LOAD_IMAGE.h,psdk_inc/_dbg_common.h) from win32: add missing intrin.h/dbghelp.h headers so tcc can build vc/v_win.c #96's fix, unchanged.Why this is needed here too
Verified before porting rather than assumed:
thirdparty-windows-i386'sinclude/_mingw.hpredefines__INTRIN_H_at line 140 - the exact same guard onthirdparty-windows-amd64(line 146) that made a naive port of the realintrin.ha silent no-op in #96 (its body gets skipped unless this macro is absent). Neitherinclude/intrin.hnorinclude/dbghelp.hexisted on this branch beforehand, matching amd64's pre-#96 state exactly.This path is real, but has no CI coverage anywhere
Checked before assuming -
thirdparty-windows-i386is not dead code:vlang/v'smakev.bathas a documented-tcc32flag that forces this branch, and it's also the automatic default on a 32-bit Windows host (PROCESSOR_ARCHITECTURE == x86). There's a dedicated:tcc32_strapbootstrap routine parallel to the amd64 one.vlang/vGitHub Actions workflow exercises-tcc32or a 32-bit host, andvlang/tccbinitself has no.github/workflowsdirectory at all - nothing in CI validates any branch here, i386 or amd64.So this fixes a real gap on a genuinely reachable code path, but neither this fix nor the original bug it mirrors would ever be caught by CI. That raises the stakes on the test-plan gap below rather than lowering them.
Test plan
git diffshows the same 2320 insertions across the same 6 files).tcc.exe+vc/v_win.cin this session (no i386 TCC toolchain or i386 V build target available here, unlike the amd64 fix which was verified with a real forced-MSVC/TCC build). Flagging this gap explicitly rather than claiming parity I haven't tested.🧙 Built with WOZCODE