Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing functions for pyodide #471

Merged
merged 24 commits into from
Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b78a8af
Added missing functions for `pyodide`
piranna May 28, 2019
222b582
Merge remote-tracking branch 'origin/master' into command/pyodide
piranna Jun 2, 2019
a9bcb7d
Merge branch 'master' into command/pyodide
piranna Jun 6, 2019
ff21d9e
Merge branch 'master' into command/pyodide
piranna Jun 8, 2019
5d93d9a
Added `fb` and `gb` symbols
piranna Jun 8, 2019
d165763
Merge branch 'master' into command/pyodide
piranna Jun 10, 2019
0b416e1
Improved syscall220 debug
syrusakbary Jun 11, 2019
6ce4f5d
Minor fixes
syrusakbary Jun 11, 2019
109acd2
Trying to fix ___syscall220
syrusakbary Jun 11, 2019
cc74004
Merge branch 'master' into command/pyodide
piranna Jun 12, 2019
f12d6f8
Merge branch 'command/pyodide' of github.com:wasmerio/wasmer into com…
piranna Jun 12, 2019
58d7586
Fixed syscall220 alignment
syrusakbary Jun 13, 2019
8829e1d
Make Python running 🎉
syrusakbary Jun 13, 2019
1560849
Fix lint errors and windows build
syrusakbary Jun 13, 2019
675caf0
Various lint fixes
syrusakbary Jun 13, 2019
7ebb905
Fixes remaining clippy issues
syrusakbary Jun 13, 2019
583fdb5
Updated Changelog
syrusakbary Jun 13, 2019
86b78c6
Fixed clippy issues
syrusakbary Jun 13, 2019
4059562
Updated nightly version
syrusakbary Jun 13, 2019
b9fa698
Assert alignment
syrusakbary Jun 13, 2019
95f39ce
Fixed last linting issues
syrusakbary Jun 14, 2019
13a2773
Merge branch 'master' into command/pyodide
syrusakbary Jun 14, 2019
6467816
Fixed asseertion of alignment
syrusakbary Jun 14, 2019
5c64d80
Merge branch 'master' into command/pyodide
syrusakbary Jun 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ jobs:
name: Install lint deps
command: |
git config --global --unset url."ssh://[email protected]".insteadOf || true
rustup toolchain install nightly-2019-02-27
rustup toolchain install nightly-2019-05-20
rustup component add rustfmt
rustup component add clippy --toolchain=nightly-2019-02-27 || cargo +nightly-2019-02-27 install --git https://github.com/rust-lang/rust-clippy/ --force clippy
rustup component add clippy --toolchain=nightly-2019-05-20 || cargo +nightly-2019-05-20 install --git https://github.com/rust-lang/rust-clippy/ --force clippy
- run:
name: Execute lints
command: |
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Blocks of changes will separated by version increments.

## **[Unreleased]**

- [#471](https://github.com/wasmerio/wasmer/pull/471) Added missing functions to run Python. Improved Emscripten bindings
- [#474](https://github.com/wasmerio/wasmer/pull/474) Set the install name of the dylib to `@rpath`
- [#490](https://github.com/wasmerio/wasmer/pull/490) Add MiddlewareChain and StreamingCompiler to runtime
- [#487](https://github.com/wasmerio/wasmer/pull/487) Fix stack offset check in singlepass backend
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ integration-tests: release

lint:
cargo fmt --all -- --check
cargo +nightly-2019-02-27 clippy --all
cargo +nightly-2019-05-20 clippy --all

precommit: lint test

Expand Down
116 changes: 75 additions & 41 deletions lib/emscripten/src/emscripten_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ use crate::env::get_emscripten_data;
use libc::getdtablesize;
use wasmer_runtime_core::vm::Ctx;

pub fn asm_const_i(_ctx: &mut Ctx, _val: i32) -> i32 {
debug!("emscripten::asm_const_i: {}", _val);
0
}

pub fn exit_with_live_runtime(_ctx: &mut Ctx) {
debug!("emscripten::exit_with_live_runtime");
}

pub fn setTempRet0(ctx: &mut Ctx, val: i32) {
debug!("emscripten::setTempRet0: {}", val);
get_emscripten_data(ctx).temp_ret_0 = val;
Expand Down Expand Up @@ -59,10 +68,6 @@ pub fn _dladdr(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_dladdr");
0
}
pub fn _pthread_attr_init(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_attr_init({})", _a);
0
}
pub fn _pthread_attr_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_attr_destroy");
0
Expand All @@ -82,44 +87,50 @@ pub fn _pthread_attr_getstack(
// HEAP32[stacksize >> 2] = TOTAL_STACK;
0
}
pub fn _pthread_cond_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_cond_destroy");
pub fn _pthread_attr_init(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_attr_init({})", _a);
0
}
pub fn _pthread_cond_timedwait(_ctx: &mut Ctx, _a: i32, _b: i32, _c: i32) -> i32 {
debug!("emscripten::_pthread_cond_timedwait");
pub fn _pthread_attr_setstacksize(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_attr_setstacksize");
0
}
pub fn _pthread_getspecific(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_getspecific");
pub fn _pthread_cleanup_pop(_ctx: &mut Ctx, _a: i32) -> () {
debug!("emscripten::_pthread_cleanup_pop");
}
pub fn _pthread_cleanup_push(_ctx: &mut Ctx, _a: i32, _b: i32) -> () {
debug!("emscripten::_pthread_cleanup_push");
}
pub fn _pthread_cond_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_cond_destroy");
0
}
pub fn _pthread_getattr_np(_ctx: &mut Ctx, _thread: i32, _attr: i32) -> i32 {
debug!("emscripten::_pthread_getattr_np({}, {})", _thread, _attr);
pub fn _pthread_cond_init(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_cond_init");
0
}
pub fn _pthread_setspecific(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_setspecific");
pub fn _pthread_cond_signal(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_cond_signal");
0
}
pub fn _pthread_once(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_once");
pub fn _pthread_cond_timedwait(_ctx: &mut Ctx, _a: i32, _b: i32, _c: i32) -> i32 {
debug!("emscripten::_pthread_cond_timedwait");
0
}
pub fn _pthread_key_create(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_key_create");
pub fn _pthread_cond_wait(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_cond_wait");
0
}
pub fn _pthread_rwlock_destroy(_ctx: &mut Ctx, _rwlock: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_destroy({})", _rwlock);
pub fn _pthread_condattr_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_condattr_destroy");
0
}
pub fn _pthread_rwlock_init(_ctx: &mut Ctx, _rwlock: i32, _attr: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_init({}, {})", _rwlock, _attr);
pub fn _pthread_condattr_init(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_condattr_init");
0
}
pub fn _pthread_rwlock_wrlock(_ctx: &mut Ctx, _rwlock: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_wrlock({})", _rwlock);
pub fn _pthread_condattr_setclock(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_condattr_setclock");
0
}
pub fn _pthread_create(_ctx: &mut Ctx, _a: i32, _b: i32, _c: i32, _d: i32) -> i32 {
Expand All @@ -130,32 +141,27 @@ pub fn _pthread_detach(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_detach");
0
}
pub fn _pthread_join(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_join");
pub fn _pthread_equal(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_equal");
0
}
pub fn _pthread_cond_init(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_cond_init");
0
pub fn _pthread_exit(_ctx: &mut Ctx, _a: i32) -> () {
debug!("emscripten::_pthread_exit");
}
pub fn _pthread_cond_signal(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_cond_signal");
0
}
pub fn _pthread_cond_wait(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_cond_wait");
pub fn _pthread_getattr_np(_ctx: &mut Ctx, _thread: i32, _attr: i32) -> i32 {
debug!("emscripten::_pthread_getattr_np({}, {})", _thread, _attr);
0
}
pub fn _pthread_condattr_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_condattr_destroy");
pub fn _pthread_getspecific(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_getspecific");
0
}
pub fn _pthread_condattr_init(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_condattr_init");
pub fn _pthread_join(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_join");
0
}
pub fn _pthread_condattr_setclock(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_condattr_setclock");
pub fn _pthread_key_create(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_key_create");
0
}
pub fn _pthread_mutex_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
Expand All @@ -178,6 +184,18 @@ pub fn _pthread_mutexattr_settype(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_mutexattr_settype");
0
}
pub fn _pthread_once(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_once");
0
}
pub fn _pthread_rwlock_destroy(_ctx: &mut Ctx, _rwlock: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_destroy({})", _rwlock);
0
}
pub fn _pthread_rwlock_init(_ctx: &mut Ctx, _rwlock: i32, _attr: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_init({}, {})", _rwlock, _attr);
0
}
pub fn _pthread_rwlock_rdlock(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_rdlock");
0
Expand All @@ -186,10 +204,22 @@ pub fn _pthread_rwlock_unlock(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_unlock");
0
}
pub fn _pthread_rwlock_wrlock(_ctx: &mut Ctx, _rwlock: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_wrlock({})", _rwlock);
0
}
pub fn _pthread_setcancelstate(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_setcancelstate");
0
}
pub fn _pthread_setspecific(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_setspecific");
0
}
pub fn _pthread_sigmask(_ctx: &mut Ctx, _a: i32, _b: i32, _c: i32) -> i32 {
debug!("emscripten::_pthread_sigmask");
0
}
pub fn ___gxx_personality_v0(
_ctx: &mut Ctx,
_a: i32,
Expand Down Expand Up @@ -222,6 +252,10 @@ pub fn _gethostbyaddr(_ctx: &mut Ctx, _addr: i32, _addrlen: i32, _atype: i32) ->
debug!("emscripten::gethostbyaddr");
0
}
pub fn _gethostbyname(_ctx: &mut Ctx, _name: i32) -> i32 {
debug!("emscripten::gethostbyname_r");
0
}
pub fn _gethostbyname_r(
_ctx: &mut Ctx,
_name: i32,
Expand Down
20 changes: 20 additions & 0 deletions lib/emscripten/src/exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ pub fn ___cxa_allocate_exception(ctx: &mut Ctx, size: u32) -> u32 {
env::call_malloc(ctx, size as _)
}

pub fn ___cxa_current_primary_exception(_ctx: &mut Ctx) -> u32 {
debug!("emscripten::___cxa_current_primary_exception");
unimplemented!()
}

pub fn ___cxa_decrement_exception_refcount(_ctx: &mut Ctx, _a: u32) {
debug!("emscripten::___cxa_decrement_exception_refcount({})", _a);
unimplemented!()
}

pub fn ___cxa_increment_exception_refcount(_ctx: &mut Ctx, _a: u32) {
debug!("emscripten::___cxa_increment_exception_refcount({})", _a);
unimplemented!()
}

pub fn ___cxa_rethrow_primary_exception(_ctx: &mut Ctx, _a: u32) {
debug!("emscripten::___cxa_rethrow_primary_exception({})", _a);
unimplemented!()
}

/// emscripten: ___cxa_throw
/// TODO: We don't have support for exceptions yet
pub fn ___cxa_throw(ctx: &mut Ctx, _ptr: u32, _ty: u32, _destructor: u32) {
Expand Down
6 changes: 6 additions & 0 deletions lib/emscripten/src/inet.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use wasmer_runtime_core::vm::Ctx;

pub fn addr(_ctx: &mut Ctx, _cp: i32) -> i32 {
debug!("inet::addr({})", _cp);
0
}
45 changes: 41 additions & 4 deletions lib/emscripten/src/io/unix.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use libc::{chroot as _chroot, printf as _printf};
use super::super::env::call_malloc;
use super::super::utils::copy_cstr_into_wasm;
use libc::{chroot as _chroot, getpwuid as _getpwuid, printf as _printf};
use std::mem;

use wasmer_runtime_core::vm::Ctx;

Expand All @@ -24,7 +27,41 @@ pub fn chroot(ctx: &mut Ctx, name_ptr: i32) -> i32 {
}

/// getpwuid
pub fn getpwuid(_ctx: &mut Ctx, _uid: i32) -> i32 {
debug!("emscripten::getpwuid");
0
#[allow(clippy::cast_ptr_alignment)]
pub fn getpwuid(ctx: &mut Ctx, uid: i32) -> i32 {
debug!("emscripten::getpwuid {}", uid);

#[repr(C)]
struct GuestPasswd {
pw_name: u32,
pw_passwd: u32,
pw_uid: u32,
pw_gid: u32,
pw_gecos: u32,
pw_dir: u32,
pw_shell: u32,
}

unsafe {
let passwd = &*_getpwuid(uid as _);
let passwd_struct_offset = call_malloc(ctx, mem::size_of::<GuestPasswd>() as _);
let passwd_struct_ptr =
emscripten_memory_pointer!(ctx.memory(0), passwd_struct_offset) as *mut GuestPasswd;
assert_eq!(
passwd_struct_ptr as usize
% std::cmp::min(std::mem::size_of::<usize>(), std::mem::align_of::<usize>()),
0
);
(*passwd_struct_ptr).pw_name = copy_cstr_into_wasm(ctx, passwd.pw_name);
(*passwd_struct_ptr).pw_passwd = copy_cstr_into_wasm(ctx, passwd.pw_passwd);
(*passwd_struct_ptr).pw_gecos = copy_cstr_into_wasm(ctx, passwd.pw_gecos);
(*passwd_struct_ptr).pw_dir = copy_cstr_into_wasm(ctx, passwd.pw_dir);
(*passwd_struct_ptr).pw_shell = copy_cstr_into_wasm(ctx, passwd.pw_shell);
(*passwd_struct_ptr).pw_uid = passwd.pw_uid;
(*passwd_struct_ptr).pw_gid = passwd.pw_gid;

passwd_struct_offset as _
}
// unsafe { _getpwuid(uid as _) as _}
// 0
}
Loading