Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

Requires mman.h? #17

Closed
thejpster opened this issue Aug 7, 2016 · 8 comments
Closed

Requires mman.h? #17

thejpster opened this issue Aug 7, 2016 · 8 comments

Comments

@thejpster
Copy link
Contributor

Trying to build compiler-rt.rs with xargo I get quite far, then it fails with this error. The Fedora packages for arm-none-eabi-gcc and arm-none-eabi-newlib don't include mman.h, which seems reasonable as it looks like a POSIX memory mapping API.

$ AR_lm4f120=arm-none-eabi-gcc CC_lm4f120=arm-none-eabi-gcc xargo build --target=lm4f120 -v
       Fresh itoa v0.1.1
       Fresh serde v0.7.15
       Fresh gcc v0.3.32
       Fresh libc v0.2.15
       Fresh spin v0.4.3
       Fresh rlibc v1.0.0
       Fresh rand v0.3.14
       Fresh lazy_static v0.2.1
       Fresh num-traits v0.1.34
       Fresh tempdir v0.3.5
       Fresh serde_json v0.7.4
   Compiling compiler-rt v0.1.0 (https://github.com/japaric/compiler-rt.rs#cafbcc36)
     Running `/home/jonathan/Documents/programming/rust/bare-metal-arm-rust/target/debug/build/compiler-rt-e5e01a4239060006/build-script-build`
error: failed to run custom build command for `compiler-rt v0.1.0 (https://github.com/japaric/compiler-rt.rs#cafbcc36)`
process didn't exit successfully: `/home/jonathan/Documents/programming/rust/bare-metal-arm-rust/target/debug/build/compiler-rt-e5e01a4239060006/build-script-build` (signal: 6, SIGABRT: process abort signal)
--- stdout
TARGET = Some("lm4f120")
...
running: "arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fPIC" "-o" "/home/jonathan/Documents/programming/rust/bare-metal-arm-rust/target/lm4f120/debug/build/compiler-rt-e5e01a4239060006/out/divxc3.o" "-c" "/tmp/compiler-rt.D1OKjKwA08DC/lib/builtins/divxc3.c"
ExitStatus(ExitStatus(0))
TARGET = Some("lm4f120")
OPT_LEVEL = Some("0")
PROFILE = Some("debug")
TARGET = Some("lm4f120")
debug=true opt-level=0
TARGET = Some("lm4f120")
HOST = Some("x86_64-unknown-linux-gnu")
CFLAGS_lm4f120 = None
CFLAGS_lm4f120 = None
TARGET_CFLAGS = None
CFLAGS = None
running: "arm-none-eabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fPIC" "-o" "/home/jonathan/Documents/programming/rust/bare-metal-arm-rust/target/lm4f120/debug/build/compiler-rt-e5e01a4239060006/out/enable_execute_stack.o" "-c" "/tmp/compiler-rt.D1OKjKwA08DC/lib/builtins/enable_execute_stack.c"
ExitStatus(ExitStatus(256))


command did not execute successfully, got: exit code: 1



--- stderr
Cloning into '/tmp/compiler-rt.D1OKjKwA08DC'...
/tmp/compiler-rt.D1OKjKwA08DC/lib/builtins/enable_execute_stack.c:14:22: fatal error: sys/mman.h: No such file or directory
compilation terminated.
thread 'main' panicked at 'explicit panic', /home/jonathan/.cargo/registry/src/github.com-1ecc6299db9ec823/gcc-0.3.32/src/lib.rs:848
note: Run with `RUST_BACKTRACE=1` for a backtrace.

error: `cargo` process didn't exit successfully
@japaric
Copy link
Contributor

japaric commented Aug 7, 2016

LLVM's compiler-rt doesn't really support the ARM Cortex-M architecture. This crate compiles all the intrinsics that don't fail to compile to that architecture regardless of whether the intrinsic is actually "used" (i.e. LLVM lowers some Rust code to that intrinsic). I'd be okay with removing this intrinsic (enable_execute_stack) if it doesn't compile on Debian but I'll add it back if we later find out that LLVM lowers some Rust code to that intrinsic.

@thejpster
Copy link
Contributor Author

Well I wasn't sure if I even needed compiler-rt.rs, but your xargo example for building copper for an STM32 seemed to include it so I figured I'd add it.

@japaric
Copy link
Contributor

japaric commented Aug 7, 2016

Well I wasn't sure if I even needed compiler-rt.rs

Nah, you can actually get quite far without it (unless you need to do floating point operations on a device without FPU like Cortex-M0 or Cortex-M0).

your xargo example for building copper for an STM32 seemed to include it so I figured I'd add it.

Did it? Which one? I'm sure the copper book examples don't use compiler-rt.rs -- all the example use target spec files with no-compilert-rt set to true.

@thejpster
Copy link
Contributor Author

@japaric
Copy link
Contributor

japaric commented Aug 7, 2016

Oh, that copper; I thought you mean the book. cu needs very little of compiler-rt.rs; I might rewrite the needed intrinsics in Rust so cu can drop its dependency on compiler-rt -- that would make building cu simpler.

@thejpster
Copy link
Contributor Author

Well I wasn't sure if I even needed compiler-rt.rs

Having said that, I was working through porting Phil Oppermann's bump and heap allocators to my bare metal ARM project this evening and I found I needed __aeabi_memclr4 and __aeabi_memmove. I've diverted them to the rlibc equivalents for now but I think fixing this would be useful.

@thejpster
Copy link
Contributor Author

This came about because RUST_TARGET_PATH wasn't set, so the build script couldn't actually see my target file, and so it didn't realise this was an os=none build.

@japaric
Copy link
Contributor

japaric commented Aug 7, 2016

I found I needed __aeabi_memclr4 and __aeabi_memmove

I'm porting compiler-rt to Rust as part of rust-lang/rust#35437. My work so far is in this repo. I just started but the crate already provides these two symbols. If you want to switch to it, check japaric-archived/cu#37

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants