Skip to content

Commit

Permalink
Fix simplejit tests for x64 by disabling is_pic
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Dec 3, 2020
1 parent 69d041f commit 2fea300
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
11 changes: 10 additions & 1 deletion cranelift/simplejit/examples/simplejit-minimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ use cranelift_simplejit::{SimpleJITBuilder, SimpleJITModule};
use std::mem;

fn main() {
let mut flag_builder = settings::builder();
flag_builder.set("use_colocated_libcalls", "false").unwrap();
// FIXME set back to true once the x64 backend supports it.
flag_builder.set("is_pic", "false").unwrap();
let isa_builder = cranelift_native::builder().unwrap_or_else(|msg| {
panic!("host machine is not supported: {}", msg);
});
let isa = isa_builder.finish(settings::Flags::new(flag_builder));
let mut module: SimpleJITModule =
SimpleJITModule::new(SimpleJITBuilder::new(default_libcall_names()));
SimpleJITModule::new(SimpleJITBuilder::with_isa(isa, default_libcall_names()));

let mut ctx = module.make_context();
let mut func_ctx = FunctionBuilderContext::new();

Expand Down
32 changes: 29 additions & 3 deletions cranelift/simplejit/tests/basic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use cranelift_codegen::binemit::NullTrapSink;
use cranelift_codegen::ir::*;
use cranelift_codegen::isa::CallConv;
use cranelift_codegen::settings;
use cranelift_codegen::{ir::types::I16, Context};
use cranelift_entity::EntityRef;
use cranelift_frontend::*;
Expand All @@ -9,8 +10,17 @@ use cranelift_simplejit::*;

#[test]
fn error_on_incompatible_sig_in_declare_function() {
let mut flag_builder = settings::builder();
flag_builder.set("use_colocated_libcalls", "false").unwrap();
// FIXME set back to true once the x64 backend supports it.
flag_builder.set("is_pic", "false").unwrap();
let isa_builder = cranelift_native::builder().unwrap_or_else(|msg| {
panic!("host machine is not supported: {}", msg);
});
let isa = isa_builder.finish(settings::Flags::new(flag_builder));
let mut module: SimpleJITModule =
SimpleJITModule::new(SimpleJITBuilder::new(default_libcall_names()));
SimpleJITModule::new(SimpleJITBuilder::with_isa(isa, default_libcall_names()));

let mut sig = Signature {
params: vec![AbiParam::new(types::I64)],
returns: vec![],
Expand Down Expand Up @@ -58,8 +68,16 @@ fn define_simple_function(module: &mut SimpleJITModule) -> FuncId {
#[test]
#[should_panic(expected = "Result::unwrap()` on an `Err` value: DuplicateDefinition(\"abc\")")]
fn panic_on_define_after_finalize() {
let mut flag_builder = settings::builder();
flag_builder.set("use_colocated_libcalls", "false").unwrap();
// FIXME set back to true once the x64 backend supports it.
flag_builder.set("is_pic", "false").unwrap();
let isa_builder = cranelift_native::builder().unwrap_or_else(|msg| {
panic!("host machine is not supported: {}", msg);
});
let isa = isa_builder.finish(settings::Flags::new(flag_builder));
let mut module: SimpleJITModule =
SimpleJITModule::new(SimpleJITBuilder::new(default_libcall_names()));
SimpleJITModule::new(SimpleJITBuilder::with_isa(isa, default_libcall_names()));

define_simple_function(&mut module);
define_simple_function(&mut module);
Expand Down Expand Up @@ -140,8 +158,16 @@ fn switch_error() {

#[test]
fn libcall_function() {
let mut flag_builder = settings::builder();
flag_builder.set("use_colocated_libcalls", "false").unwrap();
// FIXME set back to true once the x64 backend supports it.
flag_builder.set("is_pic", "false").unwrap();
let isa_builder = cranelift_native::builder().unwrap_or_else(|msg| {
panic!("host machine is not supported: {}", msg);
});
let isa = isa_builder.finish(settings::Flags::new(flag_builder));
let mut module: SimpleJITModule =
SimpleJITModule::new(SimpleJITBuilder::new(default_libcall_names()));
SimpleJITModule::new(SimpleJITBuilder::with_isa(isa, default_libcall_names()));

let sig = Signature {
params: vec![],
Expand Down

0 comments on commit 2fea300

Please sign in to comment.