tests: fix missing target init

This commit is contained in:
2025-07-31 16:15:56 +08:00
parent aacfba8c57
commit 1656770478
2 changed files with 3 additions and 6 deletions

View File

@@ -158,8 +158,8 @@ impl TargetMachineOptions {
#[must_use]
pub fn create_target_machine(&self) -> TargetMachine {
let triple = TargetTriple::create(self.triple.as_str());
let target = Target::from_triple(&triple).unwrap_or_else(|_| {
panic!("could not create target from target triple {}", self.triple)
let target = Target::from_triple(&triple).unwrap_or_else(|e| {
panic!("could not create target from target triple {}: {e}", self.triple)
});
target

View File

@@ -92,6 +92,7 @@ impl SymbolResolver for Resolver {
}
fn codegen_options() -> CodeGenOptions {
Target::initialize_native(&InitializationConfig::default()).unwrap();
// We want things like debug assertions, but we otherwise want to run on optimized code.
CodeGenOptions {
opt_level: String::from("2"),
@@ -199,8 +200,6 @@ fn test_primitives() {
);
})));
Target::initialize_all(&InitializationConfig::default());
let (registry, handles) =
WorkerRegistry::create_workers(threads, top_level, &codegen_options(), &f);
registry.add_task(task);
@@ -349,8 +348,6 @@ fn test_simple_call() {
);
})));
Target::initialize_all(&InitializationConfig::default());
let (registry, handles) =
WorkerRegistry::create_workers(threads, top_level, &codegen_options(), &f);
registry.add_task(task);