Skip to content

Fix Windows build: patch marisa-trie to remove VERSION file#1084

Merged
BYVoid merged 2 commits intomasterfrom
fix/marisa-trie-version-file-windows
Mar 31, 2026
Merged

Fix Windows build: patch marisa-trie to remove VERSION file#1084
BYVoid merged 2 commits intomasterfrom
fix/marisa-trie-version-file-windows

Conversation

@BYVoid
Copy link
Copy Markdown
Owner

@BYVoid BYVoid commented Mar 31, 2026

Problem

On Windows, any target that depends on marisa-trie failed to compile with:

external\marisa-trie+\version(1): error C2059: syntax error: 'constant'

Root cause

marisa-trie ships a file named VERSION (containing only 0.3.1) at its repo root. Bazel adds the external repo root to the compiler's include search path (-Iexternal/marisa-trie+) so that headers like marisa/trie.h can be found.

On Windows, the filesystem is case-insensitive. When MSVC resolves #include <version> (a C++17/20 standard header included transitively by other standard headers), it searches the include paths and matches the VERSION data file instead of the real <version> standard header. The preprocessor then reads 0.3.1 as C++ source and fails to parse it.

On Linux and macOS the filesystem is case-sensitive, so <version> never matches VERSION and the real standard header is found normally. This is why the bug only manifests on Windows.

Fix

Add a single_version_override patch in MODULE.bazel that deletes the VERSION file from the marisa-trie source tree before Bazel uses the repo. With the file gone, MSVC's #include <version> lookup correctly finds the standard library header.

Test plan

  • bazel build //... succeeds on Windows (no more error C2059 from marisa-trie)
  • Linux/macOS builds are unaffected (patch only deletes a non-source file)

🤖 Generated with Claude Code

On Windows (case-insensitive filesystem), MSVC's resolution of
`#include <version>` matches the literal file named `VERSION` at the
root of the marisa-trie external repo, because Bazel adds the repo root
to compiler include paths (`-Iexternal/marisa-trie+`) so that headers
like `marisa/trie.h` can be found. The preprocessor reads `VERSION`
(containing only `0.3.1`) as C++ and fails:

    external\marisa-trie+\version(1): error C2059: syntax error: 'constant'

On Linux/macOS the filesystem is case-sensitive, so `<version>` never
matches `VERSION` and the real standard header is found normally.

Fix: add a `single_version_override` patch that deletes the `VERSION`
file from the marisa-trie source tree before Bazel uses the repo.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@BYVoid BYVoid merged commit c4030a8 into master Mar 31, 2026
33 checks passed
UebelAndre pushed a commit to bazelbuild/bazel-central-registry that referenced this pull request Apr 14, 2026
## Summary
- Add `marisa-trie@0.3.1.bcr.1` with a patch that removes the `VERSION`
file from the source tree
- Fixes Windows build failure where MSVC's `#include <version>` (C++
standard header) resolves to the `VERSION` data file on case-insensitive
filesystems

### Problem

On Windows, any target that depends on `marisa-trie` fails to compile
with:

```
external\marisa-trie+\version(1): error C2059: syntax error: 'constant'
```

### Root cause

marisa-trie ships a file named `VERSION` (containing only `0.3.1`) at
its repo root. Bazel adds the external repo root to the compiler's
include search path (`-Iexternal/marisa-trie+`) so that headers like
`marisa/trie.h` can be found.

On Windows, the filesystem is **case-insensitive**. When MSVC resolves
`#include <version>` (a C++17/20 standard header included transitively
by other standard headers), it searches the include paths and matches
the `VERSION` data file instead of the real `<version>` standard header.
The preprocessor then reads `0.3.1` as C++ source and fails to parse it.

On Linux and macOS the filesystem is **case-sensitive**, so `<version>`
never matches `VERSION` and the real standard header is found normally.
This is why the bug only manifests on Windows.

### Fix

Add a patch that deletes the `VERSION` file from the marisa-trie source
tree before Bazel uses the repo. With the file gone, MSVC's `#include
<version>` lookup correctly finds the standard library header.

See BYVoid/OpenCC#1084 for the original report
and rationale.

@bazel-io skip_check unstable_url

## Test plan
- [x] `bazel run //tools:bcr_validation -- --check
marisa-trie@0.3.1.bcr.1` passes
- [x] BCR presubmit CI passes on all platforms (debian10, ubuntu2004,
macos, macos_arm64, windows) × (bazel 7.x, 8.x, 9.x)
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