Skip to content

cc/msvc: build blade-test's cc suites (flag translation, framework deps, private incs) - #67

Merged
chen3feng merged 1 commit into
mainfrom
feat/msvc-cc-suites
Jul 5, 2026
Merged

cc/msvc: build blade-test's cc suites (flag translation, framework deps, private incs)#67
chen3feng merged 1 commit into
mainfrom
feat/msvc-cc-suites

Conversation

@chen3feng

Copy link
Copy Markdown
Contributor

Drives blade-go's MSVC backend (#66) against blade-test's real cc suites on Windows. cc_basic (3/3), cc_incs (1/1), cc_export_map (1/1), cc_dll_export (1/1) now build and their tests pass. Four gaps fixed — all gcc/clang behavior unchanged (branch on IsMSVC()):

  1. cc_config gcc-flag translation (mapFlagsToMSVC) — projects write cc_config in gcc syntax and layer MSVC bits in msvc_config. On MSVC, translate -std=c++17/std:c++17, -O2/O2, -D/-I/D//I, -g/Z7, drop gcc-only -W/-m/-f (mirrors Blade's _map_gcc_flags_to_msvc). Also read msvc_config (append_cppflags, warnings, …) and default /SUBSYSTEM:CONSOLE — without it link.exe can't infer the entry point when main() is only in a static lib (gtest_main/test_main) → LNK1561.
  2. Config vocabulary — register the full *_config set (java/scala/go/cuda/lex_yacc/link/coverage/sanitizer/…) so a multi-language BLADE_ROOT loads instead of erroring undefined: java_test_config; blade-go records but ignores the ones it doesn't build.
  3. Framework libs as deps — a cc_test/cc_benchmark's gtest_libs/gtest_main_libs are injected as deps by the graph builder, so a //-target framework (blade-test's test_framework), a #syslib, and a thirdparty/<port> vcpkg lib are all classified and linked by the normal transitive path. Replaces the helper that silently dropped //-target frameworks. Verified flare still links libgtest/libgtest_main.
  4. Private incs — a target's own attr['incs'] (package-relative private include dirs) now goes on its compiles; cc_incs's incs=['include'] resolves greeting.h.

Tests

mapFlagsToMSVC translation; cc_test framework-dep injection + classification; private incs on the compile path. go test ./... green on macOS/arm64; suites verified on Windows 11 ARM64 (VS2026).

Remaining (separate follow-ups)

cc_asm (BUILD parse + ml64/armasm rule), real DLL output for dynamic_link, cc-check-undefined via dumpbin.

Drives blade-go's MSVC backend against blade-test's real cc suites on
Windows. cc_basic, cc_incs, cc_export_map, cc_dll_export now build and
their tests pass (3/3, 1/1, 1/1, 1/1). Four gaps fixed, all gcc/clang
behavior unchanged:

  * cc_config gcc-flag translation (mapFlagsToMSVC): projects write
    cc_config in gcc syntax and layer MSVC bits in msvc_config, so on an
    MSVC toolchain translate -std=c++17 -> /std:c++17, -O2 -> /O2, -D/-I
    -> /D //I, -g -> /Z7, and drop gcc-only -W/-m/-f -- mirroring Blade's
    _map_gcc_flags_to_msvc. Also read msvc_config (append_cppflags,
    warnings, ...) and default /SUBSYSTEM:CONSOLE, without which link.exe
    can't infer the entry point when main() lives in a static lib
    (gtest_main/test_main) -> LNK1561.

  * config vocabulary: register the full set of *_config functions
    (java/scala/go/cuda/lex_yacc/link/coverage/sanitizer/...) so a
    multi-language BLADE_ROOT loads instead of erroring "undefined:
    java_test_config"; blade-go records but ignores the ones it doesn't
    build.

  * framework libs as deps: a cc_test/cc_benchmark's gtest_libs /
    gtest_main_libs (and benchmark_*_libs) are injected as deps by the
    graph builder, so a `//`-target framework (blade-test's
    test_framework), a `#syslib`, and a `thirdparty/<port>` vcpkg lib are
    all classified and linked by the normal transitive path. Replaces the
    old classify-into-vcpkg/syslib helper that silently dropped
    `//`-target frameworks. Verified flare still links libgtest/libgtest_main.

  * private incs: a target's own attr['incs'] (package-relative private
    include dirs) is added to its compiles -- cc_incs's `incs=['include']`
    now resolves `greeting.h`.

Tests: mapFlagsToMSVC translation, cc_test framework-dep injection +
classification, private incs on the compile path. go test ./... green on
macOS/arm64; the suites verified on Windows 11 ARM64 (VS2026).

Remaining (separate): cc_asm (BUILD parse + ml64/armasm rule), real DLL
output for dynamic_link, cc-check-undefined via dumpbin.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chen3feng
chen3feng merged commit b093c4e into main Jul 5, 2026
1 check passed
@chen3feng
chen3feng deleted the feat/msvc-cc-suites branch July 5, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant