Skip to content
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

add Thumbs to the compiler #36874

Merged
merged 8 commits into from
Oct 4, 2016
Merged

add Thumbs to the compiler #36874

merged 8 commits into from
Oct 4, 2016

Conversation

japaric
Copy link
Member

@japaric japaric commented Sep 30, 2016

this commit adds 4 new target definitions to the compiler for easier
cross compilation to ARM Cortex-M devices.

  • thumbv6m-none-eabi
    • For the Cortex-M0, Cortex-M0+ and Cortex-M1
    • This architecture doesn't have hardware support (instructions) for
      atomics. Hence, the Atomic* structs are not available for this
      target.
  • thumbv7m-none-eabi
    • For the Cortex-M3
  • thumbv7em-none-eabi
    • For the FPU-less variants of the Cortex-M4 and Cortex-M7
    • On this target, all the floating point operations will be lowered
      software routines (intrinsics)
  • thumbv7em-none-eabihf
    • For the variants of the Cortex-M4 and Cortex-M7 that do have a FPU.
    • On this target, all the floating point operations will be lowered
      to hardware instructions

No binary releases of standard crates, like core, are planned for
these targets because Cargo, in the future, will compile e.g. the core
crate on the fly as part of the cargo build process. In the meantime,
you'll have to compile the core crate yourself. Xargo is the easiest
way to do that as in handles the compilation of core automatically and
can be used just like Cargo: xargo build --target thumbv6m-none-eabi
is all that's needed.


cc @brson @alexcrichton

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @arielb1 (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@alexcrichton
Copy link
Member

👍
👎

Copy link
Member Author

@japaric japaric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I meant to left this comment earlier but didn't realize I clicked the start review thing. 🤦

@@ -698,6 +707,10 @@ impl ToJson for Target {
target_option_val!(max_atomic_width);
target_option_val!(panic_strategy);

if self.options.max_atomic_width.to_string() != self.target_pointer_width {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexcrichton this fixes the problem I was seeing where setting max_atomic_width to 0 in the Target declaration was being converted into 32 due to the JSON roundtrip. I've also added a rmake test for this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woah can't we use Option instead of magic 0 treatment or similar? Granted, I'm arriving late to this issue so apologies if that has already been ruled out for good reason.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the simplest change necessary to make this work but using Option here sounds better; I'll give it a try.

@bors
Copy link
Contributor

bors commented Oct 1, 2016

☔ The latest upstream changes (presumably #36339) made this pull request unmergeable. Please resolve the merge conflicts.

Jorge Aparicio added 4 commits October 2, 2016 15:52
this commit adds 4 new target definitions to the compiler for easier
cross compilation to ARM Cortex-M devices.

- `thumbv6m-none-eabi`
  - For the Cortex-M0, Cortex-M0+ and Cortex-M1
  - This architecture doesn't have hardware support (instructions) for
    atomics. Hence, the `Atomic*` structs are not available for this
    target.
- `thumbv7m-none-eabi`
  - For the Cortex-M3
- `thumbv7em-none-eabi`
  - For the FPU-less variants of the Cortex-M4 and Cortex-M7
  - On this target, all the floating point operations will be lowered
    software routines (intrinsics)
- `thumbv7em-none-eabihf`
  - For the variants of the Cortex-M4 and Cortex-M7 that do have a FPU.
  - On this target, all the floating point operations will be lowered
    to hardware instructions

No binary releases of standard crates, like `core`, are planned for
these targets because Cargo, in the future, will compile e.g. the `core`
crate on the fly as part of the `cargo build` process. In the meantime,
you'll have to compile the `core` crate yourself. [Xargo] is the easiest
way to do that as in handles the compilation of `core` automatically and
can be used just like Cargo: `xargo build --target thumbv6m-none-eabi`
is all that's needed.

[Xargo]: https://crates.io/crates/xargo
@japaric
Copy link
Member Author

japaric commented Oct 2, 2016

Pushed two new commits. The first changes relocation-model to static (from pic) and the second changes panic-strategy to abort (from unwind). These values differ from the RFC text but I asked about these changes in the associated PR and the response has been positive so far.


options: TargetOptions {
// vfp4 lowest common denominator between the Cortex-M4 (vfp4) and the Cortex-M7 (vfp5)
features: "+vfp4".to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you also need +fp-only-sp

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, won't that preclude a user from enabling double precision hardware acceleration? Perhaps they'll have to pass -fp-only-sp apart from the other feature that enables DP FP ops. (I'm speculating; I haven't tried any of this)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes -fp-only-sp would work to switch it back on. +d16 should probably be added here too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thank you @parched.

@alexcrichton
Copy link
Member

@japaric could you also add some comments to each target file in line with the RFC itself? Basically just some basic rationale for the target name, what it's intended to be used for, etc.

@alexcrichton alexcrichton assigned alexcrichton and unassigned arielb1 Oct 3, 2016
@alexcrichton
Copy link
Member

@bors: r+

Thanks @japaric!

@bors
Copy link
Contributor

bors commented Oct 4, 2016

📌 Commit 6136069 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Oct 4, 2016

⌛ Testing commit 6136069 with merge a5dac7a...

bors added a commit that referenced this pull request Oct 4, 2016
add Thumbs to the compiler

this commit adds 4 new target definitions to the compiler for easier
cross compilation to ARM Cortex-M devices.

- `thumbv6m-none-eabi`
  - For the Cortex-M0, Cortex-M0+ and Cortex-M1
  - This architecture doesn't have hardware support (instructions) for
    atomics. Hence, the `Atomic*` structs are not available for this
    target.
- `thumbv7m-none-eabi`
  - For the Cortex-M3
- `thumbv7em-none-eabi`
  - For the FPU-less variants of the Cortex-M4 and Cortex-M7
  - On this target, all the floating point operations will be lowered
    software routines (intrinsics)
- `thumbv7em-none-eabihf`
  - For the variants of the Cortex-M4 and Cortex-M7 that do have a FPU.
  - On this target, all the floating point operations will be lowered
    to hardware instructions

No binary releases of standard crates, like `core`, are planned for
these targets because Cargo, in the future, will compile e.g. the `core`
crate on the fly as part of the `cargo build` process. In the meantime,
you'll have to compile the `core` crate yourself. [Xargo] is the easiest
way to do that as in handles the compilation of `core` automatically and
can be used just like Cargo: `xargo build --target thumbv6m-none-eabi`
is all that's needed.

[Xargo]: https://crates.io/crates/xargo

---

cc @brson @alexcrichton
@bors bors merged commit 6136069 into rust-lang:master Oct 4, 2016
@japaric japaric deleted the thumbs branch October 4, 2016 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants