Skip to content

Commit

Permalink
build.rs: Let cc-rs choose the hardening flags, if any.
Browse files Browse the repository at this point in the history
Now that we have almost no C code in *ring* there's little
need for these extra hardening flags.
  • Loading branch information
briansmith committed Oct 15, 2023
1 parent 89172b4 commit 2201721
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ fn cpp_flags(compiler: &cc::Tool) -> &'static [&'static str] {
NON_MSVC_FLAGS
} else {
static MSVC_FLAGS: &[&str] = &[
"/GS", // Buffer security checks.
"/Gy", // Enable function-level linking.
"/EHsc", // C++ exceptions only, only in C++.
"/GR-", // Disable RTTI.
Expand Down Expand Up @@ -592,13 +591,6 @@ fn configure_cc(c: &mut cc::Build, target: &Target, include_dir: &Path) {
for f in cpp_flags(&compiler) {
let _ = c.flag(f);
}
if target.os != "none"
&& target.os != "redox"
&& target.os != "windows"
&& target.arch != "wasm32"
{
let _ = c.flag("-fstack-protector");
}

if target.os.as_str() == "macos" {
// ``-gfull`` is required for Darwin's |-dead_strip|.
Expand All @@ -611,11 +603,6 @@ fn configure_cc(c: &mut cc::Build, target: &Target, include_dir: &Path) {
let _ = c.define("NDEBUG", None);
}

if compiler.is_like_msvc() && std::env::var("OPT_LEVEL").unwrap() == "0" {
// run-time checking: (s)tack frame, (u)ninitialized variables
let _ = c.flag("/RTCsu");
}

// Allow cross-compiling without a target sysroot for these targets.
//
// poly1305_vec.c requires <emmintrin.h> which requires <stdlib.h>.
Expand All @@ -634,14 +621,6 @@ fn configure_cc(c: &mut cc::Build, target: &Target, include_dir: &Path) {
if target.force_warnings_into_errors {
c.warnings_into_errors(true);
}
if target.is_musl {
// Some platforms enable _FORTIFY_SOURCE by default, but musl
// libc doesn't support it yet. See
// http://wiki.musl-libc.org/wiki/Future_Ideas#Fortify
// http://www.openwall.com/lists/musl/2015/02/04/3
// http://www.openwall.com/lists/musl/2015/06/17/1
let _ = c.flag("-U_FORTIFY_SOURCE");
}
}

/// Assembles the assemply language source `file` into the object file
Expand Down

0 comments on commit 2201721

Please sign in to comment.