valgrind fix for newer intel processors

This commit is contained in:
Anton-4 2022-08-12 12:06:31 +02:00
parent 07eed2c4a6
commit 72e60bceea
No known key found for this signature in database
GPG key ID: A13F4A6E21141925
5 changed files with 11 additions and 45 deletions

View file

@ -46,7 +46,6 @@ pub fn build_file<'a>(
link_type: LinkType, link_type: LinkType,
linking_strategy: LinkingStrategy, linking_strategy: LinkingStrategy,
precompiled: bool, precompiled: bool,
target_valgrind: bool,
threading: Threading, threading: Threading,
wasm_dev_stack_bytes: Option<u32>, wasm_dev_stack_bytes: Option<u32>,
) -> Result<BuiltFile, LoadingProblem<'a>> { ) -> Result<BuiltFile, LoadingProblem<'a>> {
@ -152,7 +151,6 @@ pub fn build_file<'a>(
target, target,
exposed_values, exposed_values,
exposed_closure_types, exposed_closure_types,
target_valgrind,
); );
// TODO try to move as much of this linking as possible to the precompiled // TODO try to move as much of this linking as possible to the precompiled
@ -377,7 +375,6 @@ fn spawn_rebuild_thread(
target: &Triple, target: &Triple,
exported_symbols: Vec<String>, exported_symbols: Vec<String>,
exported_closure_types: Vec<String>, exported_closure_types: Vec<String>,
target_valgrind: bool,
) -> std::thread::JoinHandle<u128> { ) -> std::thread::JoinHandle<u128> {
let thread_local_target = target.clone(); let thread_local_target = target.clone();
std::thread::spawn(move || { std::thread::spawn(move || {
@ -395,7 +392,6 @@ fn spawn_rebuild_thread(
&thread_local_target, &thread_local_target,
host_input_path.as_path(), host_input_path.as_path(),
None, None,
target_valgrind,
); );
preprocess_host_wasm32(host_dest.as_path(), &preprocessed_host_path); preprocess_host_wasm32(host_dest.as_path(), &preprocessed_host_path);
@ -408,7 +404,6 @@ fn spawn_rebuild_thread(
preprocessed_host_path.as_path(), preprocessed_host_path.as_path(),
exported_symbols, exported_symbols,
exported_closure_types, exported_closure_types,
target_valgrind,
); );
} }
LinkingStrategy::Legacy => { LinkingStrategy::Legacy => {
@ -417,7 +412,6 @@ fn spawn_rebuild_thread(
&thread_local_target, &thread_local_target,
host_input_path.as_path(), host_input_path.as_path(),
None, None,
target_valgrind,
); );
} }
} }

View file

@ -57,7 +57,6 @@ pub const FLAG_TARGET: &str = "target";
pub const FLAG_TIME: &str = "time"; pub const FLAG_TIME: &str = "time";
pub const FLAG_LINKER: &str = "linker"; pub const FLAG_LINKER: &str = "linker";
pub const FLAG_PRECOMPILED: &str = "precompiled-host"; pub const FLAG_PRECOMPILED: &str = "precompiled-host";
pub const FLAG_VALGRIND: &str = "valgrind";
pub const FLAG_CHECK: &str = "check"; pub const FLAG_CHECK: &str = "check";
pub const FLAG_WASM_STACK_SIZE_KB: &str = "wasm-stack-size-kb"; pub const FLAG_WASM_STACK_SIZE_KB: &str = "wasm-stack-size-kb";
pub const ROC_FILE: &str = "ROC_FILE"; pub const ROC_FILE: &str = "ROC_FILE";
@ -96,11 +95,6 @@ pub fn build_app<'a>() -> Command<'a> {
.help("Store LLVM debug information in the generated program.") .help("Store LLVM debug information in the generated program.")
.required(false); .required(false);
let flag_valgrind = Arg::new(FLAG_VALGRIND)
.long(FLAG_VALGRIND)
.help("Some assembly instructions are not supported by valgrind, this flag prevents those from being output when building the host.")
.required(false);
let flag_time = Arg::new(FLAG_TIME) let flag_time = Arg::new(FLAG_TIME)
.long(FLAG_TIME) .long(FLAG_TIME)
.help("Prints detailed compilation time information.") .help("Prints detailed compilation time information.")
@ -152,7 +146,6 @@ pub fn build_app<'a>() -> Command<'a> {
.arg(flag_time.clone()) .arg(flag_time.clone())
.arg(flag_linker.clone()) .arg(flag_linker.clone())
.arg(flag_precompiled.clone()) .arg(flag_precompiled.clone())
.arg(flag_valgrind.clone())
.arg(flag_wasm_stack_size_kb.clone()) .arg(flag_wasm_stack_size_kb.clone())
.arg( .arg(
Arg::new(FLAG_TARGET) Arg::new(FLAG_TARGET)
@ -192,7 +185,6 @@ pub fn build_app<'a>() -> Command<'a> {
.arg(flag_time.clone()) .arg(flag_time.clone())
.arg(flag_linker.clone()) .arg(flag_linker.clone())
.arg(flag_precompiled.clone()) .arg(flag_precompiled.clone())
.arg(flag_valgrind.clone())
.arg( .arg(
Arg::new(ROC_FILE) Arg::new(ROC_FILE)
.help("The .roc file for the main module") .help("The .roc file for the main module")
@ -215,7 +207,6 @@ pub fn build_app<'a>() -> Command<'a> {
.arg(flag_time.clone()) .arg(flag_time.clone())
.arg(flag_linker.clone()) .arg(flag_linker.clone())
.arg(flag_precompiled.clone()) .arg(flag_precompiled.clone())
.arg(flag_valgrind.clone())
.arg(roc_file_to_run.clone()) .arg(roc_file_to_run.clone())
.arg(args_for_app.clone()) .arg(args_for_app.clone())
) )
@ -282,7 +273,6 @@ pub fn build_app<'a>() -> Command<'a> {
.arg(flag_time) .arg(flag_time)
.arg(flag_linker) .arg(flag_linker)
.arg(flag_precompiled) .arg(flag_precompiled)
.arg(flag_valgrind)
.arg(roc_file_to_run.required(false)) .arg(roc_file_to_run.required(false))
.arg(args_for_app); .arg(args_for_app);
@ -531,7 +521,6 @@ pub fn build(
.and_then(|s| s.parse::<u32>().ok()) .and_then(|s| s.parse::<u32>().ok())
.map(|x| x * 1024); .map(|x| x * 1024);
let target_valgrind = matches.is_present(FLAG_VALGRIND);
let res_binary_path = build_file( let res_binary_path = build_file(
&arena, &arena,
&triple, &triple,
@ -542,7 +531,6 @@ pub fn build(
link_type, link_type,
linking_strategy, linking_strategy,
precompiled, precompiled,
target_valgrind,
threading, threading,
wasm_dev_stack_bytes, wasm_dev_stack_bytes,
); );

View file

@ -25,7 +25,6 @@ mod cli_run {
use strum_macros::EnumIter; use strum_macros::EnumIter;
const OPTIMIZE_FLAG: &str = concatcp!("--", roc_cli::FLAG_OPTIMIZE); const OPTIMIZE_FLAG: &str = concatcp!("--", roc_cli::FLAG_OPTIMIZE);
const VALGRIND_FLAG: &str = concatcp!("--", roc_cli::FLAG_VALGRIND);
const LINKER_FLAG: &str = concatcp!("--", roc_cli::FLAG_LINKER); const LINKER_FLAG: &str = concatcp!("--", roc_cli::FLAG_LINKER);
const CHECK_FLAG: &str = concatcp!("--", roc_cli::FLAG_CHECK); const CHECK_FLAG: &str = concatcp!("--", roc_cli::FLAG_CHECK);
const PRECOMPILED_HOST: &str = concatcp!("--", roc_cli::FLAG_PRECOMPILED, "=true"); const PRECOMPILED_HOST: &str = concatcp!("--", roc_cli::FLAG_PRECOMPILED, "=true");
@ -137,14 +136,16 @@ mod cli_run {
expected_ending: &str, expected_ending: &str,
use_valgrind: bool, use_valgrind: bool,
) { ) {
// valgrind does not yet support avx512 instructions, see #1963.
// we can't enable this only when testing with valgrind because of host re-use between tests
if is_x86_feature_detected!("avx512f") {
std::env::set_var("NO_AVX512", "1");
}
for cli_mode in CliMode::iter() { for cli_mode in CliMode::iter() {
let flags = { let flags = {
let mut vec = flags.to_vec(); let mut vec = flags.to_vec();
if use_valgrind {
vec.push(VALGRIND_FLAG);
}
vec.push("--max-threads=1"); vec.push("--max-threads=1");
vec.into_iter() vec.into_iter()

View file

@ -113,7 +113,6 @@ pub fn build_zig_host_native(
target: &str, target: &str,
opt_level: OptLevel, opt_level: OptLevel,
shared_lib_path: Option<&Path>, shared_lib_path: Option<&Path>,
_target_valgrind: bool,
) -> Output { ) -> Output {
let mut command = Command::new(&zig_executable()); let mut command = Command::new(&zig_executable());
command command
@ -149,13 +148,10 @@ pub fn build_zig_host_native(
target, target,
]); ]);
// use single threaded testing for cli_run and enable this code if valgrind fails with unhandled instruction bytes, see #1963. // valgrind does not yet support avx512 instructions, see #1963.
/*if target_valgrind { if env::var("NO_AVX512").is_ok() {
command.args(&[ command.args(&["-mcpu", "x86_64"]);
"-mcpu", }
"x86_64"
]);
}*/
if matches!(opt_level, OptLevel::Optimize) { if matches!(opt_level, OptLevel::Optimize) {
command.args(&["-O", "ReleaseSafe"]); command.args(&["-O", "ReleaseSafe"]);
@ -177,7 +173,6 @@ pub fn build_zig_host_native(
target: &str, target: &str,
opt_level: OptLevel, opt_level: OptLevel,
shared_lib_path: Option<&Path>, shared_lib_path: Option<&Path>,
_target_valgrind: bool,
) -> Output { ) -> Output {
let mut command = Command::new(&zig_executable()); let mut command = Command::new(&zig_executable());
command command
@ -234,7 +229,6 @@ pub fn build_zig_host_native(
opt_level: OptLevel, opt_level: OptLevel,
shared_lib_path: Option<&Path>, shared_lib_path: Option<&Path>,
// For compatibility with the non-macOS def above. Keep these in sync. // For compatibility with the non-macOS def above. Keep these in sync.
_target_valgrind: bool,
) -> Output { ) -> Output {
use serde_json::Value; use serde_json::Value;
@ -463,7 +457,6 @@ pub fn rebuild_host(
target: &Triple, target: &Triple,
host_input_path: &Path, host_input_path: &Path,
shared_lib_path: Option<&Path>, shared_lib_path: Option<&Path>,
target_valgrind: bool,
) -> PathBuf { ) -> PathBuf {
let c_host_src = host_input_path.with_file_name("host.c"); let c_host_src = host_input_path.with_file_name("host.c");
let c_host_dest = host_input_path.with_file_name("c_host.o"); let c_host_dest = host_input_path.with_file_name("c_host.o");
@ -535,7 +528,6 @@ pub fn rebuild_host(
"native", "native",
opt_level, opt_level,
shared_lib_path, shared_lib_path,
target_valgrind,
) )
} }
Architecture::X86_32(_) => { Architecture::X86_32(_) => {
@ -549,7 +541,6 @@ pub fn rebuild_host(
"i386-linux-musl", "i386-linux-musl",
opt_level, opt_level,
shared_lib_path, shared_lib_path,
target_valgrind,
) )
} }
@ -564,7 +555,6 @@ pub fn rebuild_host(
target_zig_str(target), target_zig_str(target),
opt_level, opt_level,
shared_lib_path, shared_lib_path,
target_valgrind,
) )
} }
_ => panic!("Unsupported architecture {:?}", target.architecture), _ => panic!("Unsupported architecture {:?}", target.architecture),

View file

@ -79,17 +79,10 @@ pub fn build_and_preprocess_host(
preprocessed_host_path: &Path, preprocessed_host_path: &Path,
exposed_to_host: Vec<String>, exposed_to_host: Vec<String>,
exported_closure_types: Vec<String>, exported_closure_types: Vec<String>,
target_valgrind: bool,
) { ) {
let dummy_lib = host_input_path.with_file_name("libapp.so"); let dummy_lib = host_input_path.with_file_name("libapp.so");
generate_dynamic_lib(target, exposed_to_host, exported_closure_types, &dummy_lib); generate_dynamic_lib(target, exposed_to_host, exported_closure_types, &dummy_lib);
rebuild_host( rebuild_host(opt_level, target, host_input_path, Some(&dummy_lib));
opt_level,
target,
host_input_path,
Some(&dummy_lib),
target_valgrind,
);
let dynhost = host_input_path.with_file_name("dynhost"); let dynhost = host_input_path.with_file_name("dynhost");
let metadata = host_input_path.with_file_name("metadata"); let metadata = host_input_path.with_file_name("metadata");
// let prehost = host_input_path.with_file_name("preprocessedhost"); // let prehost = host_input_path.with_file_name("preprocessedhost");