Skip to content

Commit

Permalink
Investigate and fix parallel grammar builds on Windows (#869)
Browse files Browse the repository at this point in the history
* This should reproduce the problem

* Disable concurrent grammar building on Windows

* Update CHANGELOG

* Tidy up comments
  • Loading branch information
Xophmeister authored Feb 10, 2025
1 parent d7a4250 commit f96e12c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Prefetch grammars
run: cargo run --all-features -- prefetch

- name: Run test suite
run: cargo test --all-features

Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ This name should be decided amongst the team before the release.

### Fixed
- [#867](https://github.com/tweag/topiary/pull/867) Enable coverage check and add code samples for OpenSCAD
- [#869](https://github.com/tweag/topiary/pull/869) Disable parallel grammar building on Windows

<!-->
<!--
### Security
- <Vulnerabilities>
Expand Down
9 changes: 6 additions & 3 deletions topiary-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,11 @@ impl Configuration {
let tmp_dir = tempdir()?;
let tmp_dir_path = tmp_dir.path().to_owned();

// When "parallel" is enabled, we use rayon to fetch and compile all found grammars in parallel.
#[cfg(feature = "parallel")]
// When the `parallel` feature is enabled (which it is by default), we use Rayon to fetch
// and compile all found grammars concurrently.
// NOTE The MSVC linker does not seem to like concurrent builds, so concurrency is disabled
// on Windows (see https://github.com/tweag/topiary/issues/868)
#[cfg(all(feature = "parallel", not(windows)))]
{
use rayon::prelude::*;
self.languages
Expand All @@ -160,7 +163,7 @@ impl Configuration {
.collect::<Result<Vec<_>, TopiaryConfigFetchingError>>()?;
}

#[cfg(not(feature = "parallel"))]
#[cfg(any(not(feature = "parallel"), windows))]
{
self.languages
.iter()
Expand Down

0 comments on commit f96e12c

Please sign in to comment.