Skip to content

Build C code for xous operating system #469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 9, 2022
Merged
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
8 changes: 5 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ fn main() {
// unlikely that the C is really that much better than our own Rust.
// * nvptx - everything is bitcode, not compatible with mixed C/Rust
// * riscv - the rust-lang/rust distribution container doesn't have a C
// compiler nor is cc-rs ready for compilation to riscv (at this
// time). This can probably be removed in the future
if !target.contains("wasm") && !target.contains("nvptx") && !target.starts_with("riscv") {
// compiler.
if !target.contains("wasm")
&& !target.contains("nvptx")
&& (!target.starts_with("riscv") || target.contains("xous"))
{
#[cfg(feature = "c")]
c::compile(&llvm_target, &target);
}
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub mod int;
all(target_family = "wasm", target_os = "unknown"),
all(target_arch = "x86_64", target_os = "uefi"),
all(target_arch = "arm", target_os = "none"),
target_os = "xous",
all(target_vendor = "fortanix", target_env = "sgx")
))]
pub mod math;
Expand Down
13 changes: 12 additions & 1 deletion src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ macro_rules! no_mangle {
target_os = "unknown",
not(target_env = "wasi")
),
target_os = "xous",
all(target_arch = "x86_64", target_os = "uefi"),
all(target_arch = "xtensa", target_os = "none"),
all(target_vendor = "fortanix", target_env = "sgx")
Expand Down Expand Up @@ -70,6 +71,7 @@ no_mangle! {
target_os = "unknown",
not(target_env = "wasi")
),
target_os = "xous",
all(target_arch = "xtensa", target_os = "none"),
all(target_vendor = "fortanix", target_env = "sgx")
))]
Expand All @@ -93,7 +95,16 @@ no_mangle! {
fn tanf(n: f32) -> f32;
}

#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
#[cfg(target_os = "xous")]
no_mangle! {
fn sqrtf(x: f32) -> f32;
fn sqrt(x: f64) -> f64;
}

#[cfg(any(
all(target_vendor = "fortanix", target_env = "sgx"),
target_os = "xous"
))]
no_mangle! {
fn ceil(x: f64) -> f64;
fn ceilf(x: f32) -> f32;
Expand Down