Remove newlib generator

It's broken and we can try to add it back later if necessary
This commit is contained in:
Alex Crichton 2019-05-02 08:12:23 -07:00
parent ae69253dc7
commit 8560077059
4 changed files with 0 additions and 285 deletions

View file

@ -20,7 +20,6 @@ members = [
"crates/compiler-builtins-smoke-test",
"crates/input-generator",
"crates/musl-generator",
"crates/newlib-generator",
"crates/shared",
]

View file

@ -1,7 +0,0 @@
[package]
name = "newlib-generator"
version = "0.1.0"
authors = ["Jorge Aparicio <jorge@japaric.io>"]
[dependencies]
shared = { path = "../shared" }

View file

@ -1,245 +0,0 @@
macro_rules! f32 {
($($fun:ident,)+) => {
$(
let fun = stringify!($fun);
fs::create_dir_all("math/src")?;
let main = format!("
#![no_main]
#![no_std]
#[macro_use]
extern crate qemu_arm_rt as rt;
use core::u32;
use rt::{{io, process}};
entry!(main);
fn main() {{
run().unwrap_or_else(|e| {{
eprintln!(\"error: {{}}\", e);
process::exit(1);
}})
}}
fn run() -> Result<(), usize> {{
#[link(name = \"m\")]
extern \"C\" {{
fn {0}(_: f32) -> f32;
}}
let mut buf = [0; 4];
while let Ok(()) = io::Stdin.read_exact(&mut buf) {{
let x = f32::from_bits(u32::from_bytes(buf));
let y = unsafe {{ {0}(x) }};
io::Stdout.write_all(&y.to_bits().to_bytes())?;
}}
Ok(())
}}
#[no_mangle]
pub fn __errno() -> *mut i32 {{
static mut ERRNO: i32 = 0;
unsafe {{ &mut ERRNO }}
}}
", fun);
File::create("math/src/main.rs")?.write_all(main.as_bytes())?;
assert!(
Command::new("cross")
.args(&["build", "--target", "thumbv7em-none-eabi", "--release"])
.current_dir("math")
.status()?
.success()
);
let mut qemu = Command::new("qemu-arm")
.arg("math/target/thumbv7em-none-eabi/release/math")
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()?;
qemu.stdin.as_mut().take().unwrap().write_all(F32)?;
let output = qemu.wait_with_output()?;
File::create(concat!("bin/output/newlib.", stringify!($fun)))?
.write_all(&output.stdout)?;
)+
}
}
macro_rules! f32f32 {
($($fun:ident,)+) => {
$(
let fun = stringify!($fun);
fs::create_dir_all("math/src")?;
let main = format!("
#![no_main]
#![no_std]
#[macro_use]
extern crate qemu_arm_rt as rt;
use core::u32;
use rt::{{io, process}};
entry!(main);
fn main() {{
run().unwrap_or_else(|e| {{
eprintln!(\"error: {{}}\", e);
process::exit(1);
}})
}}
fn run() -> Result<(), usize> {{
#[link(name = \"m\")]
extern \"C\" {{
fn {0}(_: f32, _: f32) -> f32;
}}
let mut chunk = [0; 8];
while let Ok(()) = io::Stdin.read_exact(&mut chunk) {{
let mut buf = [0; 4];
buf.copy_from_slice(&chunk[..4]);
let x0 = f32::from_bits(u32::from_bytes(buf));
buf.copy_from_slice(&chunk[4..]);
let x1 = f32::from_bits(u32::from_bytes(buf));
let y = unsafe {{ {0}(x0, x1) }};
io::Stdout.write_all(&y.to_bits().to_bytes())?;
}}
Ok(())
}}
#[no_mangle]
pub fn __errno() -> *mut i32 {{
static mut ERRNO: i32 = 0;
unsafe {{ &mut ERRNO }}
}}
", fun);
File::create("math/src/main.rs")?.write_all(main.as_bytes())?;
assert!(
Command::new("cross")
.args(&["build", "--target", "thumbv7em-none-eabi", "--release"])
.current_dir("math")
.status()?
.success()
);
let mut qemu = Command::new("qemu-arm")
.arg("math/target/thumbv7em-none-eabi/release/math")
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()?;
qemu.stdin.as_mut().take().unwrap().write_all(F32)?;
let output = qemu.wait_with_output()?;
File::create(concat!("bin/output/newlib.", stringify!($fun)))?
.write_all(&output.stdout)?;
)+
}
}
macro_rules! f32f32f32 {
($($fun:ident,)+) => {
$(
let fun = stringify!($fun);
fs::create_dir_all("math/src")?;
let main = format!("
#![no_main]
#![no_std]
#[macro_use]
extern crate qemu_arm_rt as rt;
use core::u32;
use rt::{{io, process}};
entry!(main);
fn main() {{
run().unwrap_or_else(|e| {{
eprintln!(\"error: {{}}\", e);
process::exit(1);
}})
}}
fn run() -> Result<(), usize> {{
#[link(name = \"m\")]
extern \"C\" {{
fn {0}(_: f32, _: f32, _: f32) -> f32;
}}
let mut chunk = [0; 12];
while let Ok(()) = io::Stdin.read_exact(&mut chunk) {{
let mut buf = [0; 4];
buf.copy_from_slice(&chunk[..4]);
let x0 = f32::from_bits(u32::from_bytes(buf));
buf.copy_from_slice(&chunk[4..8]);
let x1 = f32::from_bits(u32::from_bytes(buf));
buf.copy_from_slice(&chunk[8..]);
let x2 = f32::from_bits(u32::from_bytes(buf));
let y = unsafe {{ {0}(x0, x1, x2) }};
io::Stdout.write_all(&y.to_bits().to_bytes())?;
}}
Ok(())
}}
#[no_mangle]
pub fn __errno() -> *mut i32 {{
static mut ERRNO: i32 = 0;
unsafe {{ &mut ERRNO }}
}}
", fun);
File::create("math/src/main.rs")?.write_all(main.as_bytes())?;
assert!(
Command::new("cross")
.args(&["build", "--target", "thumbv7em-none-eabi", "--release"])
.current_dir("math")
.status()?
.success()
);
let mut qemu = Command::new("qemu-arm")
.arg("math/target/thumbv7em-none-eabi/release/math")
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()?;
qemu.stdin.as_mut().take().unwrap().write_all(F32)?;
let output = qemu.wait_with_output()?;
File::create(concat!("bin/output/newlib.", stringify!($fun)))?
.write_all(&output.stdout)?;
)+
}
}

View file

@ -1,32 +0,0 @@
extern crate shared;
use std::error::Error;
use std::fs::{self, File};
use std::io::Write;
use std::process::{Command, Stdio};
#[macro_use]
mod macros;
fn main() -> Result<(), Box<Error>> {
const F32: &[u8] = include_bytes!("../../bin/input/f32");
f32! {
asinf,
cbrtf,
cosf,
exp2f,
sinf,
tanf,
}
f32f32! {
hypotf,
}
f32f32f32! {
fmaf,
}
Ok(())
}