Merge branch 'master' into feat_sharedmemory

This commit is contained in:
ptitSeb
2022-11-25 13:07:37 +01:00
committed by GitHub
9 changed files with 1086 additions and 1055 deletions

View File

@@ -8,6 +8,15 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C
## **Unreleased**
## Added
- [#3365](https://github.com/wasmerio/wasmer/pull/3365) Preliminary FreeBSD support
## Fixed
- [#3369](https://github.com/wasmerio/wasmer/pull/3369) Fix installing wasmer via cargo-binstall
## 3.0.1 - 23/11/2022
## Added

View File

@@ -40,6 +40,7 @@ SHELL=/usr/bin/env bash
IS_DARWIN := 0
IS_LINUX := 0
IS_FREEBSD := 0
IS_WINDOWS := 0
IS_AMD64 := 0
IS_AARCH64 := 0
@@ -57,6 +58,8 @@ else
IS_DARWIN := 1
else ifeq ($(uname), Linux)
IS_LINUX := 1
else ifeq ($(uname), FreeBSD)
IS_FREEBSD := 1
else
# We use spaces instead of tabs to indent `$(error)`
# otherwise it's considered as a command outside a
@@ -67,7 +70,7 @@ else
# Architecture
uname := $(shell uname -m)
ifeq ($(uname), x86_64)
ifneq (, $(filter $(uname), x86_64 amd64))
IS_AMD64 := 1
else ifneq (, $(filter $(uname), aarch64 arm64))
IS_AARCH64 := 1
@@ -166,7 +169,7 @@ ifneq ($(ENABLE_SINGLEPASS), 0)
ifeq ($(ENABLE_SINGLEPASS), 1)
compilers += singlepass
# … otherwise, we try to check whether Singlepass works on this host.
else ifneq (, $(filter 1, $(IS_DARWIN) $(IS_LINUX) $(IS_WINDOWS)))
else ifneq (, $(filter 1, $(IS_DARWIN) $(IS_LINUX) $(IS_FREEBSD) $(IS_WINDOWS)))
ifeq ($(IS_AMD64), 1)
compilers += singlepass
endif
@@ -213,7 +216,7 @@ endif
##
ifeq ($(ENABLE_LLVM), 1)
ifneq (, $(filter 1, $(IS_WINDOWS) $(IS_DARWIN) $(IS_LINUX)))
ifneq (, $(filter 1, $(IS_WINDOWS) $(IS_DARWIN) $(IS_LINUX) $(IS_FREEBSD)))
ifeq ($(IS_AMD64), 1)
compilers_engines += llvm-universal
else ifeq ($(IS_AARCH64), 1)
@@ -227,7 +230,7 @@ endif
##
ifeq ($(ENABLE_SINGLEPASS), 1)
ifneq (, $(filter 1, $(IS_WINDOWS) $(IS_DARWIN) $(IS_LINUX)))
ifneq (, $(filter 1, $(IS_WINDOWS) $(IS_DARWIN) $(IS_LINUX) $(IS_FREEBSD)))
ifeq ($(IS_AMD64), 1)
compilers_engines += singlepass-universal
endif
@@ -272,7 +275,7 @@ capi_compilers_engines := $(filter-out $(capi_compilers_engines_exclude),$(compi
#
#####
ifneq (, $(filter 1, $(IS_DARWIN) $(IS_LINUX)))
ifneq (, $(filter 1, $(IS_DARWIN) $(IS_LINUX) $(IS_FREEBSD)))
bold := $(shell tput bold 2>/dev/null || echo -n '')
green := $(shell tput setaf 2 2>/dev/null || echo -n '')
yellow := $(shell tput setaf 3 2>/dev/null || echo -n '')
@@ -333,6 +336,8 @@ SEDI ?=
ifeq ($(IS_DARWIN), 1)
SEDI := "-i ''"
else ifeq ($(IS_FREEBSD), 1)
SEDI := "-i ''"
else ifeq ($(IS_LINUX), 1)
SEDI := "-i"
endif
@@ -559,7 +564,7 @@ generate-wasi-tests:
package-wapm:
mkdir -p "package/bin"
ifneq (, $(filter 1, $(IS_DARWIN) $(IS_LINUX)))
ifneq (, $(filter 1, $(IS_DARWIN) $(IS_LINUX) $(IS_FREEBSD)))
if [ -d "wapm-cli" ]; then \
cp wapm-cli/$(TARGET_DIR)/wapm package/bin/ ;\
echo -e "#!/bin/bash\nwapm execute \"\$$@\"" > package/bin/wax ;\

View File

@@ -80,7 +80,7 @@ curl https://get.wasmer.io -sSfL | sh
* <a href="https://crates.io/crates/cargo-binstall/">Cargo binstall</a>
```sh
cargo binstall wasmer
cargo binstall wasmer-cli
```
* <a href="https://crates.io/crates/wasmer-cli/">Cargo</a>

View File

@@ -166,31 +166,26 @@ http = [
"serde",
]
[package.metadata.binstall]
pkg-fmt = "tgz"
[package.metadata.binstall.overrides.aarch64-apple-darwin]
pkg-url = "{ repo }/releases/download/{ version }/wasmer-darwin-arm64.{ archive-format }"
bin-dir = "wasmer-darwin-arm64/bin/{ bin }"
#https://github.com/wasmerio/wasmer/releases/download/3.0.0-beta/wasmer-darwin-arm64.tar.gz
pkg-url = "{ repo }/releases/download/v{ version }/wasmer-darwin-arm64.{ archive-format }"
bin-dir = "bin/{ bin }"
[package.metadata.binstall.overrides.x86_64-apple-darwin]
pkg-url = "{ repo }/releases/download/{ version }/wasmer-darwin-amd64.{ archive-format }"
bin-dir = "wasmer-darwin-amd64/bin/{ bin }"
pkg-url = "{ repo }/releases/download/v{ version }/wasmer-darwin-amd64.{ archive-format }"
bin-dir = "bin/{ bin }"
[package.metadata.binstall.overrides.aarch64-unknown-linux-gnu]
pkg-url = "{ repo }/releases/download/{ version }/wasmer-linux-aarch64.{ archive-format }"
bin-dir = "wasmer-linux-aarch64/bin/{ bin }"
pkg-url = "{ repo }/releases/download/v{ version }/wasmer-linux-aarch64.{ archive-format }"
bin-dir = "bin/{ bin }"
[package.metadata.binstall.overrides.x86_64-unknown-linux-gnu]
pkg-url = "{ repo }/releases/download/{ version }/wasmer-linux-amd64.{ archive-format }"
bin-dir = "wasmer-linux-amd64/bin/{ bin }"
pkg-url = "{ repo }/releases/download/v{ version }/wasmer-linux-amd64.{ archive-format }"
bin-dir = "bin/{ bin }"
[package.metadata.binstall.overrides.x86_64-unknown-linux-musl]
pkg-url = "{ repo }/releases/download/{ version }/wasmer-linux-musl-amd64.{ archive-format }"
bin-dir = "wasmer-linux-musl-amd64/bin/{ bin }"
pkg-url = "{ repo }/releases/download/v{ version }/wasmer-linux-musl-amd64.{ archive-format }"
bin-dir = "bin/{ bin }"
[package.metadata.binstall.overrides.x86_64-pc-windows-msvc]
pkg-url = "{ repo }/releases/download/{ version }/wasmer-windows-amd64.{ archive-format }"
bin-dir = "wasmer-windows-amd64/bin/{ bin }.exe"
pkg-url = "{ repo }/releases/download/v{ version }/wasmer-windows-amd64.{ archive-format }"
bin-dir = "bin/{ bin }.exe"

View File

@@ -51,8 +51,14 @@ impl Login {
/// execute [List]
pub fn execute(&self) -> Result<(), anyhow::Error> {
let token = self.get_token_or_ask_user()?;
wasmer_registry::login::login_and_save_token(&self.registry, &token)
.map_err(|e| anyhow::anyhow!("{e}"))
match wasmer_registry::login::login_and_save_token(&self.registry, &token)? {
Some(s) => println!("Login for WAPM user {:?} saved", s),
None => println!(
"Error: no user found on registry {:?} with token {:?}. Token saved regardless.",
self.registry, token
),
}
Ok(())
}
}

View File

@@ -8,12 +8,14 @@ pub fn login_and_save_token(
#[cfg(test)] test_name: &str,
registry: &str,
token: &str,
) -> Result<(), anyhow::Error> {
) -> Result<Option<String>, anyhow::Error> {
let registry = format_graphql(registry);
#[cfg(test)]
let mut config = PartialWapmConfig::from_file(test_name).map_err(|e| anyhow::anyhow!("{e}"))?;
let mut config = PartialWapmConfig::from_file(test_name)
.map_err(|e| anyhow::anyhow!("config from file: {e}"))?;
#[cfg(not(test))]
let mut config = PartialWapmConfig::from_file().map_err(|e| anyhow::anyhow!("{e}"))?;
let mut config =
PartialWapmConfig::from_file().map_err(|e| anyhow::anyhow!("config from file: {e}"))?;
config.registry.set_current_registry(&registry);
config.registry.set_login_token_for_registry(
&config.registry.get_current_registry(),
@@ -21,16 +23,11 @@ pub fn login_and_save_token(
UpdateRegistry::Update,
);
#[cfg(test)]
let path =
PartialWapmConfig::get_file_location(test_name).map_err(|e| anyhow::anyhow!("{e}"))?;
let path = PartialWapmConfig::get_file_location(test_name)
.map_err(|e| anyhow::anyhow!("get file location: {e}"))?;
#[cfg(not(test))]
let path = PartialWapmConfig::get_file_location().map_err(|e| anyhow::anyhow!("{e}"))?;
let path = PartialWapmConfig::get_file_location()
.map_err(|e| anyhow::anyhow!("get file location: {e}"))?;
config.save(&path)?;
let username = crate::utils::get_username_registry_token(&registry, token);
if let Some(s) = username.ok().and_then(|o| o) {
println!("Login for WAPM user {:?} saved", s);
} else {
println!("Login for WAPM user saved");
}
Ok(())
crate::utils::get_username_registry_token(&registry, token)
}

View File

@@ -272,7 +272,7 @@ cfg_if::cfg_if! {
))] {
pc = context.uc_mcontext.gregs[libc::REG_EIP as usize] as usize;
sp = context.uc_mcontext.gregs[libc::REG_ESP as usize] as usize;
} else if #[cfg(all(target_os = "freebsd", target_arch = "x86"))] {
} else if #[cfg(all(target_os = "freebsd", any(target_arch = "x86", target_arch = "x86_64")))] {
pc = context.uc_mcontext.mc_rip as usize;
sp = context.uc_mcontext.mc_rsp as usize;
} else if #[cfg(all(target_vendor = "apple", target_arch = "x86_64"))] {

View File

@@ -12,6 +12,12 @@ varies based on the WASI version). A program compiled for the
filesystem manipulation, memory management, time, string, environment
variables, program startup etc.
Wasmer WASI is created with the aim to be fully sandboxed.
We are able to achieve that thanks to our Virtual Filesystem implementation (`wasmer-vfs`)
and by only allowing secure systemcalls back to the host.
> Note: If you encounter any sandboxing issue please open an issue in the wasmer repo https://github.com/wasmerio/wasmer.
This crate provides the necessary API to create the imports to use
WASI easily from the Wasmer runtime, through our `ImportObject` API.

View File

@@ -18,18 +18,31 @@ fn login_works() -> anyhow::Result<()> {
.arg(wapm_dev_token)
.output()?;
let stdout = std::str::from_utf8(&output.stdout)
.expect("stdout is not utf8! need to handle arbitrary bytes");
let stderr = std::str::from_utf8(&output.stderr)
.expect("stderr is not utf8! need to handle arbitrary bytes");
if !output.status.success() {
bail!(
"wasmer login failed with: stdout: {}\n\nstderr: {}",
std::str::from_utf8(&output.stdout)
.expect("stdout is not utf8! need to handle arbitrary bytes"),
std::str::from_utf8(&output.stderr)
.expect("stderr is not utf8! need to handle arbitrary bytes")
stdout,
stderr
);
}
let stdout_output = std::str::from_utf8(&output.stdout).unwrap();
assert_eq!(stdout_output, "Login for WAPM user \"ciuser\" saved\n");
let expected = "Login for WAPM user \"ciuser\" saved\n";
if stdout_output != expected {
println!("expected:");
println!("{expected}");
println!("got:");
println!("{stdout}");
println!("-----");
println!("{stderr}");
panic!("stdout incorrect");
}
Ok(())
}