Skip to content

add support for Cortex-R devices #339

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

Merged
merged 2 commits into from
Aug 24, 2018
Merged
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,31 @@ impl Build {
if target.starts_with("thumbv7m") {
cmd.args.push("-march=armv7-m".into());
}
if target.starts_with("armebv7r") | target.starts_with("armv7r") {
if target.starts_with("armeb") {
cmd.args.push("-mbig-endian".into());
} else {
cmd.args.push("-mlittle-endian".into());
}

// ARM mode
cmd.args.push("-marm".into());

// R Profile
cmd.args.push("-march=armv7-r".into());

if target.ends_with("eabihf") {
// Calling convention
cmd.args.push("-mfloat-abi=hard".into());

// lowest common denominator FPU
// (see Cortex-R4 technical reference manual)
cmd.args.push("-mfpu=vfpv3-d16".into())
} else {
// Calling convention
cmd.args.push("-mfloat-abi=soft".into());
}
}
}
}

Expand Down Expand Up @@ -1672,6 +1697,9 @@ impl Build {
"sparc64-unknown-linux-gnu" => Some("sparc64-linux-gnu"),
"sparc64-unknown-netbsd" => Some("sparc64--netbsd"),
"sparcv9-sun-solaris" => Some("sparcv9-sun-solaris"),
"armebv7r-none-eabihf" => Some("arm-none-eabi"),

Choose a reason for hiding this comment

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

Is this correct? eb = big-endian in armeb . I use 'armeb-eabi' and not arm-none-eabi in this case (Linaro toolchain)

Copy link
Member Author

Choose a reason for hiding this comment

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

The arm-none-eabi-gcc toolchain can also generate big endian code but it needs the -mbig-endian flag. The latest commit addresses that.

$ arm-none-eabi-readelf -h ./target/armebv7r-none-eabihf/debug/build/foo-728ce1e8d146ec12/out/libfoo.a

File: ./target/armebv7r-none-eabihf/debug/build/foo-728ce1e8d146ec12/out/libfoo.a(foo.o)
ELF Header:
  Magic:   7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          1188 (bytes into file)
  Flags:                             0x5000000, Version5 EABI
  Size of this header:               52 (bytes)
  Size of program headers:           0 (bytes)
  Number of program headers:         0
  Size of section headers:           40 (bytes)
  Number of section headers:         22
  Section header string table index: 21
$ arm-none-eabi-readelf -h ./target/armv7r-none-eabi/debug/build/foo-728ce1e8d146ec12/out/libfoo.a

File: ./target/armv7r-none-eabi/debug/build/foo-728ce1e8d146ec12/out/libfoo.a(foo.o)
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          1168 (bytes into file)
  Flags:                             0x5000000, Version5 EABI
  Size of this header:               52 (bytes)
  Size of program headers:           0 (bytes)
  Number of program headers:         0
  Size of section headers:           40 (bytes)
  Number of section headers:         22
  Section header string table index: 21

"armv7r-none-eabi" => Some("arm-none-eabi"),
"armv7r-none-eabihf" => Some("arm-none-eabi"),
"thumbv6m-none-eabi" => Some("arm-none-eabi"),
"thumbv7em-none-eabi" => Some("arm-none-eabi"),
"thumbv7em-none-eabihf" => Some("arm-none-eabi"),
Expand Down