RazrFalcon / memmap2-rs

cross-platform Rust API for memory mapped IO
Apache License 2.0
419 stars 74 forks source link

Trouble compiling on aarch64 for xtensa-esp32-espidf #61

Closed Gazedo closed 2 years ago

Gazedo commented 2 years ago

I'm having issues when compiling in a dev container while on aarch64 for a target of xtensa-esp32-idf. Its a std application for an esp32 and unfortunately the example is for no_std so I'm trying to convert it for my use. There are a total of 35 errors shown below:

I don't know if the issue is with compiling it on my M1 mac in a Debian docker container or if the issue is the feature selection. Any advice would be appreciated. Let me know if there is any other info required, I don't have my code hosted yet anywhere but I would be happy to upload and share it if that would help as well. I should note that I can compile libc crate just fine and I have tried compiling it in a couple different ways. Standard features and no defaults and "std".

   Compiling hash32 v0.2.1
error[E0425]: cannot find value `MAP_FAILED` in crate `libc`
  --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:93:29
   |
93 |             if ptr == libc::MAP_FAILED {
   |                             ^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `PROT_READ` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:108:19
    |
108 |             libc::PROT_READ,
    |                   ^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `MAP_SHARED` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:109:19
    |
109 |             libc::MAP_SHARED | populate,
    |                   ^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `PROT_READ` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:119:19
    |
119 |             libc::PROT_READ | libc::PROT_EXEC,
    |                   ^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `PROT_EXEC` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:119:37
    |
119 |             libc::PROT_READ | libc::PROT_EXEC,
    |                                     ^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `MAP_SHARED` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:120:19
    |
120 |             libc::MAP_SHARED | populate,
    |                   ^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `PROT_READ` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:130:19
    |
130 |             libc::PROT_READ | libc::PROT_WRITE,
    |                   ^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `PROT_WRITE` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:130:37
    |
130 |             libc::PROT_READ | libc::PROT_WRITE,
    |                                     ^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `MAP_SHARED` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:131:19
    |
131 |             libc::MAP_SHARED | populate,
    |                   ^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `PROT_READ` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:141:19
    |
141 |             libc::PROT_READ | libc::PROT_WRITE,
    |                   ^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `PROT_WRITE` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:141:37
    |
141 |             libc::PROT_READ | libc::PROT_WRITE,
    |                                     ^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `MAP_PRIVATE` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:142:19
    |
142 |             libc::MAP_PRIVATE | populate,
    |                   ^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `PROT_READ` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:157:19
    |
157 |             libc::PROT_READ,
    |                   ^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `MAP_PRIVATE` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:158:19
    |
158 |             libc::MAP_PRIVATE | populate,
    |                   ^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `PROT_READ` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:169:19
    |
169 |             libc::PROT_READ | libc::PROT_WRITE,
    |                   ^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `PROT_WRITE` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:169:37
    |
169 |             libc::PROT_READ | libc::PROT_WRITE,
    |                                     ^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `MAP_PRIVATE` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:170:19
    |
170 |             libc::MAP_PRIVATE | libc::MAP_ANON | stack,
    |                   ^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `MAP_ANON` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:170:39
    |
170 |             libc::MAP_PRIVATE | libc::MAP_ANON | stack,
    |                                       ^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `msync` in crate `libc`
    --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:181:28
     |
181  |             unsafe { libc::msync(self.ptr.offset(offset), len as libc::size_t, libc::MS_SYNC) };
     |                            ^^^^^ help: a function with a similar name exists: `fsync`
     |
    ::: /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.134/src/unix/mod.rs:1009:5
     |
1009 |     pub fn fsync(fd: ::c_int) -> ::c_int;
     |     ------------------------------------ similarly named function `fsync` defined here

error[E0425]: cannot find value `MS_SYNC` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:181:86
    |
181 |             unsafe { libc::msync(self.ptr.offset(offset), len as libc::size_t, libc::MS_SYNC) };
    |                                                                                      ^^^^^^^ help: a constant with a similar name exists: `O_SYNC`
    |
   ::: /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.134/src/unix/newlib/mod.rs:393:1
    |
393 | pub const O_SYNC: ::c_int = 8192;
    | ------------------------- similarly named constant `O_SYNC` defined here

error[E0425]: cannot find function `msync` in crate `libc`
    --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:194:28
     |
194  |             unsafe { libc::msync(self.ptr.offset(offset), len as libc::size_t, libc::MS_ASYNC) };
     |                            ^^^^^ help: a function with a similar name exists: `fsync`
     |
    ::: /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.134/src/unix/mod.rs:1009:5
     |
1009 |     pub fn fsync(fd: ::c_int) -> ::c_int;
     |     ------------------------------------ similarly named function `fsync` defined here

error[E0425]: cannot find value `MS_ASYNC` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:194:86
    |
194 |             unsafe { libc::msync(self.ptr.offset(offset), len as libc::size_t, libc::MS_ASYNC) };
    |                                                                                      ^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `mprotect` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:208:22
    |
208 |             if libc::mprotect(ptr, len, prot) == 0 {
    |                      ^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `PROT_READ` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:217:29
    |
217 |         self.mprotect(libc::PROT_READ)
    |                             ^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `PROT_READ` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:221:29
    |
221 |         self.mprotect(libc::PROT_READ | libc::PROT_EXEC)
    |                             ^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `PROT_EXEC` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:221:47
    |
221 |         self.mprotect(libc::PROT_READ | libc::PROT_EXEC)
    |                                               ^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `PROT_READ` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:225:29
    |
225 |         self.mprotect(libc::PROT_READ | libc::PROT_WRITE)
    |                             ^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `PROT_WRITE` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:225:47
    |
225 |         self.mprotect(libc::PROT_READ | libc::PROT_WRITE)
    |                                               ^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `madvise` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:245:22
    |
245 |             if libc::madvise(self.ptr, self.len, advice as i32) != 0 {
    |                      ^^^^^^^ not found in `libc`

error[E0425]: cannot find value `_SC_PAGESIZE` in crate `libc`
   --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/unix.rs:297:58
    |
297 |             let page_size = unsafe { libc::sysconf(libc::_SC_PAGESIZE) as usize };
    |                                                          ^^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `MADV_NORMAL` in crate `libc`
  --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/advice.rs:13:20
   |
13 |     Normal = libc::MADV_NORMAL,
   |                    ^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `MADV_RANDOM` in crate `libc`
  --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/advice.rs:19:20
   |
19 |     Random = libc::MADV_RANDOM,
   |                    ^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `MADV_SEQUENTIAL` in crate `libc`
  --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/advice.rs:26:24
   |
26 |     Sequential = libc::MADV_SEQUENTIAL,
   |                        ^^^^^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `MADV_WILLNEED` in crate `libc`
  --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/advice.rs:32:22
   |
32 |     WillNeed = libc::MADV_WILLNEED,
   |                      ^^^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `MADV_DONTNEED` in crate `libc`
  --> /home/esp/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.5.7/src/advice.rs:63:22
   |
63 |     DontNeed = libc::MADV_DONTNEED,
   |                      ^^^^^^^^^^^^^ not found in `libc`

For more information about this error, try `rustc --explain E0425`.
error: could not compile `memmap2` due to 35 previous errors
RazrFalcon commented 2 years ago

I would guess that your target simply doesn't support memory mapping. Or only a rudimentary one. I would suggest avoiding memmap2 use altogether.

Gazedo commented 2 years ago

@RazrFalcon Thanks for the advice! I was pretty sure it was a simple compilation issue. The memmap2 dependency is part of the slint dependencies as part of usvg using fontdb which I think are your libraries as well. I'll see if I can figure out how the correct series of features to use, kind of a newbie at this so figuring it out as I go.