Skip to content

The thumb* target family (which have newlib libc) are not supported #375

Closed
@SimonSapin

Description

@SimonSapin

I have embedded hardware without an OS. I build Rust code for it with --target thumbv7em-none-eabi and this thumbv7em-none-eabi.json file:

{
    "arch": "arm",
    "cpu": "cortex-m4",
    "data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64",
    "disable-redzone": true,
    "executables": true,
    "llvm-target": "thumbv7em-none-eabi",
    "morestack": false,
    "os": "none",
    "relocation-model": "static",
    "target-endian": "little",
    "target-pointer-width": "32",
    "no-compiler-rt": true,
    "pre-link-args": [
        "-mcpu=cortex-m4", "-mthumb",
        "-Tlayout.ld"
    ],
    "post-link-args": [
        "-lm", "-lgcc", "-lnosys"
    ]
}

If I add a Cargo dependency on the libc crate and build with this target, I get many build errors. The first and last are below. The entire thing is at https://gist.github.com/anonymous/780fe74b2ae2834fc9c738dbff60acc0

   Compiling libc v0.2.15
error[E0412]: type name `c_char` is undefined or not in scope
   --> /home/simon/tmp/cargo-home/registry/src/github.com-1ecc6299db9ec823/libc-0.2.15/src/lib.rs:153:35
    |
153 |     pub fn fopen(filename: *const c_char,
    |                                   ^^^^^^ undefined or not in scope
    |
    = help: no candidates by the name of `c_char` found in your project; maybe you misspelled the name or forgot to import an external crate?


// Removed: ~4000 more lines


error[E0204]: the trait `Copy` may not be implemented for this type
   --> /home/simon/tmp/cargo-home/registry/src/github.com-1ecc6299db9ec823/libc-0.2.15/src/macros.rs:44:9
    |
44  |         impl ::dox::Copy for $i {}
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^ field `rlim_cur` does not implement `Copy`
    | 
   ::: /home/simon/tmp/cargo-home/registry/src/github.com-1ecc6299db9ec823/libc-0.2.15/src/lib.rs
    |
261 | cfg_if! {
    | - in this macro invocation

error: aborting due to 5 previous errors

error: Could not compile `libc`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions