Skip to content

Commit

Permalink
Add no-stack-protector feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
athre0z committed Jun 9, 2024
1 parent 7d4f95e commit d74e485
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ formatter = ["alloc", "full-decoder"]
encoder = ["alloc", "full-decoder"]
serialization = ["serde", "bitflags/serde"]
nolibc = []
no-stack-protector = []

[[example]]
name = "pattern"
Expand Down
11 changes: 9 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,18 @@ fn build_library() {
bool2cmake(env::var("CARGO_FEATURE_NOLIBC").is_ok()),
);

let dst = config.build();

let target = env::var("TARGET").unwrap_or("(unknown)".to_string());
let is_msvc = target.ends_with("windows-msvc");

if env::var("CARGO_FEATURE_NO_STACK_PROTECTOR").is_ok() {
if is_msvc {
config.cflag("/GS-");
} else {
config.cflag("-fno-stack-protector");
}
}

let dst = config.build();
let relative_build_dir = if is_msvc { config.get_profile() } else { "" };

println!(
Expand Down

0 comments on commit d74e485

Please sign in to comment.