Skip to content

Compiling Solang to WebAssembly #497

Open
@talentlessguy

Description

@talentlessguy

Hello, I'm writing a Deno library for Solidity compiler bindings and I decided to try to wrap Solang.

I am following this guide for compiling Rust to WebAssembly: https://depth-first.com/articles/2020/06/29/compiling-rust-to-webassembly-a-simple-example/

my linux kernel version is 5.10.63, distro is Manjaro Linux

I installed lld, lib32-llvm, libc++, rustc 1.53, rustup 1.24.3

and added this to Cargo.toml:

[dependencies]
getrandom = { version = "0.2", features = ["js"] }

and tried to run cargo build --target wasm32-unknown-unknown --release

and I get this:

error[E0412]: cannot find type `c_int` in crate `libc`
   --> /home/v1rtl/.cargo/registry/src/github.com-1ecc6299db9ec823/llvm-sys-120.2.1/src/lto.rs:414:89
    |
414 |     pub fn thinlto_debug_options(options: *const *const ::libc::c_char, number: ::libc::c_int);
    |                                                                                         ^^^^^ not found in `libc`
    |
help: consider importing this type alias
    |
11  | use std::os::raw::c_int;
    |

error[E0412]: cannot find type `c_char` in crate `libc`
   --> /home/v1rtl/.cargo/registry/src/github.com-1ecc6299db9ec823/llvm-sys-120.2.1/src/lto.rs:423:30
    |
423 |         name: *const ::libc::c_char,
    |                              ^^^^^^ not found in `libc`
    |
help: consider importing this type alias
    |
11  | use std::os::raw::c_char;
    |

error[E0412]: cannot find type `c_int` in crate `libc`
   --> /home/v1rtl/.cargo/registry/src/github.com-1ecc6299db9ec823/llvm-sys-120.2.1/src/lto.rs:424:25
    |
424 |         length: ::libc::c_int,
    |                         ^^^^^ not found in `libc`
    |
help: consider importing this type alias
    |
11  | use std::os::raw::c_int;
    |

error[E0412]: cannot find type `c_char` in crate `libc`
   --> /home/v1rtl/.cargo/registry/src/github.com-1ecc6299db9ec823/llvm-sys-120.2.1/src/lto.rs:433:30
    |
433 |         name: *const ::libc::c_char,
    |                              ^^^^^^ not found in `libc`
    |
help: consider importing this type alias
    |
11  | use std::os::raw::c_char;
    |

error[E0412]: cannot find type `c_int` in crate `libc`
   --> /home/v1rtl/.cargo/registry/src/github.com-1ecc6299db9ec823/llvm-sys-120.2.1/src/lto.rs:434:25
    |
434 |         length: ::libc::c_int,
    |                         ^^^^^ not found in `libc`
    |
help: consider importing this type alias
    |
11  | use std::os::raw::c_int;
    |

error[E0412]: cannot find type `c_char` in crate `libc`
   --> /home/v1rtl/.cargo/registry/src/github.com-1ecc6299db9ec823/llvm-sys-120.2.1/src/object.rs:104:81
    |
104 |     pub fn LLVMGetSectionContents(SI: LLVMSectionIteratorRef) -> *const ::libc::c_char;
    |                                                                                 ^^^^^^ not found in `libc`
    |
help: consider importing this type alias
    |
3   | use std::os::raw::c_char;
    |

error[E0412]: cannot find type `c_char` in crate `libc`
   --> /home/v1rtl/.cargo/registry/src/github.com-1ecc6299db9ec823/llvm-sys-120.2.1/src/object.rs:124:90
    |
124 |     pub fn LLVMGetRelocationValueString(RI: LLVMRelocationIteratorRef) -> *const ::libc::c_char;
    |                                                                                          ^^^^^^ not found in `libc`
    |
help: consider importing this type alias
    |
3   | use std::os::raw::c_char;
    |

error[E0412]: cannot find type `c_void` in crate `libc`
 --> /home/v1rtl/.cargo/registry/src/github.com-1ecc6299db9ec823/llvm-sys-120.2.1/src/orc2/lljit.rs:7:27
  |
7 |         Ctx: *mut ::libc::c_void,
  |                           ^^^^^^ not found in `libc`
  |
help: consider importing this enum
  |
1 | use std::os::raw::c_void;
  |

What should I install from C/C++ libraries to make it compile?

thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions