Skip to content

toolchain: MSVC file-naming on Windows (obj/lib/dll), parity with Python - #65

Merged
chen3feng merged 1 commit into
mainfrom
feat/msvc-toolchain-naming
Jul 3, 2026
Merged

toolchain: MSVC file-naming on Windows (obj/lib/dll), parity with Python#65
chen3feng merged 1 commit into
mainfrom
feat/msvc-toolchain-naming

Conversation

@chen3feng

Copy link
Copy Markdown
Contributor

What

blade-go's toolchain hard-coded gcc/clang file names (obj .o, static lib lib<name>.a) regardless of OS, so on Windows it emitted Unix names for what is an MSVC target. This mirrors Blade's toolchain naming properties, keyed on the OS (Windows == MSVC; blade-go doesn't do MinGW):

gcc/clang MSVC
ObjSuffix .o .obj
StaticLib lib<n>.a <n>.lib
DynamicLib (new) lib<n>.so / lib<n>.dylib <n>.dll
BinName <n> <n>.exe (already present)

Plus an IsMSVC() helper (the cc_is('msvc') analog).

Test fallout (fixed here)

Making the naming correct exposed unit tests that hard-coded .o/.a/no-.exe in generated-ninja assertions — they only passed on Windows before because the toolchain was wrongly emitting Unix names. Those tests now derive expected file names from the toolchain (cc: structure/proto/gen_rule/header-only; build: generates-ninja/resource/link_all_symbols/header-x-cpp), and bladectx's abspath test checks filepath.IsAbs instead of a leading /.

Verified

go test ./... green on macOS/arm64 and Windows 11/arm64 (found while running blade-go's suite on Windows — previously 3 packages / several tests failed there). New toolchain_test.TestNaming pins all three conventions.

Note: this is the naming layer only. A full MSVC build backend (compile rules, deps=msvc, /WHOLEARCHIVE: force-load, .lib/.obj in the link commands) is separate future work.

blade-go's toolchain hard-coded gcc/clang names (obj '.o', static lib
'lib<name>.a') regardless of OS, so on Windows it emitted Unix names for
what is an MSVC target. Mirror Blade's toolchain naming properties, keyed
on the OS (Windows == MSVC, no MinGW):

  * ObjSuffix:  .o    -> .obj
  * StaticLib:  lib<n>.a -> <n>.lib   (MSVC drops the 'lib' prefix)
  * DynamicLib (new): lib<n>.so / lib<n>.dylib / <n>.dll
  * IsMSVC() helper (the cc_is('msvc') analog); BinName already added .exe

Making the naming correct exposed unit tests that hard-coded '.o'/'.a'/
no-'.exe' in generated-ninja assertions -- they passed on Windows before
only because the toolchain was (wrongly) emitting Unix names. Derive the
expected file names from the toolchain in those tests (cc: structure,
proto, gen_rule, header-only; build: generates-ninja, resource,
link_all_symbols, header-x-cpp) so they hold on every platform. Also fix
bladectx's abspath test to check absoluteness with filepath.IsAbs rather
than assuming a leading '/' (Windows returns C:\...).

Verified: go test ./... green on both macOS/arm64 and Windows/arm64
(previously 3 packages / several tests failed on Windows). New
toolchain_test.TestNaming pins all three conventions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chen3feng
chen3feng merged commit 5de6225 into main Jul 3, 2026
1 check passed
@chen3feng
chen3feng deleted the feat/msvc-toolchain-naming branch July 3, 2026 14:17
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