Skip to content

Commit 168cf2d

Browse files
committed
Allow up to 8MB stack size for build.rs to avoid a stack overflow
1 parent 3881e0d commit 168cf2d

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cssparser"
3-
version = "0.23.5"
3+
version = "0.23.6"
44
authors = [ "Simon Sapin <simon.sapin@exyr.org>" ]
55

66
description = "Rust implementation of CSS Syntax Level 3"

build.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::path::Path;
1515
#[cfg(feature = "dummy_match_byte")]
1616
mod codegen {
1717
use std::path::Path;
18-
pub fn main(_: &Path) {}
18+
pub fn main() {}
1919
}
2020

2121
#[cfg(not(feature = "dummy_match_byte"))]
@@ -27,11 +27,21 @@ mod codegen {
2727
use match_byte;
2828
use std::env;
2929
use std::path::Path;
30+
use std::thread::Builder;
3031

31-
pub fn main(tokenizer_rs: &Path) {
32-
match_byte::expand(tokenizer_rs,
33-
&Path::new(&env::var("OUT_DIR").unwrap()).join("tokenizer.rs"));
32+
pub fn main() {
33+
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
3434

35+
let input = Path::new(&manifest_dir).join("src/tokenizer.rs");
36+
let output = Path::new(&env::var("OUT_DIR").unwrap()).join("tokenizer.rs");
37+
println!("cargo:rerun-if-changed={}", input.display());
38+
39+
// We have stack overflows on Servo's CI.
40+
let handle = Builder::new().stack_size(8 * 1024 * 1024).spawn(move || {
41+
match_byte::expand(&input, &output);
42+
}).unwrap();
43+
44+
handle.join().unwrap();
3545
}
3646
}
3747

@@ -41,8 +51,5 @@ fn main() {
4151
println!("cargo:rustc-cfg=rustc_has_pr45225")
4252
}
4353

44-
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
45-
let tokenizer_rs = Path::new(&manifest_dir).join("src/tokenizer.rs");
46-
codegen::main(&tokenizer_rs);
47-
println!("cargo:rerun-if-changed={}", tokenizer_rs.display());
54+
codegen::main();
4855
}

0 commit comments

Comments
 (0)