Update no_std support in cranelift-frontend.

This commit is contained in:
Dan Gohman
2018-09-28 14:46:26 -07:00
parent 75e4ff62a0
commit 52aa1d292a
4 changed files with 17 additions and 5 deletions

View File

@@ -13,11 +13,12 @@ readme = "README.md"
cranelift-codegen = { path = "../codegen", version = "0.22.0", default-features = false }
target-lexicon = { version = "0.0.3", default-features = false }
log = { version = "0.4.4", default-features = false, features = ["release_max_level_warn"] }
hashmap_core = { version = "0.1.9", optional = true }
[features]
default = ["std"]
std = ["cranelift-codegen/std"]
core = ["cranelift-codegen/core"]
core = ["hashmap_core", "cranelift-codegen/core"]
[badges]
maintenance = { status = "experimental" }

View File

@@ -653,7 +653,6 @@ impl<'a> FunctionBuilder<'a> {
#[cfg(test)]
mod tests {
use cranelift_codegen::entity::EntityRef;
use cranelift_codegen::ir::types::*;
use cranelift_codegen::ir::{AbiParam, ExternalName, Function, InstBuilder, Signature};
@@ -661,6 +660,7 @@ mod tests {
use cranelift_codegen::settings::CallConv;
use cranelift_codegen::verifier::verify_function;
use frontend::{FunctionBuilder, FunctionBuilderContext};
use std::string::ToString;
use Variable;
fn sample_function(lazy_seal: bool) {

View File

@@ -176,6 +176,9 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(alloc))]
#[cfg(not(feature = "std"))]
#[macro_use]
extern crate alloc;
extern crate cranelift_codegen;
#[cfg(test)]
extern crate target_lexicon;
@@ -191,10 +194,16 @@ mod ssa;
mod switch;
mod variable;
/// This replaces `std` in builds with `core`.
#[cfg(not(feature = "std"))]
mod std {
extern crate alloc;
pub use self::alloc::vec;
pub use alloc::{string, vec};
pub use core::*;
pub mod collections {
#[allow(unused_extern_crates)]
extern crate hashmap_core;
pub use self::hashmap_core::map as hash_map;
pub use self::hashmap_core::{HashMap, HashSet};
}
}

View File

@@ -2,6 +2,7 @@ use cranelift_codegen::ir::condcodes::IntCC;
use cranelift_codegen::ir::*;
use frontend::FunctionBuilder;
use std::collections::HashMap;
use std::vec::Vec;
type EntryIndex = u64;
@@ -185,6 +186,7 @@ mod tests {
use super::*;
use cranelift_codegen::ir::Function;
use frontend::FunctionBuilderContext;
use std::string::ToString;
macro_rules! setup {
($default:expr, [$($index:expr,)*]) => {{