Skip to content

Commit

Permalink
Update to nightly 2016-10-14, use new compiler builtins
Browse files Browse the repository at this point in the history
Rust has changed some stuff regarding the core crate and compiler intrinsics (e.g. float to int conversion).
Crates do not need to link to libcore anymore, but need to link against compiler_builtins.

This changes fixes the appearance of recursive intrinsics that happend with larger arrays
https://users.rust-lang.org/t/compiler-generates-recursive-memclr/7575/3
rust-lang/rust#31544
  • Loading branch information
Phaiax committed Oct 15, 2016
1 parent 4c9f247 commit 4727410
Show file tree
Hide file tree
Showing 63 changed files with 92 additions and 277 deletions.
13 changes: 13 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
[target.thumbv6m-none-eabi]
linker = "arm-none-eabi-gcc"
ar = "arm-none-eabi-ar"
rustflags = [
"-C",
"link-arg=-Tlayout.ld",
]

[target.thumbv7m-none-eabi]
linker = "arm-none-eabi-gcc"
ar = "arm-none-eabi-ar"
rustflags = [
"-C",
"link-arg=-Tlayout.ld",
]

[target.thumbv7em-none-eabi]
linker = "arm-none-eabi-gcc"
ar = "arm-none-eabi-ar"
rustflags = [
"-C",
"link-arg=-Tlayout.ld",
]

4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
language: rust
rust: nightly-2016-09-17
rust: nightly-2016-10-14
before_install:
- sudo add-apt-repository -y ppa:terry.guo/gcc-arm-embedded
- sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 6D1D8367A3421AFB
- sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/terry_guo-gcc-arm-embedded-precise.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
- sudo apt-get install gcc-arm-none-eabi libcurl4-openssl-dev libelf-dev libdw-dev
- wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && tar xzf master.tar.gz
- (mkdir kcov-master/build && cd kcov-master/build && cmake .. && make && make install DESTDIR=../tmp)
before_script:
- cargo install xargo
script:
- ./support/build-jenkins.sh
env:
Expand Down
23 changes: 9 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,23 @@ multitasking = ["cpu_cortex-m4"]

loglib = ["log"]

[target.thumbv6m-none-eabi.dependencies]
rust-libcore = "*"

[target.thumbv7m-none-eabi.dependencies]
rust-libcore = "*"

[target.thumbv7em-none-eabi.dependencies]
rust-libcore = "*"

[dependencies.ioreg]
path = "./ioreg"

[dependencies.volatile_cell]
path = "./volatile_cell"

[dependencies.rlibc]
git = "https://github.com/hackndev/rlibc"
branch = "zinc"

[dependencies]
rlibc = "1.0"

[dependencies.compiler_builtins]
git = "https://github.com/Phaiax/compiler-builtins"
branch = "gccdeptogit"
features = ["c"]

[dependencies.log]
git = "https://github.com/archaelus/log"
branch = "zinc"
version = "*"
default-features = false
optional = true

Expand Down
38 changes: 23 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,20 @@ Zinc is distributed under Apache-2.0, see LICENSE for more details.
### Environment Setup

For the time being, Zinc makes use unstable features of the Rust
language. As such, we recommend using the latest nightly version of
Rust for development. As features of the language stabilize over
language. As such, we recommend using the nightly version of
Rust mentioned below for development.
As features of the language stabilize over
time, it is the goal of Zinc to eventually be able to target stable
versions of the compiler.
[rustup.rs](https://www.rustup.rs/) may be used to manage
installations of multiple versions of rust on single machine.

The currently supported Rust version is nightly-2016-09-17. To install
The currently supported Rust version is nightly-2016-10-14. To install
it with rustup use the following:

```Shell
rustup install nightly-2016-09-17
rustup override set nightly-2016-09-17
rustup install nightly-2016-10-14
rustup override set nightly-2016-10-14
```

In addition to rust itself, a GCC cross-toolchain for ARM must be
Expand All @@ -87,18 +88,24 @@ GCC Linker is still used at this time. The
[GCCM ARM Embedded toolchain](https://launchpad.net/gcc-arm-embedded/+download)
works well for most people.

The rust language team is currently mixing up things that belong to cross compiling. Keep an eye out here for future changes. For now you need to use [Xargo](https://github.com/japaric/xargo) instead of Cargo.

```Shell
cargo install xargo
```

Note: The previously needed .json files for the thumb targets are now part of the rust compiler. You can delete it. You also need to get rid of any `rust-libcore` mentions in any Cargo.toml files, including dependencies. Otherwise you will get a lot of these errors: `duplicate lang item in crate \`core\`: \`const_ptr\`.`

### Building Examples Within Zinc

There are several examples available within the Zinc source itself.
Zinc makes use of Cargo for its build system, but it is still necesary
Zinc makes use of Cargo/Xargo for its build system, but it is still necesary
to provide the build system with a few pieces of information for it to
properly compile for your target.

Namely, cargo must know about and have access to:

1. The target specification for the machine being specified (consumed
by the compiler)
2. A feature telling the code what platform is being targetted. These
1. A feature telling the code what platform is being targetted. These
features are defined in the form `mcu_<platform>`.

Suppose we are targetting the `k20` platform. In that case, I could
Expand All @@ -108,22 +115,23 @@ platforms to targets.

```
$ cd examples/blink_k20
$ ln -s ../../thumbv7em-none-eabi.json
$ cargo build --target=thumbv7em-none-eabi --features mcu_k20 --release
$ xcargo build --target=thumbv7em-none-eabi --features mcu_k20 --release
$ file target/thumbv7em-none-eabi/release/blink
target/thumbv7em-none-eabi/release/blink: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, not stripped
```

If you receive link errors, you probably need to tell Cargo to use
your cross-compilers linker. You can do this by adding a
`.cargo/config` to either your home directory or the root of the Zinc
project:
the correct linker file. (This was previously defined in the target.json) You can do this by adding a `.cargo/config` to either your home directory or the root of the Zinc project:

```toml
[target.thumbv7em-none-eabi]
linker = "arm-none-eabi-gcc"
ar = "arm-none-eabi-ar"
rustflags = [
"-C",
"link-arg=-Tlayout.ld",
]
```

### Using Zinc for your Project
Expand All @@ -132,7 +140,7 @@ Sinc Zinc uses cargo for its build system, using Zinc from your own
project just requires setting up your Cargo.toml correctly.

You can find an example of how to do that here:
https://github.com/posborne/zinc-example-lpc1768
https://github.com/posborne/zinc-example-lpc1768 (currently outdated)

### Contacting developers

Expand Down
1 change: 0 additions & 1 deletion examples/adc_lpc17xx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ mcu_lpc17xx = ["zinc/mcu_lpc17xx"]
[dependencies]
zinc = { path = "../.." }
macro_platformtree = { path = "../../macro_platformtree" }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/adc_lpc17xx/thumbv7m-none-eabi.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/blink_k20/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ mcu_k20 = ["zinc/mcu_k20"]
[dependencies]
zinc = { path = "../.." }
macro_zinc = { path = "../../macro_zinc" }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/blink_k20/thumbv7em-none-eabi.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/blink_k20_isr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ mcu_k20 = ["zinc/mcu_k20"]

[dependencies]
zinc = { path = "../.." }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/blink_k20_isr/thumbv7em-none-eabi.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/blink_lpc17xx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ mcu_lpc17xx = ["zinc/mcu_lpc17xx"]
[dependencies]
zinc = { path = "../.." }
macro_zinc = { path = "../../macro_zinc" }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/blink_lpc17xx/thumbv7m-none-eabi.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/blink_pt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ mcu_lpc17xx = ["zinc/mcu_lpc17xx"]
[dependencies]
zinc = { path = "../.." }
macro_platformtree = { path = "../../macro_platformtree" }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/blink_pt/thumbv7m-none-eabi.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/blink_stm32f1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ mcu_stm32f1 = ["zinc/mcu_stm32f1"]
[dependencies]
zinc = { path = "../.." }
macro_zinc = { path = "../../macro_zinc" }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/blink_stm32f4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ mcu_stm32f4 = ["zinc/mcu_stm32f4"]
[dependencies]
zinc = { path = "../.." }
macro_zinc = { path = "../../macro_zinc" }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/blink_stm32f4/thumbv7em-none-eabi.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/blink_stm32f7/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ mcu_stm32f7 = ["zinc/mcu_stm32f7"]
[dependencies]
zinc = { path = "../.." }
macro_zinc = { path = "../../macro_zinc" }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/blink_stm32f7/thumbv7em-none-eabi.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/blink_stm32l1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ mcu_stm32l1 = ["zinc/mcu_stm32l1"]
[dependencies]
zinc = { path = "../.." }
macro_zinc = { path = "../../macro_zinc" }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/blink_stm32l1/thumbv7m-none-eabi.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/blink_tiva_c/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ mcu_tiva_c = ["zinc/mcu_tiva_c"]
[dependencies]
zinc = { path = "../.." }
macro_platformtree = { path = "../../macro_platformtree" }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/blink_tiva_c/thumbv7em-none-eabi.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/bluenrg_stm32l1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ mcu_stm32l1 = ["zinc/mcu_stm32l1"]

[dependencies]
zinc = { path = "../.." }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/bluenrg_stm32l1/thumbv7m-none-eabi.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/dht22/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ mcu_lpc17xx = ["zinc/mcu_lpc17xx"]
[dependencies]
zinc = { path = "../.." }
macro_platformtree = { path = "../../macro_platformtree" }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/dht22/thumbv7m-none-eabi.json

This file was deleted.

2 changes: 1 addition & 1 deletion examples/empty/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ version = "0.0.1"
[features]
mcu_lpc11xx = ["zinc/mcu_lpc11xx"]
mcu_lpc17xx = ["zinc/mcu_lpc17xx"]
mcu_stm32f1 = ["zinc/mcu_stm32f1"]
mcu_stm32f4 = ["zinc/mcu_stm32f4"]
mcu_stm32l1 = ["zinc/mcu_stm32l1"]
mcu_k20 = ["zinc/mcu_k20"]
Expand All @@ -13,4 +14,3 @@ mcu_tiva_c = ["zinc/mcu_tiva_c"]
[dependencies]
zinc = { path = "../.." }
macro_zinc = { path = "../../macro_zinc" }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/empty/thumbv6m-none-eabi.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/empty/thumbv7em-none-eabi.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/empty/thumbv7m-none-eabi.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/lcd_tiva_c/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ mcu_tiva_c = ["zinc/mcu_tiva_c"]
[dependencies]
zinc = { path = "../.." }
macro_platformtree = { path = "../../macro_platformtree" }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/rgb_pwm_lpc17xx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ mcu_lpc17xx = ["zinc/mcu_lpc17xx"]
zinc = { path = "../.." }
macro_zinc = { path = "../../macro_zinc" }
macro_platformtree = { path = "../../macro_platformtree" }
rust-libcore = "*"

[[bin]]
name = "rgb_pwm_lpc17xx"
Expand Down
1 change: 0 additions & 1 deletion examples/rgb_pwm_lpc17xx/thumbv7m-none-eabi.json

This file was deleted.

2 changes: 2 additions & 0 deletions examples/uart/.cargo/config
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[build]
target = "thumbv7m-none-eabi"
linker = "arm-none-eabi-gcc"
ar = "arm-none-eabi-ar"
1 change: 0 additions & 1 deletion examples/uart/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ mcu_lpc17xx = ["zinc/mcu_lpc17xx"]
[dependencies]
zinc = { path = "../.." }
macro_platformtree = { path = "../../macro_platformtree" }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/uart/thumbv7m-none-eabi.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/uart_tiva_c/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ mcu_tiva_c = ["zinc/mcu_tiva_c"]
[dependencies]
zinc = { path = "../.." }
macro_platformtree = { path = "../../macro_platformtree" }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/uart_tiva_c/thumbv7em-none-eabi.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/usart_stm32f1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ mcu_stm32f1 = ["zinc/mcu_stm32f1"]
[dependencies]
zinc = { path = "../.." }
macro_zinc = { path = "../../macro_zinc" }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/usart_stm32l1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ mcu_stm32l1 = ["zinc/mcu_stm32l1"]
[dependencies]
zinc = { path = "../.." }
macro_zinc = { path = "../../macro_zinc" }
rust-libcore = "*"
1 change: 0 additions & 1 deletion examples/usart_stm32l1/thumbv7m-none-eabi.json

This file was deleted.

4 changes: 2 additions & 2 deletions ioreg/src/builder/union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn reg_struct_type(cx: &ExtCtxt, path: &Vec<String>, reg: &node::Reg)
1 => base_ty,
n =>
cx.ty(reg.count.span,
ast::TyKind::FixedLengthVec(base_ty, expr_usize(cx, respan(reg.count.span, n as u64)))),
ast::TyKind::Array(base_ty, expr_usize(cx, respan(reg.count.span, n as u64)))),
}
}

Expand Down Expand Up @@ -146,7 +146,7 @@ impl<'a, 'b> BuildUnionTypes<'a, 'b> {
let ty: P<ast::Ty> =
self.cx.ty(
DUMMY_SP,
ast::TyKind::FixedLengthVec(u8_ty, expr_usize(self.cx, respan(DUMMY_SP, length))));
ast::TyKind::Array(u8_ty, expr_usize(self.cx, respan(DUMMY_SP, length))));
ast::StructField {
span: DUMMY_SP,
ident: Some(self.cx.ident_of(format!("_pad{}", index).as_str())),
Expand Down
1 change: 1 addition & 0 deletions macro_platformtree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ fn macro_zinc_task_item(cx: &mut ExtCtxt, it: P<ast::Item>) -> P<ast::Item> {
cx.typaram(
DUMMY_SP,
cx.ident_of(ty.to_tyhash().as_str()),
vec![],
P::from_vec(vec!(cx.typarambound(
cx.path(DUMMY_SP, ty.as_str().split("::").map(|t| cx.ident_of(t)).collect())))),
None)
Expand Down
5 changes: 3 additions & 2 deletions platformtree/src/builder/meta_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use syntax::codemap::DUMMY_SP;
use syntax::ext::base::ExtCtxt;
use syntax::ext::build::AstBuilder;
use syntax::parse::token::{InternedString, intern_and_get_ident};
use std::hash::{Hash, Hasher, SipHasher};
use std::hash::{Hash, Hasher};
use std::collections::hash_map::DefaultHasher;

static TAG: &'static str = "__zinc_task_ty_params";

Expand All @@ -28,7 +29,7 @@ pub trait ToTyHash {

impl ToTyHash for String {
fn to_tyhash(&self) -> String {
let mut s = SipHasher::new();
let mut s = DefaultHasher::new();
self.hash(&mut s);
let h: u64 = s.finish();
format!("Ty{:X}", h)
Expand Down
3 changes: 2 additions & 1 deletion platformtree/src/builder/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ fn build_args(builder: &mut Builder, cx: &mut ExtCtxt,
let typaram = cx.typaram(
DUMMY_SP,
cx.ident_of(ty.to_tyhash().as_str()),
vec![],
P::from_vec(vec!(
ast::RegionTyParamBound(cx.lifetime(DUMMY_SP, intern("'a")))
)),
Expand All @@ -173,7 +174,7 @@ fn build_args(builder: &mut Builder, cx: &mut ExtCtxt,
node: ast::ItemKind::Struct(
ast::VariantData::Struct(fields, ast::DUMMY_NODE_ID),
ast::Generics {
lifetimes: vec!(cx.lifetime_def(DUMMY_SP, intern("'a"), vec!())),
lifetimes: vec!(cx.lifetime_def(DUMMY_SP, intern("'a"), vec![], vec!())),
ty_params: P::from_vec(collected_params),
where_clause: ast::WhereClause {
id: ast::DUMMY_NODE_ID,
Expand Down
Loading

0 comments on commit 4727410

Please sign in to comment.