Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 74 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
members = [ "common", "vmm", "kernel", "macros", "user", "arca" , "arcane", "fix"]
default-members = [ "common", "vmm", "macros", "arca"]
members = [ "common", "vmm", "kernel", "macros" , "user", "arca" , "arcane", "fix", "fix/runtime", "fix/handle", "fix/shell" ]
default-members = [ "common", "vmm", "macros", "arca" ]

resolver = "2"

Expand Down
4 changes: 2 additions & 2 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ default = ["std"]
std = ["alloc", "snafu/std", "libc", "nix"]
alloc = []
thread_local_cache = ["cache"]
core_local_cache = ["macros", "cache"]
core_local_cache = ["cache"]
cache = []
nix = ["dep:nix"]

[dependencies]
log = "0.4.22"
snafu = { version="0.8.5", default-features=false }
macros = { path = "../macros", optional=true }
macros = { path = "../macros" }
arca = { path = "../arca" }
libc = { version="0.2.164", optional=true }
elf = { version = "0.7.4", default-features = false }
Expand Down
9 changes: 9 additions & 0 deletions common/src/bitpack.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use core::simd::u8x32;

pub use macros::BitPack;

pub trait BitPack {
const TAGBITS: u32;
fn pack(&self) -> u8x32;
fn unpack(content: u8x32) -> Self;
}
2 changes: 2 additions & 0 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#![feature(maybe_uninit_as_bytes)]
#![feature(negative_impls)]
#![feature(new_range_api)]
#![feature(portable_simd)]
#![feature(ptr_metadata)]
#![feature(slice_from_ptr_range)]
#![feature(sync_unsafe_cell)]
Expand All @@ -19,6 +20,7 @@ pub mod buddy;
pub mod refcnt;
pub use buddy::BuddyAllocator;
pub mod arrayvec;
pub mod bitpack;
pub mod controlreg;
pub mod elfloader;
pub mod ipaddr;
Expand Down
8 changes: 8 additions & 0 deletions fix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ klog-warn = ["kernel/klog-warn"]
klog-error = ["kernel/klog-error"]
klog-off = ["kernel/klog-off"]
debugcon = ["kernel/debugcon"]
testing-mode = ["fixhandle/testing-mode"]

[dependencies]
arca = { path = "../arca", features = ["serde"] }
kernel = { path = "../kernel" }
macros = { path = "../macros" }
common = { path = "../common", default-features = false }
fixhandle = { path = "handle" }
fixruntime = { path = "runtime" }
log = "0.4.27"
serde = { version = "1.0.219", default-features = false, features = ["alloc", "derive"] }
chrono = { version = "0.4.41", default-features = false, features = ["alloc", "serde"] }
Expand All @@ -30,9 +34,13 @@ trait-variant = "0.1.2"
futures = { version = "0.3.31", default-features = false, features = ["alloc", "async-await"] }
user = { path = "../user", artifact = "bin", target = "x86_64-unknown-none" }
async-lock = { version = "3.4.1", default-features = false }
bytemuck = "1.24.0"
bitfield-struct = "0.11.0"

[build-dependencies]
fixshell = { path = "shell", artifact="staticlib", target = "x86_64-unknown-none" }
anyhow = "1.0.98"
bindgen = "0.72.1"
cc = "1.2.30"
autotools = "0.2.7"
cmake = "0.1.54"
Expand Down
59 changes: 19 additions & 40 deletions fix/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::env;
use std::ffi::OsStr;
use std::fs::create_dir_all;
use std::io::ErrorKind;
use std::path::{Path, PathBuf};
Expand All @@ -11,10 +10,10 @@ use cmake::Config;

use include_directory::{Dir, include_directory};

static FIX_SHELL: Dir<'_> = include_directory!("$CARGO_MANIFEST_DIR/fix-shell");
static FIX_SHELL_INC: Dir<'_> = include_directory!("$CARGO_MANIFEST_DIR/shell/inc");
static FIX_SHELL_ETC: Dir<'_> = include_directory!("$CARGO_MANIFEST_DIR/shell/etc");

static INTERMEDIATEOUT: OnceLock<PathBuf> = OnceLock::new();
static ARCAPREFIX: OnceLock<PathBuf> = OnceLock::new();
static WASM2C: OnceLock<PathBuf> = OnceLock::new();
static WAT2WASM: OnceLock<PathBuf> = OnceLock::new();

Expand Down Expand Up @@ -72,7 +71,8 @@ fn wasm2c(wasm: &[u8]) -> Result<(Vec<u8>, Vec<u8>)> {
}

fn c2elf(c: &[u8], h: &[u8]) -> Result<Vec<u8>> {
FIX_SHELL.extract(INTERMEDIATEOUT.get().unwrap())?;
FIX_SHELL_INC.extract(INTERMEDIATEOUT.get().unwrap())?;
FIX_SHELL_ETC.extract(INTERMEDIATEOUT.get().unwrap())?;

let mut c_file = INTERMEDIATEOUT.get().unwrap().clone();
c_file.push("module.c");
Expand All @@ -84,15 +84,9 @@ fn c2elf(c: &[u8], h: &[u8]) -> Result<Vec<u8>> {
std::fs::write(h_file, h)?;

let mut src = vec![];
let exts = [OsStr::new("c"), OsStr::new("S")];
for f in std::fs::read_dir(INTERMEDIATEOUT.get().unwrap())? {
let f = f?;
if let Some(ext) = f.path().extension()
&& exts.contains(&ext)
{
src.push(f.path());
}
}

let shell_top = env::var_os("CARGO_STATICLIB_FILE_FIXSHELL_fixshell").unwrap();
src.push(PathBuf::from(shell_top));

println!("{src:?}");

Expand All @@ -102,10 +96,7 @@ fn c2elf(c: &[u8], h: &[u8]) -> Result<Vec<u8>> {
let mut memmap = INTERMEDIATEOUT.get().unwrap().clone();
memmap.push("memmap.ld");

let prefix = ARCAPREFIX.get().unwrap();
let gcc = prefix.join("bin/musl-gcc");

let cc = Command::new(gcc)
let cc = Command::new("gcc")
.args([
"-o",
o_file.to_str().unwrap(),
Expand All @@ -116,11 +107,14 @@ fn c2elf(c: &[u8], h: &[u8]) -> Result<Vec<u8>> {
"-frounding-math",
// "-fsignaling-nans",
"-ffreestanding",
// "-nostdlib",
"-nostdlib",
"-nostartfiles",
"-mcmodel=large",
"--verbose",
"-Wl,-no-pie",
//"-mavx",
//"-mavx2",
//"-march=native"
])
.args(src)
.status().map_err(|e| if let ErrorKind::NotFound = e.kind() {anyhow!("Compilation failed. Please make sure you have installed gcc-multilib if you are on Ubuntu.")} else {e.into()})?;
Expand All @@ -136,26 +130,12 @@ fn main() -> Result<()> {

let mut intermediateout: PathBuf = out_dir.clone().into();
intermediateout.push("inter-out");
if !intermediateout.exists() {
create_dir_all(&intermediateout)?
if intermediateout.exists() {
std::fs::remove_dir_all(&intermediateout)?;
}
create_dir_all(&intermediateout)?;
INTERMEDIATEOUT.set(intermediateout).unwrap();

let mut prefix: PathBuf = out_dir.clone().into();
prefix.push("arca-musl-large");

if !prefix.exists() {
create_dir_all(&prefix)?
}

let prefix = autotools::Config::new("../modules/arca-musl")
.cflag("-mcmodel=large")
.cxxflag("-mcmodel=large")
.out_dir(prefix)
.build();

ARCAPREFIX.set(prefix).unwrap();

let mut dst: PathBuf = out_dir.clone().into();
dst.push("wabt");
if !dst.exists() {
Expand All @@ -166,8 +146,6 @@ fn main() -> Result<()> {
.define("BUILD_TESTS", "OFF")
.define("BUILD_LIBWASM", "OFF")
.define("BUILD_TOOLS", "ON")
.cflag("-fPIE")
.cxxflag("-fPIE")
.out_dir(dst)
.build();

Expand All @@ -190,9 +168,10 @@ fn main() -> Result<()> {
std::fs::write(dst, elf)?;
}

let dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
println!("cargo::rerun-if-changed={dir}/etc/memmap.ld");
println!("cargo::rustc-link-arg=-T{dir}/etc/memmap.ld");
let cwd = std::env::var("CARGO_MANIFEST_DIR").unwrap();

println!("cargo::rerun-if-changed={cwd}/etc/memmap.ld");
println!("cargo::rustc-link-arg=-T{cwd}/etc/memmap.ld");
println!("cargo::rustc-link-arg=-no-pie");

Ok(())
Expand Down
Empty file removed fix/fix-shell/fix.c
Empty file.
Loading
Loading