From db494967c5b871768b9dca7cd9d008383d9bcbfe Mon Sep 17 00:00:00 2001 From: whitequark Date: Wed, 19 Apr 2017 09:38:24 +0000 Subject: [PATCH] firmware use Rust 0.18.0. --- artiq/firmware/liballoc_artiq/lib.rs | 7 +++++++ artiq/firmware/liballoc_none/lib.rs | 5 +++++ artiq/firmware/libdrtioaux/lib.rs | 2 -- artiq/firmware/libdyld/lib.rs | 2 +- artiq/firmware/libstd_artiq/io/mod.rs | 3 +-- artiq/firmware/libstd_artiq/lib.rs | 2 +- artiq/firmware/runtime/lib.rs | 6 +++++- artiq/frontend/artiq_devtool.py | 4 ++-- conda/artiq-dev/meta.yaml | 2 +- doc/manual/developing.rst | 8 +++++--- 10 files changed, 28 insertions(+), 13 deletions(-) diff --git a/artiq/firmware/liballoc_artiq/lib.rs b/artiq/firmware/liballoc_artiq/lib.rs index 073062973..37b39c561 100644 --- a/artiq/firmware/liballoc_artiq/lib.rs +++ b/artiq/firmware/liballoc_artiq/lib.rs @@ -81,6 +81,13 @@ pub extern fn __rust_allocate(mut size: usize, align: usize) -> *mut u8 { ptr::null_mut() } +#[no_mangle] +pub extern fn __rust_allocate_zeroed(size: usize, align: usize) -> *mut u8 { + let ptr = __rust_allocate(size, align); + unsafe { ptr::write_bytes(ptr, 0, size); } + ptr +} + #[no_mangle] pub extern fn __rust_deallocate(ptr: *mut u8, _old_size: usize, _align: usize) { unsafe { diff --git a/artiq/firmware/liballoc_none/lib.rs b/artiq/firmware/liballoc_none/lib.rs index f321c49a8..79f8cecbf 100644 --- a/artiq/firmware/liballoc_none/lib.rs +++ b/artiq/firmware/liballoc_none/lib.rs @@ -7,6 +7,11 @@ pub extern "C" fn __rust_allocate(_size: usize, _align: usize) -> *mut u8 { unimplemented!() } +#[no_mangle] +pub extern fn __rust_allocate_zeroed(_size: usize, _align: usize) -> *mut u8 { + unimplemented!() +} + #[no_mangle] pub extern "C" fn __rust_deallocate(_ptr: *mut u8, _old_size: usize, _align: usize) { unimplemented!() diff --git a/artiq/firmware/libdrtioaux/lib.rs b/artiq/firmware/libdrtioaux/lib.rs index eaf3da4df..5aa23e857 100644 --- a/artiq/firmware/libdrtioaux/lib.rs +++ b/artiq/firmware/libdrtioaux/lib.rs @@ -2,8 +2,6 @@ #[macro_use] extern crate std_artiq as std; -#[macro_use] -extern crate log; extern crate board; extern crate byteorder; diff --git a/artiq/firmware/libdyld/lib.rs b/artiq/firmware/libdyld/lib.rs index 8fe1c6c25..c5d028226 100644 --- a/artiq/firmware/libdyld/lib.rs +++ b/artiq/firmware/libdyld/lib.rs @@ -1,5 +1,5 @@ #![no_std] -#![feature(untagged_unions, ptr_unaligned)] +#![feature(untagged_unions)] use core::{mem, ptr, fmt, slice, str, convert}; use elf::*; diff --git a/artiq/firmware/libstd_artiq/io/mod.rs b/artiq/firmware/libstd_artiq/io/mod.rs index 0159b92a9..f0d42ab43 100644 --- a/artiq/firmware/libstd_artiq/io/mod.rs +++ b/artiq/firmware/libstd_artiq/io/mod.rs @@ -248,7 +248,6 @@ //! time and may call fewer or more syscalls/library functions. use core::cmp; -use std_unicode::str as core_str; use core::fmt; use core::iter::{Iterator}; use core::marker::Sized; @@ -1529,7 +1528,7 @@ impl Iterator for Chars { Ok(..) => buf[0], Err(e) => return Some(Err(CharsError::Other(e))), }; - let width = core_str::utf8_char_width(first_byte); + let width = ::core::str::utf8_char_width(first_byte); if width == 1 { return Some(Ok(first_byte as char)) } if width == 0 { return Some(Err(CharsError::NotUtf8)) } let mut buf = [first_byte, 0, 0, 0]; diff --git a/artiq/firmware/libstd_artiq/lib.rs b/artiq/firmware/libstd_artiq/lib.rs index 9d6d7471d..8ab6ac86b 100644 --- a/artiq/firmware/libstd_artiq/lib.rs +++ b/artiq/firmware/libstd_artiq/lib.rs @@ -1,6 +1,6 @@ #![feature(lang_items, asm, alloc, collections, needs_panic_runtime, unicode, raw, int_error_internals, try_from, macro_reexport, - allow_internal_unstable, stmt_expr_attributes)] + allow_internal_unstable, stmt_expr_attributes, str_internals)] #![no_std] #![needs_panic_runtime] diff --git a/artiq/firmware/runtime/lib.rs b/artiq/firmware/runtime/lib.rs index 61c35efbf..c1a745e03 100644 --- a/artiq/firmware/runtime/lib.rs +++ b/artiq/firmware/runtime/lib.rs @@ -1,7 +1,8 @@ #![no_std] -#![feature(compiler_builtins_lib, repr_simd, lang_items, const_fn)] +#![feature(compiler_builtins_lib, alloc, oom, repr_simd, lang_items, const_fn)] extern crate compiler_builtins; +extern crate alloc; extern crate cslice; #[macro_use] extern crate log; @@ -168,6 +169,9 @@ pub extern fn main() -> i32 { alloc_artiq::seed(&mut _fheap as *mut u8, &_eheap as *const u8 as usize - &_fheap as *const u8 as usize); + fn oom() -> ! { panic!("out of memory") } + alloc::oom::set_oom_handler(oom); + static mut LOG_BUFFER: [u8; 65536] = [0; 65536]; logger_artiq::BufferLogger::new(&mut LOG_BUFFER[..]).register(startup); 0 diff --git a/artiq/frontend/artiq_devtool.py b/artiq/frontend/artiq_devtool.py index 6cbafcad1..08856c9dc 100755 --- a/artiq/frontend/artiq_devtool.py +++ b/artiq/frontend/artiq_devtool.py @@ -36,7 +36,7 @@ def get_argparser(): parser.add_argument("-t", "--target", metavar="TARGET", type=str, default="kc705_dds", help="Target to build, one of: " - "kc705_dds kc705_drtio_satellite") + "kc705_dds kc705_drtio_master kc705_drtio_satellite") parser.add_argument("-c", "--config", metavar="TARGET_CFG", type=str, default="openocd-kc705.cfg", help="OpenOCD configuration file corresponding to the development board") @@ -53,7 +53,7 @@ def main(): args = get_argparser().parse_args() init_logger(args) - if args.target == "kc705_dds": + if args.target == "kc705_dds" or args.target == "kc705_drtio_master": firmware = "runtime" elif args.target == "kc705_drtio_satellite": firmware = "satman" diff --git a/conda/artiq-dev/meta.yaml b/conda/artiq-dev/meta.yaml index 143a46b74..8a267a51f 100644 --- a/conda/artiq-dev/meta.yaml +++ b/conda/artiq-dev/meta.yaml @@ -20,7 +20,7 @@ requirements: - binutils-or1k-linux >=2.27 - llvm-or1k - llvmlite-artiq 0.12.0.dev py35_30 - - rust-core-or1k 1.17.0 12 + - rust-core-or1k 1.18.0 13 - cargo 0.11.0 - openocd >=0.10 - lit diff --git a/doc/manual/developing.rst b/doc/manual/developing.rst index d7b57dcf9..27c20bd2f 100644 --- a/doc/manual/developing.rst +++ b/doc/manual/developing.rst @@ -62,7 +62,7 @@ and the ARTIQ kernels. $ cd ~/artiq-dev $ git clone --recursive https://github.com/m-labs/artiq - + Add ``-b release-X`` to the ``git clone`` command if you are building a stable branch of ARTIQ (the default will fetch the development ``master`` branch). * Install OpenRISC binutils (or1k-linux-...): :: @@ -99,13 +99,15 @@ and the ARTIQ kernels. * Install Rust: :: $ cd ~/artiq-dev - $ git clone -b artiq-1.16.0 https://github.com/m-labs/rust + $ git clone -b artiq-1.18.0 https://github.com/m-labs/rust $ cd rust $ git submodule update --init $ mkdir build $ cd build $ ../configure --prefix=/usr/local/rust-or1k --llvm-root=/usr/local/llvm-or1k --disable-manage-submodules - $ sudo make install -j4 + $ sudo mkdir /usr/local/rust-or1k + $ sudo chown $USER.$USER /usr/local/rust-or1k + $ make install $ libs="libcore liballoc libstd_unicode libcollections liblibc_mini libunwind" $ rustc="/usr/local/rust-or1k/bin/rustc --target or1k-unknown-none -g -C target-feature=+mul,+div,+ffl1,+cmov,+addc -C opt-level=s -L ."