From ac7727b8b10c4f63037153c4155552232246c097 Mon Sep 17 00:00:00 2001 From: Mark Poliakov Date: Mon, 18 Nov 2024 19:34:24 +0200 Subject: [PATCH] arch: fix x86_64 sp align, fix i686 missing f128 functions --- kernel/arch/x86_64/src/context.rs | 4 ++++ lib/runtime/src/lib.rs | 2 +- userspace/dyn-loader/src/main.rs | 8 ++------ userspace/dyn-loader/src/thread_local/variant2.rs | 1 + userspace/lib/ygglibc/etc/i686-unknown-none.json | 2 +- xtask/src/build/cargo.rs | 9 +++++++-- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/kernel/arch/x86_64/src/context.rs b/kernel/arch/x86_64/src/context.rs index 658f6012..1e89d504 100644 --- a/kernel/arch/x86_64/src/context.rs +++ b/kernel/arch/x86_64/src/context.rs @@ -526,6 +526,10 @@ impl usize { + (sp & !0xF) - 8 + } } impl> Drop diff --git a/lib/runtime/src/lib.rs b/lib/runtime/src/lib.rs index 66778e69..35d98a92 100644 --- a/lib/runtime/src/lib.rs +++ b/lib/runtime/src/lib.rs @@ -1,5 +1,5 @@ //! Yggdrasil OS application runtime -#![feature(rustc_private, decl_macro)] +#![feature(rustc_private, decl_macro, f128, linkage)] #![no_std] #![deny(missing_docs)] #![allow(nonstandard_style)] diff --git a/userspace/dyn-loader/src/main.rs b/userspace/dyn-loader/src/main.rs index 855fec24..ab32d957 100644 --- a/userspace/dyn-loader/src/main.rs +++ b/userspace/dyn-loader/src/main.rs @@ -113,14 +113,10 @@ unsafe fn enter(entry: extern "C" fn(usize), argument: usize) -> ! { "#, in(reg) argument, in(reg) entry, - options(att_syntax) + options(att_syntax, noreturn) ); } - #[cfg(any(target_arch = "x86_64", rust_analyzer))] - { - loop {} - } - #[cfg(any(target_arch = "aarch64", rust_analyzer))] + #[cfg(any(target_arch = "aarch64", target_arch = "x86_64", rust_analyzer))] { entry(argument); unreachable!() diff --git a/userspace/dyn-loader/src/thread_local/variant2.rs b/userspace/dyn-loader/src/thread_local/variant2.rs index 205698e6..8c1684e5 100644 --- a/userspace/dyn-loader/src/thread_local/variant2.rs +++ b/userspace/dyn-loader/src/thread_local/variant2.rs @@ -77,6 +77,7 @@ impl TlsLayoutBuilder for TlsLayoutImpl { segments, total_size, tp_offset, + prefix_len: 0 }, align, )) diff --git a/userspace/lib/ygglibc/etc/i686-unknown-none.json b/userspace/lib/ygglibc/etc/i686-unknown-none.json index d0221cf3..8302e4df 100644 --- a/userspace/lib/ygglibc/etc/i686-unknown-none.json +++ b/userspace/lib/ygglibc/etc/i686-unknown-none.json @@ -7,7 +7,7 @@ "data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128", "max-atomic-width": 64, "target-pointer-width": "32", - "features": "+sse,-soft-float", + "features": "+sse", "executables": true, "dynamic-linking": true, diff --git a/xtask/src/build/cargo.rs b/xtask/src/build/cargo.rs index b1a4def7..cf07e1ba 100644 --- a/xtask/src/build/cargo.rs +++ b/xtask/src/build/cargo.rs @@ -8,7 +8,7 @@ use std::{ use serde::Deserialize; use crate::{ - env::{BuildEnv, Profile}, + env::{Arch, BuildEnv, Profile}, error::Error, }; @@ -87,11 +87,16 @@ impl<'e> CargoBuilder<'e> { .display(), env.arch ); + let mut build_std_features = + "compiler-builtins-mangled-names,compiler-builtins-mem".to_owned(); + if env.arch == Arch::i686 { + build_std_features += ",compiler-builtins-no-f16-f128"; + } command .arg(arg) .arg("-Zbuild-std=core,alloc") - .arg("-Zbuild-std-features=compiler-builtins-mangled-names,compiler-builtins-mem") + .arg(&format!("-Zbuild-std-features={build_std_features}")) .arg(&format!("--target={target}")); if env.verbose {