Potential char
type issue on powerpc64le-unknown-linux-gnu
for wasm32-wasi
target #102976
Open
Description
I tried this code:
- Compiling this library for
wasm32-wasi
: https://github.com/kateinoigakukun/wasi-vfs. It creates a filelibwasi_vfs.a
which is then linked against when creating a Wasi application using the author's virtual filesystem application. This application allows packing files and directories into a Wasi .wasm binary for running with a runtime environment. - Both instances below also wasi-sdk-16 which was confirmed to be working by testing with other projects.
- Running
cargo build --release --target=wasm32-wasi
(same without--release
)
I expected to see this happen:
- On an x86_64 system (
x86_64-unknown-linux-gnu
), it compiles just fine forwasm32-wasi
. No errors or warnings.
Instead, this happened:
- Compiling the same code from
powerpc64le-unknown-linux-gnu
, it has errors where it seems to usei8
whenu8
is expected for Cchar
types.
I wonder if the toolchain for the wasm32-wasi
target on powerpc64le-unknown-linux-gnu
has a type issue somewhere.
Meta
rustc --version --verbose
on PPC64 machine:
$ rustc --version --verbose
rustc 1.64.0 (a55dd71d5 2022-09-19)
binary: rustc
commit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52
commit-date: 2022-09-19
host: powerpc64le-unknown-linux-gnu
release: 1.64.0
LLVM version: 14.0.6
$ rustup override set nightly # Also tried nightly
$ rustc --version --verbose
rustc 1.66.0-nightly (db0597f56 2022-10-11)
binary: rustc
commit-hash: db0597f5619d5ed93feca28e61226d3581cc7867
commit-date: 2022-10-11
host: powerpc64le-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2
rustc --version --verbose
on x86_64
machine:
$ rustc --version --verbose
rustc 1.64.0 (a55dd71d5 2022-09-19)
binary: rustc
commit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52
commit-date: 2022-09-19
host: x86_64-unknown-linux-gnu
release: 1.64.0
LLVM version: 14.0.6
Misc:
$ /opt/wasi-sdk/bin/clang --version
clang version 14.0.4 (https://github.com/llvm/llvm-project 29f1039a7285a5c3a9c353d054140bf2556d4c4d)
Target: wasm32-unknown-wasi
Thread model: posix
InstalledDir: /opt/wasi-sdk/bin
$ uname -a
Linux behemoth 5.18.19_1 #1 SMP Fri Aug 26 14:37:39 UTC 2022 ppc64le GNU/Linux
Backtrace
cargo build --release --target=wasm32-wasi
Compiling cc v1.0.73
Compiling wasi v0.11.0+wasi-snapshot-preview1
Compiling wasi-vfs v0.2.0 (/home/rjzak/CLionProjects/Profian/wasi-vfs)
error[E0308]: mismatched types
--> src/embed/linked_storage.rs:60:39
|
60 | let name = CStr::from_ptr(node.name).to_string_lossy().into_owned();
| -------------- ^^^^^^^^^ expected `i8`, found `u8`
| |
| arguments to this function are incorrect
|
= note: expected raw pointer `*const i8`
found raw pointer `*const u8`
note: associated function defined here
--> /home/rjzak/.rustup/toolchains/stable-powerpc64le-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ffi/c_str.rs:248:19
|
248 | pub unsafe fn from_ptr<'a>(ptr: *const c_char) -> &'a CStr {
| ^^^^^^^^
error[E0308]: mismatched types
--> src/embed/linked_storage.rs:147:85
|
147 | let result = wasi_vfs_embed_linked_storage_new_dir(self.context, &link, name.as_ptr());
| ------------------------------------- ^^^^^^^^^^^^^ expected `u8`, found `i8`
| |
| arguments to this function are incorrect
|
= note: expected raw pointer `*const u8`
found raw pointer `*const i8`
note: function defined here
--> src/embed/linked_storage.rs:93:8
|
93 | fn wasi_vfs_embed_linked_storage_new_dir(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> src/embed/linked_storage.rs:169:17
|
166 | let result = wasi_vfs_embed_linked_storage_new_file(
| -------------------------------------- arguments to this function are incorrect
...
169 | name.as_ptr(),
| ^^^^^^^^^^^^^ expected `u8`, found `i8`
|
= note: expected raw pointer `*const u8`
found raw pointer `*const i8`
note: function defined here
--> src/embed/linked_storage.rs:98:8
|
98 | fn wasi_vfs_embed_linked_storage_new_file(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> src/lib.rs:114:45
|
114 | let c_str = unsafe { CStr::from_ptr(offset as *const u8) };
| -------------- ^^^^^^^^^^^^^^^^^^^ expected `i8`, found `u8`
| |
| arguments to this function are incorrect
|
= note: expected raw pointer `*const i8`
found raw pointer `*const u8`
note: associated function defined here
--> /home/rjzak/.rustup/toolchains/stable-powerpc64le-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ffi/c_str.rs:248:19
|
248 | pub unsafe fn from_ptr<'a>(ptr: *const c_char) -> &'a CStr {
| ^^^^^^^^
For more information about this error, try `rustc --explain E0308`.
error: could not compile `wasi-vfs` due to 4 previous errors