From 2d689ee69888c77b8b173cb8994d0e11379dec4f Mon Sep 17 00:00:00 2001 From: Shunsuke Shibayama Date: Sat, 17 Dec 2022 17:59:51 +0900 Subject: [PATCH] Add `large_thread` feature --- .github/workflows/rust.yml | 2 +- Cargo.toml | 5 +++++ compiler/erg_common/Cargo.toml | 1 + compiler/erg_common/spawn.rs | 2 +- compiler/erg_compiler/Cargo.toml | 14 ++++++++++++-- compiler/erg_parser/Cargo.toml | 1 + 6 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 215702a2..80c1d22e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -25,7 +25,7 @@ jobs: rustup update stable cargo build --verbose - name: Run tests - run: cargo test --verbose + run: cargo test --features large_thread --verbose - uses: actions-rs/cargo@v1 with: command: clippy diff --git a/Cargo.toml b/Cargo.toml index 97f07fc3..ecd1d72e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,6 +46,11 @@ traditional_chinese = [ unicode = ["erg_common/unicode", "erg_parser/unicode", "erg_compiler/unicode"] pretty = ["erg_common/pretty", "erg_parser/pretty", "erg_compiler/unicode"] pre-commit = [] +large_thread = [ + "erg_common/large_thread", + "erg_parser/large_thread", + "erg_compiler/large_thread" +] [dependencies] erg_common = { version = "0.6.0-beta.2", path = "./compiler/erg_common" } diff --git a/compiler/erg_common/Cargo.toml b/compiler/erg_common/Cargo.toml index 649edf26..25567867 100644 --- a/compiler/erg_common/Cargo.toml +++ b/compiler/erg_common/Cargo.toml @@ -17,6 +17,7 @@ simplified_chinese = [] traditional_chinese = [] unicode = [] pretty = [] +large_thread = [] [target.'cfg(unix)'.dependencies] libc = { version = "0.2", default-features = false } diff --git a/compiler/erg_common/spawn.rs b/compiler/erg_common/spawn.rs index 60cf8857..b4795b67 100644 --- a/compiler/erg_common/spawn.rs +++ b/compiler/erg_common/spawn.rs @@ -8,7 +8,7 @@ where F: FnOnce() -> T + Send + 'static, T: Send + 'static, { - if cfg!(windows) { + if cfg!(windows) || cfg!(features = "large_thread") { const STACK_SIZE: usize = 4 * 1024 * 1024; let child = thread::Builder::new() .stack_size(STACK_SIZE) diff --git a/compiler/erg_compiler/Cargo.toml b/compiler/erg_compiler/Cargo.toml index bd08821f..c25c71ad 100644 --- a/compiler/erg_compiler/Cargo.toml +++ b/compiler/erg_compiler/Cargo.toml @@ -22,8 +22,18 @@ traditional_chinese = [ "erg_common/traditional_chinese", "erg_parser/traditional_chinese", ] -unicode = ["erg_common/unicode"] -pretty = ["erg_common/pretty"] +unicode = [ + "erg_common/unicode", + "erg_parser/unicode", +] +pretty = [ + "erg_common/pretty", + "erg_parser/pretty" +] +large_thread = [ + "erg_common/large_thread", + "erg_parser/large_thread", +] [dependencies] erg_common = { version = "0.6.0-beta.2", path = "../erg_common" } diff --git a/compiler/erg_parser/Cargo.toml b/compiler/erg_parser/Cargo.toml index cb45c19e..5ea42dfc 100644 --- a/compiler/erg_parser/Cargo.toml +++ b/compiler/erg_parser/Cargo.toml @@ -16,6 +16,7 @@ simplified_chinese = ["erg_common/simplified_chinese"] traditional_chinese = ["erg_common/traditional_chinese"] unicode = ["erg_common/unicode"] pretty = ["erg_common/pretty"] +large_thread = ["erg_common/large_thread"] [dependencies] erg_common = { version = "0.6.0-beta.2", path = "../erg_common" }