Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b27aee9
stabilize `ci_rustc_if_unchanged_logic` test
onur-ozkan Oct 9, 2024
de744ea
update `rustc_borrowck::places_conflict` doc-comment
onur-ozkan Oct 10, 2024
249df9e
Auto merge of #131444 - onur-ozkan:hotfix-ci, r=Kobzol
bors Oct 10, 2024
26f472d
add armv7a-vex-v5 target
max-niederman May 28, 2024
e517385
add (shimmed) std support for armv7a-vex-v5
max-niederman May 28, 2024
c165bed
add panic, stdio, and alloc support to armv7a-vex-v5
max-niederman May 28, 2024
7919692
fix linker script and call main
max-niederman May 30, 2024
dcfa3bd
zero out bss section in _start
max-niederman Jul 17, 2024
8095ebd
use static TLS implementation on vexos
max-niederman Jul 17, 2024
1780a6a
make minor improvements to linker script
max-niederman Jul 17, 2024
31c0e19
enable stdio and fix stdout flushing
max-niederman Jul 18, 2024
9b51015
add: `Instant` implementation
Gavin-Niederman Jul 18, 2024
b1cbee0
remove broken cleanup
max-niederman Jul 18, 2024
651a267
fix `.code_signature` section error
tropicaaal Jul 18, 2024
48155eb
move `.code_signature` section into `.text`
tropicaaal Jul 18, 2024
e1b6923
adjust `armv7a-vex-v5` target features for more aggressive hardware o…
tropicaaal Jul 18, 2024
3295fed
switch `llvm_target` to use ARM hard-float abi
tropicaaal Jul 18, 2024
bffb60d
add `env` implementation for `vexos` PAL
tropicaaal Jul 18, 2024
4981de1
feat: experimental fs support
Gavin-Niederman Jul 18, 2024
72111c5
add support for more missing file operations
tropicaaal Jul 18, 2024
dc8dff0
feat: file writes vectored writes and vectored reads
Gavin-Niederman Jul 18, 2024
ed9640f
add helper for mapping FRESULT values
tropicaaal Jul 21, 2024
3886ee9
add: try_file_exists and stat
Gavin-Niederman Jul 21, 2024
c5ec31f
add: fileattr functions
Gavin-Niederman Jul 21, 2024
99ef1ae
fix: check current position in file when getting size
Gavin-Niederman Jul 21, 2024
cf0224e
refactor: pseudorandom hashmap keys
Gavin-Niederman Jul 21, 2024
e3d3956
fix: support File::file_attr and dissalow read and write mode at the …
Gavin-Niederman Jul 22, 2024
e54eb6d
feat: seek implementation
Gavin-Niederman Jul 22, 2024
477aeeb
feat: almost working directory reading
Gavin-Niederman Jul 23, 2024
51a85f8
fix: remove trailing slashes sooner
Gavin-Niederman Jul 23, 2024
871058a
remove test code and document filesystem quirks
tropicaaal Jul 27, 2024
5723946
add default code signature, ensure stdout flush
tropicaaal Aug 4, 2024
fd35bda
add platform docs
tropicaaal Aug 4, 2024
1274213
adjust wording and fix typos in target documentation
tropicaaal Aug 4, 2024
c65cfdb
update PAL and add `check-cfg` override for `target_os`
tropicaaal Aug 5, 2024
876be73
add additional information to target spec and supporting docs
tropicaaal Aug 5, 2024
23508ab
fix `EXE_SUFFFIX` to use dot
tropicaaal Aug 9, 2024
3ec93ea
fix: use correct code signature default values
tropicaaal Aug 17, 2024
8ddc5f1
don't compile with `+thumb-mode` feature for now
tropicaaal Aug 21, 2024
834ab12
properly flush serial on abort
tropicaaal Sep 6, 2024
3a23f09
clarify documentation regarding cargo-v5, adjust `SystemTime` panic m…
tropicaaal Sep 7, 2024
08998e9
use aapcs as system abi
max-niederman Oct 9, 2024
23704a8
fix stack corruptions in startup routine
max-niederman Oct 9, 2024
9e466b6
fix thread locals
max-niederman Oct 9, 2024
a200a23
implement (shimmed) std::random
max-niederman Oct 9, 2024
8632a35
fix allocation
max-niederman Oct 9, 2024
ee08567
update linkerscript to include unwinding-related sections
tropicaaal Oct 11, 2024
a86a069
format target doc and reorder maintainer list
max-niederman Oct 11, 2024
bc40dcd
bump vex-sdk version and allow vex-sdk to be a stdlib dep
max-niederman Oct 11, 2024
64c05d2
add assembly test for armv7a-vex-v5
max-niederman Oct 11, 2024
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
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/places_conflict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! we can prove overlap one way or another. Essentially, we treat `Overlap` as
//! a monoid and report a conflict if the product ends up not being `Disjoint`.
//!
//! At each step, if we didn't run out of borrow or place, we know that our elements
//! On each step, if we didn't run out of borrow or place, we know that our elements
//! have the same type, and that they only overlap if they are the identical.
//!
//! For example, if we are comparing these:
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1913,6 +1913,8 @@ supported_targets! {

("armv7-sony-vita-newlibeabihf", armv7_sony_vita_newlibeabihf),

("armv7a-vex-v5", armv7a_vex_v5),

("armv7-unknown-linux-uclibceabi", armv7_unknown_linux_uclibceabi),
("armv7-unknown-linux-uclibceabihf", armv7_unknown_linux_uclibceabihf),

Expand Down Expand Up @@ -2265,6 +2267,8 @@ pub struct TargetOptions {
pub is_like_wasm: bool,
/// Whether a target toolchain is like Android, implying a Linux kernel and a Bionic libc
pub is_like_android: bool,
/// Whether a target toolchain is like VEXos.
pub is_like_vexos: bool,
/// Default supported version of DWARF on this platform.
/// Useful because some platforms (osx, bsd) only want up to DWARF2.
pub default_dwarf_version: u32,
Expand Down Expand Up @@ -2620,6 +2624,7 @@ impl Default for TargetOptions {
is_like_msvc: false,
is_like_wasm: false,
is_like_android: false,
is_like_vexos: false,
default_dwarf_version: 4,
allows_weak_linkage: true,
has_rpath: false,
Expand Down Expand Up @@ -2727,6 +2732,7 @@ impl Target {
Abi::System { unwind } if self.is_like_windows && self.arch == "x86" && !c_variadic => {
Abi::Stdcall { unwind }
}
Abi::System { unwind } if self.is_like_vexos && !c_variadic => Abi::Aapcs { unwind },
Abi::System { unwind } => Abi::C { unwind },
Abi::EfiApi if self.arch == "arm" => Abi::Aapcs { unwind: false },
Abi::EfiApi if self.arch == "x86_64" => Abi::Win64 { unwind: false },
Expand Down Expand Up @@ -3380,6 +3386,7 @@ impl Target {
key!(is_like_msvc, bool);
key!(is_like_wasm, bool);
key!(is_like_android, bool);
key!(is_like_vexos, bool);
key!(default_dwarf_version, u32);
key!(allows_weak_linkage, bool);
key!(has_rpath, bool);
Expand Down Expand Up @@ -3660,6 +3667,7 @@ impl ToJson for Target {
target_option_val!(is_like_msvc);
target_option_val!(is_like_wasm);
target_option_val!(is_like_android);
target_option_val!(is_like_vexos);
target_option_val!(default_dwarf_version);
target_option_val!(allows_weak_linkage);
target_option_val!(has_rpath);
Expand Down
37 changes: 37 additions & 0 deletions compiler/rustc_target/src/spec/targets/armv7a_vex_v5.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};

const LINK_SCRIPT: &str = include_str!("./armv7a_vex_v5_linker_script.ld");

pub(crate) fn target() -> Target {
Target {
llvm_target: "armv7a-none-eabihf".into(),
metadata: crate::spec::TargetMetadata {
description: Some("Armv7-A Cortex-A9 VEX V5 Brain, VEXos".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
},
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),
options: TargetOptions {
os: "vexos".into(),
is_like_vexos: true,
vendor: "vex".into(),
cpu: "cortex-a9".into(),
abi: "eabihf".into(),
features: "+v7,+neon,+vfp3,+thumb2".into(),
linker: Some("rust-lld".into()),
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
link_script: Some(LINK_SCRIPT.into()),
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
c_enum_min_bits: Some(8),
max_atomic_width: Some(64),
disable_redzone: true,
emit_debug_gdb_scripts: false,
has_thumb_interworking: true,
..Default::default()
},
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
OUTPUT_FORMAT("elf32-littlearm")

ENTRY(_boot)

__user_ram_start = 0x03800000;
__user_ram_length = 0x04800000;
__user_ram_end = __user_ram_start + __user_ram_length;

__code_signature_length = 0x20;

__stack_length = 0x400000;
__heap_end = __user_ram_end - __stack_length;

__eh_frame_hdr_start = SIZEOF(.eh_frame_hdr) > 0 ? ADDR(.eh_frame_hdr) : 0;
__eh_frame_hdr_end = SIZEOF(.eh_frame_hdr) > 0 ? . : 0;

MEMORY {
USER_RAM : ORIGIN = __user_ram_start, LENGTH = __user_ram_length
}

SECTIONS {
.code_signature : {
KEEP(*(.code_signature))
. = __user_ram_start + __code_signature_length;
} > USER_RAM

.text : {
*(.boot)
*(.text .text.*)
} > USER_RAM

.rodata : {
*(.rodata .rodata.*)
} > USER_RAM

.data : {
*(.data .data.*)
} > USER_RAM

.bss : {
__bss_start = .;
*(.bss .bss.*)
__bss_end = .;
} > USER_RAM

/* The unwind tables enabled by "default-uwtable" in the target file live here. */
/* __eh_frame_start and similar symbols are used by libunwind. */
.eh_frame_hdr : {
KEEP(*(.eh_frame_hdr))
} > USER_RAM

.eh_frame : {
__eh_frame_start = .;
KEEP(*(.eh_frame))
__eh_frame_end = .;
} > USER_RAM

.ARM.exidx : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} > USER_RAM

.ARM.extab : {
__extab_start = .;
*(.ARM.extab*)
__extab_end = .;
} > USER_RAM

.heap (NOLOAD) : ALIGN(4) {
__heap_start = .;
. = __heap_end;
} > USER_RAM

.stack (NOLOAD) : ALIGN(8) {
__stack_bottom = .;
. += __stack_length;
__stack_top = .;
} > USER_RAM

/DISCARD/ : {
*(.ARM.attributes*)
}
}
13 changes: 12 additions & 1 deletion library/Cargo.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4

[[package]]
name = "addr2line"
Expand Down Expand Up @@ -348,6 +348,7 @@ dependencies = [
"rustc-demangle",
"std_detect",
"unwind",
"vex-sdk",
"wasi",
"windows-targets 0.0.0",
]
Expand Down Expand Up @@ -415,6 +416,16 @@ dependencies = [
"rustc-std-workspace-core",
]

[[package]]
name = "vex-sdk"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40b1777b4e4a60f9fed09417dafdc4a6a3393a67df1bd02c3b589770d906cff3"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-core",
]

[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
Expand Down
3 changes: 3 additions & 0 deletions library/panic_abort/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ compiler_builtins = "0.1.0"

[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
libc = { version = "0.2", default-features = false }

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(target_os, values("vexos"))'] }
1 change: 1 addition & 0 deletions library/panic_abort/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub unsafe fn __rust_start_panic(_payload: &mut dyn PanicPayload) -> u32 {
all(target_vendor = "fortanix", target_env = "sgx"),
target_os = "xous",
target_os = "uefi",
target_os = "vexos",
))] {
unsafe fn abort() -> ! {
// call std::sys::abort_internal
Expand Down
6 changes: 5 additions & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ path = "../windows_targets"
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }
rand_xorshift = "0.3.0"

[target.'cfg(any(all(target_family = "wasm", target_os = "unknown"), target_os = "xous", all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies]
[target.'cfg(any(all(target_family = "wasm", target_os = "unknown"), target_os = "vexos", target_os = "xous", all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies]
dlmalloc = { version = "0.2.4", features = ['rustc-dep-of-std'] }

[target.x86_64-fortanix-unknown-sgx.dependencies]
Expand All @@ -90,6 +90,9 @@ wasi = { version = "0.11.0", features = [
r-efi = { version = "4.5.0", features = ['rustc-dep-of-std'] }
r-efi-alloc = { version = "1.0.0", features = ['rustc-dep-of-std'] }

[target.'cfg(target_os = "vexos")'.dependencies]
vex-sdk = { version = "0.22.0", features = ['rustc-dep-of-std'] }

[features]
backtrace = [
'addr2line/rustc-dep-of-std',
Expand Down Expand Up @@ -152,4 +155,5 @@ check-cfg = [
'cfg(feature, values(any()))',
# #[cfg(bootstrap)] rtems
'cfg(target_os, values("rtems"))',
'cfg(target_os, values("vexos"))',
]
1 change: 1 addition & 0 deletions library/std/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ fn main() {
|| target_os == "zkvm"
|| target_os == "rtems"
|| target_os == "nuttx"
|| target_os == "vexos"

// See src/bootstrap/src/core/build_steps/synthetic_targets.rs
|| env::var("RUSTC_BOOTSTRAP_SYNTHETIC_TARGET").is_ok()
Expand Down
2 changes: 2 additions & 0 deletions library/std/src/sys/alloc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,7 @@ cfg_if::cfg_if! {
mod xous;
} else if #[cfg(target_os = "zkvm")] {
mod zkvm;
} else if #[cfg(target_os = "vexos")] {
mod vexos;
}
}
98 changes: 98 additions & 0 deletions library/std/src/sys/alloc/vexos.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
#![allow(static_mut_refs)]

use crate::alloc::{GlobalAlloc, Layout, System};
use crate::ptr;
use crate::sync::atomic::{AtomicBool, Ordering};

static mut DLMALLOC: dlmalloc::Dlmalloc<Vexos> = dlmalloc::Dlmalloc::new_with_allocator(Vexos);

extern "C" {
static mut __heap_start: u8;
static mut __heap_end: u8;
}

struct Vexos;

unsafe impl dlmalloc::Allocator for Vexos {
/// Allocs system resources
fn alloc(&self, _size: usize) -> (*mut u8, usize, u32) {
static INIT: AtomicBool = AtomicBool::new(false);

if !INIT.swap(true, Ordering::Relaxed) {
unsafe {
(
ptr::addr_of_mut!(__heap_start).cast(),
ptr::addr_of!(__heap_end).byte_offset_from(ptr::addr_of!(__heap_start)) as _,
0,
)
}
} else {
(ptr::null_mut(), 0, 0)
}
}

fn remap(&self, _ptr: *mut u8, _oldsize: usize, _newsize: usize, _can_move: bool) -> *mut u8 {
ptr::null_mut()
}

fn free_part(&self, _ptr: *mut u8, _oldsize: usize, _newsize: usize) -> bool {
false
}

fn free(&self, _ptr: *mut u8, _size: usize) -> bool {
false
}

fn can_release_part(&self, _flags: u32) -> bool {
false
}

fn allocates_zeros(&self) -> bool {
false
}

fn page_size(&self) -> usize {
0x1000
}
}

#[stable(feature = "alloc_system_type", since = "1.28.0")]
unsafe impl GlobalAlloc for System {
#[inline]
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
// SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access.
// Calling malloc() is safe because preconditions on this function match the trait method preconditions.
let _lock = lock::lock();
unsafe { DLMALLOC.malloc(layout.size(), layout.align()) }
}

#[inline]
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
// SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access.
// Calling calloc() is safe because preconditions on this function match the trait method preconditions.
let _lock = lock::lock();
unsafe { DLMALLOC.calloc(layout.size(), layout.align()) }
}

#[inline]
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
// SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access.
// Calling free() is safe because preconditions on this function match the trait method preconditions.
let _lock = lock::lock();
unsafe { DLMALLOC.free(ptr, layout.size(), layout.align()) }
}

#[inline]
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
// SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access.
// Calling realloc() is safe because preconditions on this function match the trait method preconditions.
let _lock = lock::lock();
unsafe { DLMALLOC.realloc(ptr, layout.size(), layout.align(), new_size) }
}
}

mod lock {
#[inline]
pub fn lock() {} // we don't have threads, which makes this real easy
}
3 changes: 3 additions & 0 deletions library/std/src/sys/pal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ cfg_if::cfg_if! {
} else if #[cfg(target_os = "zkvm")] {
mod zkvm;
pub use self::zkvm::*;
} else if #[cfg(target_os = "vexos")] {
mod vexos;
pub use self::vexos::*;
} else {
mod unsupported;
pub use self::unsupported::*;
Expand Down
9 changes: 9 additions & 0 deletions library/std/src/sys/pal/vexos/env.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pub mod os {
pub const FAMILY: &str = "";
pub const OS: &str = "vexos";
pub const DLL_PREFIX: &str = "";
pub const DLL_SUFFIX: &str = "";
pub const DLL_EXTENSION: &str = "";
pub const EXE_SUFFIX: &str = ".bin";
pub const EXE_EXTENSION: &str = "bin";
}
Loading