Compiling Solang to WebAssembly
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
I think solang should be compiled to wasi, like so:
cargo build --target wasm32-wasi --release
Then again I don't know if node and/or browsers support wasi.
If I try that, I just get an error about llvm not being found: the llvm libraries needs to built for wasm first. I've tried to do this with clang and failed, I was going to do this with emscripten next.
Also @talentlessguy thank you for looking at porting solang to webassembly, this is really needed :smile:
@seanyoung
- Yes there's
wasiin Node.js and std/wasi in Deno - It still fails but for different reasons:
➜ cargo build --target wasm32-wasi --release
Compiling lsp-types v0.89.2
Compiling contract-metadata v0.3.0
Compiling inkwell v0.1.0-beta.3
Compiling solang v0.1.8 (/home/v1rtl/Coding/forks/solang)
The following warnings were emitted during compilation:
warning: In file included from src/linker/linker.cpp:2:
warning: In file included from /usr/include/lld/Common/Driver.h:12:
warning: In file included from /usr/include/llvm/ADT/ArrayRef.h:12:
warning: In file included from /usr/include/llvm/ADT/Hashing.h:48:
warning: In file included from /usr/include/llvm/Support/ErrorHandling.h:17:
warning: /usr/include/llvm/Support/Compiler.h:21:10: fatal error: 'new' file not found
warning: #include <new>
warning: ^~~~~
warning: 1 error generated.
error: failed to run custom build command for `solang v0.1.8 (/home/v1rtl/Coding/forks/solang)`
Caused by:
process didn't exit successfully: `/home/v1rtl/Coding/forks/solang/target/release/build/solang-7656b77601092452/build-script-build` (exit status: 1)
--- stdout
cargo:rerun-if-changed=src/parser/solidity.lalrpop
TARGET = Some("wasm32-wasi")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-unknown-linux-gnu")
CXX_wasm32-wasi = None
CXX_wasm32_wasi = None
TARGET_CXX = None
CXX = None
CXXFLAGS_wasm32-wasi = None
CXXFLAGS_wasm32_wasi = None
TARGET_CXXFLAGS = None
CXXFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-wasi" "-Wall" "-Wextra" "-Wno-unused-parameter" "-I/usr/include" "-std=c++14" "-fno-exceptions" "-D_GNU_SOURCE" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-o" "/home/v1rtl/Coding/forks/solang/target/wasm32-wasi/release/build/solang-711ae689a401e349/out/src/linker/linker.o" "-c" "src/linker/linker.cpp"
cargo:warning=In file included from src/linker/linker.cpp:2:
cargo:warning=In file included from /usr/include/lld/Common/Driver.h:12:
cargo:warning=In file included from /usr/include/llvm/ADT/ArrayRef.h:12:
cargo:warning=In file included from /usr/include/llvm/ADT/Hashing.h:48:
cargo:warning=In file included from /usr/include/llvm/Support/ErrorHandling.h:17:
cargo:warning=/usr/include/llvm/Support/Compiler.h:21:10: fatal error: 'new' file not found
cargo:warning=#include <new>
cargo:warning= ^~~~~
cargo:warning=1 error generated.
exit status: 1
--- stderr
error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-wasi" "-Wall" "-Wextra" "-Wno-unused-parameter" "-I/usr/include" "-std=c++14" "-fno-exceptions" "-D_GNU_SOURCE" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-o" "/home/v1rtl/Coding/forks/solang/target/wasm32-wasi/release/build/solang-711ae689a401e349/out/src/linker/linker.o" "-c" "src/linker/linker.cpp" with args "clang" did not execute successfully (status code exit status: 1).
warning: build failed, waiting for other jobs to finish...
error[E0308]: mismatched types
--> /home/v1rtl/.cargo/registry/src/github.com-1ecc6299db9ec823/inkwell-0.1.0-beta.3/src/module.rs:601:95
|
601 | pub fn write_bitcode_to_file(&self, file: &File, should_close: bool, unbuffered: bool) -> bool {
| --------------------- ^^^^ expected `bool`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
error: build failed
for more context:
I have:
- gcc 11.1.0
- llvm 12.0.1-4
So there are two issues:
- clang needs the wasi sdk. Copy this into your clang directory and add
--sysroot=wasi-sysroot..usingTARGET_CFLAGSandTARGET_CXXFLAGS - inkwell needs a little patch, working on that
With that done a whole new world of pain is opened: linking. This requires a wasm build of llvm which can be done with emscripten, I think. I don't have it working yet.
@seanyoung It still errors:
$ env TARGET_CFLAGS=--sysroot=wasi-sysroot.. TARGET_CXXFLAGS=--sysroot=wasi-sysroot cargo build --target wasm32-wasi --release
Compiling inkwell v0.1.0 (https://github.com/TheDan64/inkwell?branch=master#d018ee22)
Compiling solang v0.1.8 (/home/v1rtl/Coding/forks/solang)
The following warnings were emitted during compilation:
warning: In file included from src/linker/linker.cpp:2:
warning: In file included from /usr/include/lld/Common/Driver.h:12:
warning: In file included from /usr/include/llvm/ADT/ArrayRef.h:12:
warning: In file included from /usr/include/llvm/ADT/Hashing.h:48:
warning: In file included from /usr/include/llvm/Support/ErrorHandling.h:17:
warning: /usr/include/llvm/Support/Compiler.h:21:10: fatal error: 'new' file not found
warning: #include <new>
warning: ^~~~~
warning: 1 error generated.
error: failed to run custom build command for `solang v0.1.8 (/home/v1rtl/Coding/forks/solang)`
Caused by:
process didn't exit successfully: `/home/v1rtl/Coding/forks/solang/target/release/build/solang-7656b77601092452/build-script-build` (exit status: 1)
--- stdout
cargo:rerun-if-changed=src/parser/solidity.lalrpop
TARGET = Some("wasm32-wasi")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-unknown-linux-gnu")
CXX_wasm32-wasi = None
CXX_wasm32_wasi = None
TARGET_CXX = None
CXX = None
CXXFLAGS_wasm32-wasi = None
CXXFLAGS_wasm32_wasi = None
TARGET_CXXFLAGS = Some("--sysroot=wasi-sysroot")
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-wasi" "--sysroot=wasi-sysroot" "-Wno-unused-parameter" "-I/usr/include" "-std=c++14" "-fno-exceptions" "-D_GNU_SOURCE" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-o" "/home/v1rtl/Coding/forks/solang/target/wasm32-wasi/release/build/solang-711ae689a401e349/out/src/linker/linker.o" "-c" "src/linker/linker.cpp"
cargo:warning=In file included from src/linker/linker.cpp:2:
cargo:warning=In file included from /usr/include/lld/Common/Driver.h:12:
cargo:warning=In file included from /usr/include/llvm/ADT/ArrayRef.h:12:
cargo:warning=In file included from /usr/include/llvm/ADT/Hashing.h:48:
cargo:warning=In file included from /usr/include/llvm/Support/ErrorHandling.h:17:
cargo:warning=/usr/include/llvm/Support/Compiler.h:21:10: fatal error: 'new' file not found
cargo:warning=#include <new>
cargo:warning= ^~~~~
cargo:warning=1 error generated.
exit status: 1
--- stderr
error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-wasi" "--sysroot=wasi-sysroot" "-Wno-unused-parameter" "-I/usr/include" "-std=c++14" "-fno-exceptions" "-D_GNU_SOURCE" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-o" "/home/v1rtl/Coding/forks/solang/target/wasm32-wasi/release/build/solang-711ae689a401e349/out/src/linker/linker.o" "-c" "src/linker/linker.cpp" with args "clang" did not execute successfully (status code exit status: 1).
warning: build failed, waiting for other jobs to finish...
error[E0308]: mismatched types
--> /home/v1rtl/.cargo/git/checkouts/inkwell-946411d814d2c9f8/d018ee2/src/module.rs:601:95
|
601 | pub fn write_bitcode_to_file(&self, file: &File, should_close: bool, unbuffered: bool) -> bool {
| --------------------- ^^^^ expected `bool`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
error: build failed
I have clang and wasi-sdk both installed to /usr/bin
You need to set the correct sysroot for the wasi sdk (share/sysroot in wasi-sdk).
inkwell needs this fix: https://github.com/TheDan64/inkwell/pull/270
@seanyoung oops sorry I found out the location of sysroot it was in /opt/wasi-sdk
but now I get this:
➜ echo $WASI_SDK_PATH
/opt/wasi-sdk/wasi-sysroot
➜ env TARGET_CFLAGS=--sysroot=$WASI_SDK_PATH TARGET_CXXFLAGS=--sysroot=$WASI_SDK_PATH cargo build --target wasm32-wasi --release
Compiling inkwell v0.1.0 (https://github.com/TheDan64/inkwell?branch=master#d018ee22)
Compiling solang v0.1.8 (/home/v1rtl/Coding/forks/solang)
The following warnings were emitted during compilation:
warning: In file included from src/linker/linker.cpp:2:
warning: In file included from /usr/include/lld/Common/Driver.h:12:
warning: In file included from /usr/include/llvm/ADT/ArrayRef.h:12:
warning: In file included from /usr/include/llvm/ADT/Hashing.h:48:
warning: In file included from /usr/include/llvm/Support/ErrorHandling.h:17:
warning: In file included from /usr/include/llvm/Support/Compiler.h:21:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/new:89:
warning: /opt/wasi-sdk/wasi-sysroot/include/c++/v1/__config:1209:2: error: _LIBCPP_HAS_NO_THREADS cannot be set when __STDCPP_THREADS__ is set.
warning: #error _LIBCPP_HAS_NO_THREADS cannot be set when __STDCPP_THREADS__ is set.
warning: ^
warning: In file included from src/linker/linker.cpp:2:
warning: In file included from /usr/include/lld/Common/Driver.h:12:
warning: In file included from /usr/include/llvm/ADT/ArrayRef.h:12:
warning: In file included from /usr/include/llvm/ADT/Hashing.h:48:
warning: In file included from /usr/include/llvm/Support/ErrorHandling.h:18:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/string:506:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/string_view:175:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/__string:57:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/algorithm:643:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/memory:668:
warning: /opt/wasi-sdk/wasi-sysroot/include/c++/v1/typeinfo:225:16: error: reinterpret_cast from 'std::__type_info_implementations::__non_unique_arm_rtti_bit_impl::__type_name_t' (aka 'unsigned int') to 'size_t' (aka 'unsigned long') is not allowed
warning: return reinterpret_cast<size_t>(__v);
warning: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: In file included from src/linker/linker.cpp:2:
warning: In file included from /usr/include/lld/Common/Driver.h:12:
warning: In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
warning: In file included from /usr/include/llvm/ADT/SmallVector.h:19:
warning: In file included from /usr/include/llvm/Support/MathExtras.h:19:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/climits:41:
warning: In file included from /usr/include/limits.h:124:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/limits.h:57:
warning: In file included from /usr/lib/clang/12.0.1/include/limits.h:21:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/limits.h:6:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/bits/alltypes.h:269:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/__struct_timeval.h:4:
warning: /opt/wasi-sdk/wasi-sysroot/include/__typedef_time_t.h:5:19: error: typedef redefinition with different types ('long long' vs '__time_t' (aka 'long'))
warning: typedef long long time_t;
warning: ^
warning: /usr/include/bits/types/time_t.h:7:18: note: previous definition is here
warning: typedef __time_t time_t;
warning: ^
warning: In file included from src/linker/linker.cpp:2:
warning: In file included from /usr/include/lld/Common/Driver.h:12:
warning: In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
warning: In file included from /usr/include/llvm/ADT/SmallVector.h:19:
warning: In file included from /usr/include/llvm/Support/MathExtras.h:19:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/climits:41:
warning: In file included from /usr/include/limits.h:124:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/limits.h:57:
warning: In file included from /usr/lib/clang/12.0.1/include/limits.h:21:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/limits.h:6:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/bits/alltypes.h:269:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/__struct_timeval.h:5:
warning: /opt/wasi-sdk/wasi-sysroot/include/__typedef_suseconds_t.h:6:19: error: typedef redefinition with different types ('long long' vs '__suseconds_t' (aka 'long'))
warning: typedef long long suseconds_t;
warning: ^
warning: /usr/include/sys/types.h:138:23: note: previous definition is here
warning: typedef __suseconds_t suseconds_t;
warning: ^
warning: In file included from src/linker/linker.cpp:2:
warning: In file included from /usr/include/lld/Common/Driver.h:12:
warning: In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
warning: In file included from /usr/include/llvm/ADT/SmallVector.h:19:
warning: In file included from /usr/include/llvm/Support/MathExtras.h:19:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/climits:41:
warning: In file included from /usr/include/limits.h:124:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/limits.h:57:
warning: In file included from /usr/lib/clang/12.0.1/include/limits.h:21:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/limits.h:6:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/bits/alltypes.h:269:
warning: /opt/wasi-sdk/wasi-sysroot/include/__struct_timeval.h:8:8: error: redefinition of 'timeval'
warning: struct timeval {
warning: ^
warning: /usr/include/bits/types/struct_timeval.h:8:8: note: previous definition is here
warning: struct timeval
warning: ^
warning: In file included from src/linker/linker.cpp:2:
warning: In file included from /usr/include/lld/Common/Driver.h:12:
warning: In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
warning: In file included from /usr/include/llvm/ADT/SmallVector.h:19:
warning: In file included from /usr/include/llvm/Support/MathExtras.h:19:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/climits:41:
warning: In file included from /usr/include/limits.h:124:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/limits.h:57:
warning: In file included from /usr/lib/clang/12.0.1/include/limits.h:21:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/limits.h:6:
warning: In file included from /opt/wasi-sdk/wasi-sysroot/include/bits/alltypes.h:270:
warning: /opt/wasi-sdk/wasi-sysroot/include/__struct_timespec.h:7:8: error: redefinition of 'timespec'
warning: struct timespec {
warning: ^
warning: /usr/include/bits/types/struct_timespec.h:10:8: note: previous definition is here
warning: struct timespec
warning: ^
warning: In file included from src/linker/linker.cpp:2:
warning: In file included from /usr/include/lld/Common/Driver.h:12:
warning: In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
warning: In file included from /usr/include/llvm/ADT/SmallVector.h:19:
warning: In file included from /usr/include/llvm/Support/MathExtras.h:20:
warning: /opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:321:9: error: no member named 'signbit' in the global namespace; did you mean '__signbit'?
warning: using ::signbit;
warning: ~~^
warning: /usr/include/bits/mathcalls-helper-functions.h:24:24: note: '__signbit' declared here
warning: __MATHDECL_ALIAS (int, __signbit,, (_Mdouble_ __value), signbit)
warning: ^
warning: In file included from src/linker/linker.cpp:2:
warning: In file included from /usr/include/lld/Common/Driver.h:12:
warning: In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
warning: In file included from /usr/include/llvm/ADT/SmallVector.h:19:
warning: In file included from /usr/include/llvm/Support/MathExtras.h:20:
warning: /opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:322:9: error: no member named 'fpclassify' in the global namespace; did you mean '__fpclassify'?
warning: using ::fpclassify;
warning: ~~^
warning: /usr/include/bits/mathcalls-helper-functions.h:20:24: note: '__fpclassify' declared here
warning: __MATHDECL_ALIAS (int, __fpclassify,, (_Mdouble_ __value), fpclassify)
warning: ^
warning: In file included from src/linker/linker.cpp:2:
warning: In file included from /usr/include/lld/Common/Driver.h:12:
warning: In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
warning: In file included from /usr/include/llvm/ADT/SmallVector.h:19:
warning: In file included from /usr/include/llvm/Support/MathExtras.h:20:
warning: /opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:323:9: error: no member named 'isfinite' in the global namespace
warning: using ::isfinite;
warning: ~~^
warning: /opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:324:9: error: no member named 'isinf' in the global namespace
warning: using ::isinf;
warning: ~~^
warning: /opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:325:9: error: no member named 'isnan' in the global namespace
warning: using ::isnan;
warning: ~~^
warning: /opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:326:9: error: no member named 'isnormal' in the global namespace
warning: using ::isnormal;
warning: ~~^
warning: /opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:327:7: error: no member named 'isgreater' in the global namespace; did you mean '::std::greater'?
warning: using ::isgreater;
warning: ^~
warning: /opt/wasi-sdk/wasi-sysroot/include/c++/v1/functional:742:29: note: '::std::greater' declared here
warning: struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
warning: ^
warning: In file included from src/linker/linker.cpp:2:
warning: In file included from /usr/include/lld/Common/Driver.h:12:
warning: In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
warning: In file included from /usr/include/llvm/ADT/SmallVector.h:19:
warning: In file included from /usr/include/llvm/Support/MathExtras.h:20:
warning: /opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:328:7: error: no member named 'isgreaterequal' in the global namespace; did you mean '::std::greater_equal'?
warning: using ::isgreaterequal;
warning: ^~
warning: /opt/wasi-sdk/wasi-sysroot/include/c++/v1/functional:771:29: note: '::std::greater_equal' declared here
warning: struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
warning: ^
warning: In file included from src/linker/linker.cpp:2:
warning: In file included from /usr/include/lld/Common/Driver.h:12:
warning: In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
warning: In file included from /usr/include/llvm/ADT/SmallVector.h:19:
warning: In file included from /usr/include/llvm/Support/MathExtras.h:20:
warning: /opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:329:9: error: no member named 'isless' in the global namespace
warning: using ::isless;
warning: ~~^
warning: /opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:330:9: error: no member named 'islessequal' in the global namespace
warning: using ::islessequal;
warning: ~~^
warning: /opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:331:9: error: no member named 'islessgreater' in the global namespace
warning: using ::islessgreater;
warning: ~~^
warning: /opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:332:9: error: no member named 'isunordered' in the global namespace
warning: using ::isunordered;
warning: ~~^
warning: /opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:333:9: error: no member named 'isunordered' in the global namespace
warning: using ::isunordered;
warning: ~~^
warning: 19 errors generated.
error: failed to run custom build command for `solang v0.1.8 (/home/v1rtl/Coding/forks/solang)`
Caused by:
process didn't exit successfully: `/home/v1rtl/Coding/forks/solang/target/release/build/solang-7656b77601092452/build-script-build` (exit status: 1)
--- stdout
cargo:rerun-if-changed=src/parser/solidity.lalrpop
TARGET = Some("wasm32-wasi")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-unknown-linux-gnu")
CXX_wasm32-wasi = None
CXX_wasm32_wasi = None
TARGET_CXX = None
CXX = None
CXXFLAGS_wasm32-wasi = None
CXXFLAGS_wasm32_wasi = None
TARGET_CXXFLAGS = Some("--sysroot=/opt/wasi-sdk/wasi-sysroot")
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-wasi" "--sysroot=/opt/wasi-sdk/wasi-sysroot" "-Wno-unused-parameter" "-I/usr/include" "-std=c++14" "-fno-exceptions" "-D_GNU_SOURCE" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-o" "/home/v1rtl/Coding/forks/solang/target/wasm32-wasi/release/build/solang-711ae689a401e349/out/src/linker/linker.o" "-c" "src/linker/linker.cpp"
cargo:warning=In file included from src/linker/linker.cpp:2:
cargo:warning=In file included from /usr/include/lld/Common/Driver.h:12:
cargo:warning=In file included from /usr/include/llvm/ADT/ArrayRef.h:12:
cargo:warning=In file included from /usr/include/llvm/ADT/Hashing.h:48:
cargo:warning=In file included from /usr/include/llvm/Support/ErrorHandling.h:17:
cargo:warning=In file included from /usr/include/llvm/Support/Compiler.h:21:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/new:89:
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/c++/v1/__config:1209:2: error: _LIBCPP_HAS_NO_THREADS cannot be set when __STDCPP_THREADS__ is set.
cargo:warning=#error _LIBCPP_HAS_NO_THREADS cannot be set when __STDCPP_THREADS__ is set.
cargo:warning= ^
cargo:warning=In file included from src/linker/linker.cpp:2:
cargo:warning=In file included from /usr/include/lld/Common/Driver.h:12:
cargo:warning=In file included from /usr/include/llvm/ADT/ArrayRef.h:12:
cargo:warning=In file included from /usr/include/llvm/ADT/Hashing.h:48:
cargo:warning=In file included from /usr/include/llvm/Support/ErrorHandling.h:18:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/string:506:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/string_view:175:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/__string:57:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/algorithm:643:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/memory:668:
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/c++/v1/typeinfo:225:16: error: reinterpret_cast from 'std::__type_info_implementations::__non_unique_arm_rtti_bit_impl::__type_name_t' (aka 'unsigned int') to 'size_t' (aka 'unsigned long') is not allowed
cargo:warning= return reinterpret_cast<size_t>(__v);
cargo:warning= ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cargo:warning=In file included from src/linker/linker.cpp:2:
cargo:warning=In file included from /usr/include/lld/Common/Driver.h:12:
cargo:warning=In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
cargo:warning=In file included from /usr/include/llvm/ADT/SmallVector.h:19:
cargo:warning=In file included from /usr/include/llvm/Support/MathExtras.h:19:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/climits:41:
cargo:warning=In file included from /usr/include/limits.h:124:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/limits.h:57:
cargo:warning=In file included from /usr/lib/clang/12.0.1/include/limits.h:21:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/limits.h:6:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/bits/alltypes.h:269:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/__struct_timeval.h:4:
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/__typedef_time_t.h:5:19: error: typedef redefinition with different types ('long long' vs '__time_t' (aka 'long'))
cargo:warning=typedef long long time_t;
cargo:warning= ^
cargo:warning=/usr/include/bits/types/time_t.h:7:18: note: previous definition is here
cargo:warning=typedef __time_t time_t;
cargo:warning= ^
cargo:warning=In file included from src/linker/linker.cpp:2:
cargo:warning=In file included from /usr/include/lld/Common/Driver.h:12:
cargo:warning=In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
cargo:warning=In file included from /usr/include/llvm/ADT/SmallVector.h:19:
cargo:warning=In file included from /usr/include/llvm/Support/MathExtras.h:19:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/climits:41:
cargo:warning=In file included from /usr/include/limits.h:124:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/limits.h:57:
cargo:warning=In file included from /usr/lib/clang/12.0.1/include/limits.h:21:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/limits.h:6:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/bits/alltypes.h:269:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/__struct_timeval.h:5:
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/__typedef_suseconds_t.h:6:19: error: typedef redefinition with different types ('long long' vs '__suseconds_t' (aka 'long'))
cargo:warning=typedef long long suseconds_t;
cargo:warning= ^
cargo:warning=/usr/include/sys/types.h:138:23: note: previous definition is here
cargo:warning=typedef __suseconds_t suseconds_t;
cargo:warning= ^
cargo:warning=In file included from src/linker/linker.cpp:2:
cargo:warning=In file included from /usr/include/lld/Common/Driver.h:12:
cargo:warning=In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
cargo:warning=In file included from /usr/include/llvm/ADT/SmallVector.h:19:
cargo:warning=In file included from /usr/include/llvm/Support/MathExtras.h:19:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/climits:41:
cargo:warning=In file included from /usr/include/limits.h:124:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/limits.h:57:
cargo:warning=In file included from /usr/lib/clang/12.0.1/include/limits.h:21:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/limits.h:6:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/bits/alltypes.h:269:
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/__struct_timeval.h:8:8: error: redefinition of 'timeval'
cargo:warning=struct timeval {
cargo:warning= ^
cargo:warning=/usr/include/bits/types/struct_timeval.h:8:8: note: previous definition is here
cargo:warning=struct timeval
cargo:warning= ^
cargo:warning=In file included from src/linker/linker.cpp:2:
cargo:warning=In file included from /usr/include/lld/Common/Driver.h:12:
cargo:warning=In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
cargo:warning=In file included from /usr/include/llvm/ADT/SmallVector.h:19:
cargo:warning=In file included from /usr/include/llvm/Support/MathExtras.h:19:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/climits:41:
cargo:warning=In file included from /usr/include/limits.h:124:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/c++/v1/limits.h:57:
cargo:warning=In file included from /usr/lib/clang/12.0.1/include/limits.h:21:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/limits.h:6:
cargo:warning=In file included from /opt/wasi-sdk/wasi-sysroot/include/bits/alltypes.h:270:
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/__struct_timespec.h:7:8: error: redefinition of 'timespec'
cargo:warning=struct timespec {
cargo:warning= ^
cargo:warning=/usr/include/bits/types/struct_timespec.h:10:8: note: previous definition is here
cargo:warning=struct timespec
cargo:warning= ^
cargo:warning=In file included from src/linker/linker.cpp:2:
cargo:warning=In file included from /usr/include/lld/Common/Driver.h:12:
cargo:warning=In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
cargo:warning=In file included from /usr/include/llvm/ADT/SmallVector.h:19:
cargo:warning=In file included from /usr/include/llvm/Support/MathExtras.h:20:
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:321:9: error: no member named 'signbit' in the global namespace; did you mean '__signbit'?
cargo:warning=using ::signbit;
cargo:warning= ~~^
cargo:warning=/usr/include/bits/mathcalls-helper-functions.h:24:24: note: '__signbit' declared here
cargo:warning=__MATHDECL_ALIAS (int, __signbit,, (_Mdouble_ __value), signbit)
cargo:warning= ^
cargo:warning=In file included from src/linker/linker.cpp:2:
cargo:warning=In file included from /usr/include/lld/Common/Driver.h:12:
cargo:warning=In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
cargo:warning=In file included from /usr/include/llvm/ADT/SmallVector.h:19:
cargo:warning=In file included from /usr/include/llvm/Support/MathExtras.h:20:
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:322:9: error: no member named 'fpclassify' in the global namespace; did you mean '__fpclassify'?
cargo:warning=using ::fpclassify;
cargo:warning= ~~^
cargo:warning=/usr/include/bits/mathcalls-helper-functions.h:20:24: note: '__fpclassify' declared here
cargo:warning=__MATHDECL_ALIAS (int, __fpclassify,, (_Mdouble_ __value), fpclassify)
cargo:warning= ^
cargo:warning=In file included from src/linker/linker.cpp:2:
cargo:warning=In file included from /usr/include/lld/Common/Driver.h:12:
cargo:warning=In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
cargo:warning=In file included from /usr/include/llvm/ADT/SmallVector.h:19:
cargo:warning=In file included from /usr/include/llvm/Support/MathExtras.h:20:
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:323:9: error: no member named 'isfinite' in the global namespace
cargo:warning=using ::isfinite;
cargo:warning= ~~^
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:324:9: error: no member named 'isinf' in the global namespace
cargo:warning=using ::isinf;
cargo:warning= ~~^
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:325:9: error: no member named 'isnan' in the global namespace
cargo:warning=using ::isnan;
cargo:warning= ~~^
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:326:9: error: no member named 'isnormal' in the global namespace
cargo:warning=using ::isnormal;
cargo:warning= ~~^
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:327:7: error: no member named 'isgreater' in the global namespace; did you mean '::std::greater'?
cargo:warning=using ::isgreater;
cargo:warning= ^~
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/c++/v1/functional:742:29: note: '::std::greater' declared here
cargo:warning=struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
cargo:warning= ^
cargo:warning=In file included from src/linker/linker.cpp:2:
cargo:warning=In file included from /usr/include/lld/Common/Driver.h:12:
cargo:warning=In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
cargo:warning=In file included from /usr/include/llvm/ADT/SmallVector.h:19:
cargo:warning=In file included from /usr/include/llvm/Support/MathExtras.h:20:
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:328:7: error: no member named 'isgreaterequal' in the global namespace; did you mean '::std::greater_equal'?
cargo:warning=using ::isgreaterequal;
cargo:warning= ^~
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/c++/v1/functional:771:29: note: '::std::greater_equal' declared here
cargo:warning=struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
cargo:warning= ^
cargo:warning=In file included from src/linker/linker.cpp:2:
cargo:warning=In file included from /usr/include/lld/Common/Driver.h:12:
cargo:warning=In file included from /usr/include/llvm/ADT/ArrayRef.h:14:
cargo:warning=In file included from /usr/include/llvm/ADT/SmallVector.h:19:
cargo:warning=In file included from /usr/include/llvm/Support/MathExtras.h:20:
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:329:9: error: no member named 'isless' in the global namespace
cargo:warning=using ::isless;
cargo:warning= ~~^
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:330:9: error: no member named 'islessequal' in the global namespace
cargo:warning=using ::islessequal;
cargo:warning= ~~^
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:331:9: error: no member named 'islessgreater' in the global namespace
cargo:warning=using ::islessgreater;
cargo:warning= ~~^
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:332:9: error: no member named 'isunordered' in the global namespace
cargo:warning=using ::isunordered;
cargo:warning= ~~^
cargo:warning=/opt/wasi-sdk/wasi-sysroot/include/c++/v1/cmath:333:9: error: no member named 'isunordered' in the global namespace
cargo:warning=using ::isunordered;
cargo:warning= ~~^
cargo:warning=19 errors generated.
exit status: 1
--- stderr
error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-wasi" "--sysroot=/opt/wasi-sdk/wasi-sysroot" "-Wno-unused-parameter" "-I/usr/include" "-std=c++14" "-fno-exceptions" "-D_GNU_SOURCE" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-o" "/home/v1rtl/Coding/forks/solang/target/wasm32-wasi/release/build/solang-711ae689a401e349/out/src/linker/linker.o" "-c" "src/linker/linker.cpp" with args "clang" did not execute successfully (status code exit status: 1).
warning: build failed, waiting for other jobs to finish...
error[E0308]: mismatched types
--> /home/v1rtl/.cargo/git/checkouts/inkwell-946411d814d2c9f8/d018ee2/src/module.rs:601:95
|
601 | pub fn write_bitcode_to_file(&self, file: &File, should_close: bool, unbuffered: bool) -> bool {
| --------------------- ^^^^ expected `bool`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
error: build failed
this is wasi-sdk v12.0-1
Ok, now the issue is that you are using your systems llvm, so compiled for x86, not an llvm cross-compiled to wasm. That can be done with emscripten (I hope).
@seanyoung do you know how to do that?
I have both emscripten, llvm and wasi-sdk installed. I also have wasm-ld
I haven't gotten it working yet. Any help would be appreciated.
I think we need this resolved. https://github.com/rustwasm/wasm-pack/issues/654
Then again, others have compiled clang to run in a browser - which means wasi is not necessary.