in aws-lc-sys/builder/cc_builder.rs [444:506]
fn memcmp_check(&self) {
let basename = "memcmp_invalid_stripped_check";
let exec_path = out_dir().join(basename);
let memcmp_build = cc::Build::default();
let memcmp_compiler = memcmp_build.get_compiler();
if !memcmp_compiler.is_like_clang() && !memcmp_compiler.is_like_gnu() {
// The logic below assumes a Clang or GCC compiler is in use
return;
}
let mut memcmp_compile_args = Vec::from(memcmp_compiler.args());
memcmp_compile_args.push(
self.manifest_dir
.join("aws-lc")
.join("tests")
.join("compiler_features_tests")
.join(format!("{basename}.c"))
.into_os_string(),
);
memcmp_compile_args.push("-Wno-unused-parameter".into());
memcmp_compile_args.push("-o".into());
memcmp_compile_args.push(exec_path.clone().into_os_string());
let memcmp_args: Vec<_> = memcmp_compile_args
.iter()
.map(std::ffi::OsString::as_os_str)
.collect();
let memcmp_compile_result =
execute_command(memcmp_compiler.path().as_os_str(), memcmp_args.as_slice());
assert!(
memcmp_compile_result.status,
"COMPILER: {}\
ARGS: {:?}\
EXECUTED: {}\
ERROR: {}\
OUTPUT: {}\
Failed to compile {basename}
",
memcmp_compiler.path().display(),
memcmp_args.as_slice(),
memcmp_compile_result.executed,
memcmp_compile_result.stderr,
memcmp_compile_result.stdout
);
// We can only execute the binary when the host and target platforms match.
if cargo_env("HOST") == target() {
let result = execute_command(exec_path.as_os_str(), &[]);
assert!(
result.status,
"### COMPILER BUG DETECTED ###\nYour compiler ({}) is not supported due to a memcmp related bug reported in \
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189. \
We strongly recommend against using this compiler. \n\
EXECUTED: {}\n\
ERROR: {}\n\
OUTPUT: {}\n\
",
memcmp_compiler.path().display(),
memcmp_compile_result.executed,
memcmp_compile_result.stderr,
memcmp_compile_result.stdout
);
}
let _ = fs::remove_file(exec_path);
}