From bd5884204117b5f76ce46bb1073ce8ed511edfa0 Mon Sep 17 00:00:00 2001 From: Brandon Fish Date: Tue, 19 Nov 2019 23:38:50 -0600 Subject: [PATCH 01/16] Refactor excludes and add target_arch option --- lib/spectests/tests/excludes.txt | 4 +- lib/spectests/tests/spectest.rs | 252 +++++++++++++++++++++++++------ 2 files changed, 209 insertions(+), 47 deletions(-) diff --git a/lib/spectests/tests/excludes.txt b/lib/spectests/tests/excludes.txt index 628027693..45310f2e8 100644 --- a/lib/spectests/tests/excludes.txt +++ b/lib/spectests/tests/excludes.txt @@ -12,10 +12,12 @@ # Star line allows skipping an entire wast file # clif:skip:simd.wast:* # -# Excludes can also contain platform +# Excludes can also contain target family # clif:skip:data.wast:172:windows # clif:skip:data.wast:172:unix # +# Or target arch +# singlepass:skip:atomic.wast:*:*:aarch64 # Cranelift clif:skip:atomic.wast:* # Threads not implemented diff --git a/lib/spectests/tests/spectest.rs b/lib/spectests/tests/spectest.rs index 299971ee1..9bb6f631c 100644 --- a/lib/spectests/tests/spectest.rs +++ b/lib/spectests/tests/spectest.rs @@ -18,6 +18,7 @@ mod tests { // TODO Files could be run with multiple threads // TODO Allow running WAST &str directly (E.g. for use outside of spectests) + use std::collections::HashSet; use std::sync::{Arc, Mutex}; struct SpecFailure { @@ -46,15 +47,14 @@ mod tests { pub fn add_failure( &mut self, failure: SpecFailure, - testkey: &str, - excludes: &HashMap, + _testkey: &str, + excludes: &Vec, + line: u64, ) { - if excludes.contains_key(testkey) { - self.allowed_failure += 1; - return; - } - let platform_key = format!("{}:{}", testkey, get_platform()); - if excludes.contains_key(&platform_key) { + if excludes + .iter() + .any(|e| e.line_matches(line) && e.exclude_kind == ExcludeKind::Fail) + { self.allowed_failure += 1; return; } @@ -104,15 +104,113 @@ mod tests { } #[cfg(unix)] - fn get_platform() -> &'static str { + fn get_target_family() -> &'static str { "unix" } #[cfg(windows)] - fn get_platform() -> &'static str { + fn get_target_family() -> &'static str { "windows" } + fn get_target_arch() -> &'static str { + if cfg!(target_arch = "x86_64") { + "x86_64" + } else if cfg!(target_arch = "aarch64") { + "aarch64" + } else if cfg!(target_arch = "x86") { + "x86" + } else if cfg!(target_arch = "mips") { + "mips" + } else if cfg!(target_arch = "powerpc") { + "powerpc" + } else if cfg!(target_arch = "powerpc64") { + "powerpc64" + } else if cfg!(target_arch = "arm") { + "arm" + } else { + panic!("unknown target arch") + } + } + + // clif:skip:data.wast:172:unix:x86 + #[allow(dead_code)] + struct Exclude { + backend: Option, + exclude_kind: ExcludeKind, + file: String, + line: Option, + target_family: Option, + target_arch: Option, + } + + impl Exclude { + fn line_matches(&self, value: u64) -> bool { + self.line.is_none() || self.line.unwrap() == value + } + + fn line_exact_match(&self, value: u64) -> bool { + self.line.is_some() && self.line.unwrap() == value + } + + fn matches_backend(&self, value: &str) -> bool { + self.backend.is_none() || self.backend.as_ref().unwrap() == value + } + + fn matches_target_family(&self, value: &str) -> bool { + self.target_family.is_none() || self.target_family.as_ref().unwrap() == value + } + + fn matches_target_arch(&self, value: &str) -> bool { + self.target_arch.is_none() || self.target_arch.as_ref().unwrap() == value + } + + fn from( + backend: &str, + exclude_kind: &str, + file: &str, + line: &str, + target_family: &str, + target_arch: &str, + ) -> Exclude { + let backend: Option = match backend { + "*" => None, + "clif" => Some("clif".to_string()), + "singlepass" => Some("singlepass".to_string()), + "llvm" => Some("llvm".to_string()), + _ => panic!("backend {:?} not recognized", backend), + }; + let exclude_kind = match exclude_kind { + "skip" => ExcludeKind::Skip, + "fail" => ExcludeKind::Fail, + _ => panic!("exclude kind {:?} not recognized", exclude_kind), + }; + let line = match line { + "*" => None, + _ => Some( + line.parse::() + .expect(&format!("expected * or int: {:?}", line)), + ), + }; + let target_family = match target_family { + "*" => None, + _ => Some(target_family.to_string()), + }; + let target_arch = match target_arch { + "*" => None, + _ => Some(target_arch.to_string()), + }; + Exclude { + backend, + exclude_kind, + file: file.to_string(), + line, + target_family, + target_arch, + } + } + } + #[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))] fn get_compiler_name() -> &'static str { panic!("compiler not specified, activate a compiler via features"); @@ -160,7 +258,8 @@ mod tests { fn parse_and_run( path: &PathBuf, - excludes: &HashMap, + file_excludes: &HashSet, + excludes: &HashMap>, ) -> Result { let mut test_report = TestReport { failures: vec![], @@ -171,15 +270,9 @@ mod tests { let filename = path.file_name().unwrap().to_str().unwrap(); let source = fs::read(&path).unwrap(); - let backend = get_compiler_name(); - let platform = get_platform(); - let star_key = format!("{}:{}:*", backend, filename); - let platform_star_key = format!("{}:{}:*:{}", backend, filename, platform); - if (excludes.contains_key(&star_key) && *excludes.get(&star_key).unwrap() == Exclude::Skip) - || (excludes.contains_key(&platform_star_key) - && *excludes.get(&platform_star_key).unwrap() == Exclude::Skip) - { + // Entire file is excluded by line * and skip + if file_excludes.contains(filename) { return Ok(test_report); } @@ -198,21 +291,27 @@ mod tests { let mut registered_modules: HashMap>> = HashMap::new(); // + let empty_excludes = vec![]; + let excludes = if excludes.contains_key(filename) { + excludes.get(filename).unwrap() + } else { + &empty_excludes + }; + + let backend = get_compiler_name(); while let Some(Command { kind, line }) = parser.next().map_err(|e| format!("Parse err: {:?}", e))? { let test_key = format!("{}:{}:{}", backend, filename, line); - let test_platform_key = format!("{}:{}:{}:{}", backend, filename, line, platform); // Use this line to debug which test is running println!("Running test: {}", test_key); - if (excludes.contains_key(&test_key) - && *excludes.get(&test_key).unwrap() == Exclude::Skip) - || (excludes.contains_key(&test_platform_key) - && *excludes.get(&test_platform_key).unwrap() == Exclude::Skip) + // Skip tests that match this line + if excludes + .iter() + .any(|e| e.line_exact_match(line) && e.exclude_kind == ExcludeKind::Skip) { - // println!("Skipping test: {}", test_key); continue; } @@ -251,6 +350,7 @@ mod tests { }, &test_key, excludes, + line, ); instance = None; } @@ -290,6 +390,7 @@ mod tests { }, &test_key, excludes, + line, ); } else { let call_result = maybe_call_result.unwrap(); @@ -304,6 +405,7 @@ mod tests { }, &test_key, excludes, + line, ); } Ok(values) => { @@ -320,7 +422,7 @@ mod tests { "result {:?} ({:?}) does not match expected {:?} ({:?})", v, to_hex(v.clone()), expected_value, to_hex(expected_value.clone()) ), - }, &test_key, excludes); + }, &test_key, excludes, line); } else { test_report.count_passed(); } @@ -350,6 +452,7 @@ mod tests { }, &test_key, excludes, + line, ); } else { let export: Export = maybe_call_result.unwrap(); @@ -373,6 +476,7 @@ mod tests { }, &test_key, excludes, + line, ); } } @@ -386,6 +490,7 @@ mod tests { }, &test_key, excludes, + line, ); } } @@ -416,6 +521,7 @@ mod tests { }, &test_key, excludes, + line, ); } else { let call_result = maybe_call_result.unwrap(); @@ -430,6 +536,7 @@ mod tests { }, &test_key, excludes, + line, ); } Ok(values) => { @@ -453,6 +560,7 @@ mod tests { }, &test_key, excludes, + line, ); } } @@ -484,6 +592,7 @@ mod tests { }, &test_key, excludes, + line, ); } else { let call_result = maybe_call_result.unwrap(); @@ -498,6 +607,7 @@ mod tests { }, &test_key, excludes, + line, ); } Ok(values) => { @@ -521,6 +631,7 @@ mod tests { }, &test_key, excludes, + line, ); } } @@ -552,6 +663,7 @@ mod tests { }, &test_key, excludes, + line, ); } else { let call_result = maybe_call_result.unwrap(); @@ -569,6 +681,7 @@ mod tests { }, &test_key, excludes, + line, ); } CallError::Runtime(r) => { @@ -590,6 +703,7 @@ mod tests { }, &test_key, excludes, + line, ); } } @@ -606,6 +720,7 @@ mod tests { }, &test_key, excludes, + line, ); } } @@ -649,6 +764,7 @@ mod tests { }, &test_key, excludes, + line, ); } } @@ -662,6 +778,7 @@ mod tests { }, &test_key, excludes, + line, ); } } @@ -704,6 +821,7 @@ mod tests { }, &test_key, excludes, + line, ); } } @@ -717,6 +835,7 @@ mod tests { }, &test_key, excludes, + line, ); } } @@ -755,6 +874,7 @@ mod tests { }, &test_key, excludes, + line, ); } }; @@ -786,6 +906,7 @@ mod tests { }, &test_key, excludes, + line, ); } else { let call_result = maybe_call_result.unwrap(); @@ -807,6 +928,7 @@ mod tests { }, &test_key, excludes, + line, ); } } @@ -845,6 +967,7 @@ mod tests { }, &test_key, excludes, + line, ); } Ok(result) => match result { @@ -860,6 +983,7 @@ mod tests { }, &test_key, excludes, + line, ); } Err(e) => match e { @@ -876,6 +1000,7 @@ mod tests { }, &test_key, excludes, + line, ); } }, @@ -909,6 +1034,7 @@ mod tests { }, &test_key, excludes, + line, ); } } @@ -934,6 +1060,7 @@ mod tests { }, &test_key, excludes, + line, ); } else { let call_result = maybe_call_result.unwrap(); @@ -948,6 +1075,7 @@ mod tests { }, &test_key, excludes, + line, ); } Ok(_values) => { @@ -1105,7 +1233,7 @@ mod tests { } #[derive(Debug, Copy, Clone, PartialEq, Eq)] - enum Exclude { + enum ExcludeKind { Skip, Fail, } @@ -1115,13 +1243,18 @@ mod tests { use std::io::{BufRead, BufReader}; /// Reads the excludes.txt file into a hash map - fn read_excludes() -> HashMap { + fn read_excludes() -> (HashMap>, HashSet) { let mut excludes_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); excludes_path.push("tests"); excludes_path.push("excludes.txt"); let input = File::open(excludes_path).unwrap(); let buffered = BufReader::new(input); let mut result = HashMap::new(); + let mut file_excludes = HashSet::new(); + let current_backend = get_compiler_name(); + let current_target_family = get_target_family(); + let current_target_arch = get_target_arch(); + for line in buffered.lines() { let mut line = line.unwrap(); if line.trim().is_empty() || line.starts_with("#") { @@ -1136,26 +1269,53 @@ mod tests { // ::: let split: Vec<&str> = line.trim().split(':').collect(); - let kind = match *split.get(1).unwrap() { - "skip" => Exclude::Skip, - "fail" => Exclude::Fail, - _ => panic!("unknown exclude kind"), + let file = *split.get(2).unwrap(); + let exclude = match split.len() { + 0..=3 => panic!("expected at least 4 exclude conditions"), + 4 => Exclude::from( + *split.get(0).unwrap(), + *split.get(1).unwrap(), + *split.get(2).unwrap(), + *split.get(3).unwrap(), + "*", + "*", + ), + 5 => Exclude::from( + *split.get(0).unwrap(), + *split.get(1).unwrap(), + *split.get(2).unwrap(), + *split.get(3).unwrap(), + *split.get(4).unwrap(), + "*", + ), + 6 => Exclude::from( + *split.get(0).unwrap(), + *split.get(1).unwrap(), + *split.get(2).unwrap(), + *split.get(3).unwrap(), + *split.get(4).unwrap(), + *split.get(5).unwrap(), + ), + _ => panic!("too many exclude conditions {}", split.len()), }; - let has_platform = split.len() > 4; - let backend = split.get(0).unwrap(); - let testfile = split.get(2).unwrap(); - let line = split.get(3).unwrap(); - let key = if has_platform { - let platform = split.get(4).unwrap(); - format!("{}:{}:{}:{}", backend, testfile, line, platform) - } else { - format!("{}:{}:{}", backend, testfile, line) - }; - result.insert(key, kind); + if exclude.matches_backend(current_backend) + && exclude.matches_target_family(current_target_family) + && exclude.matches_target_arch(current_target_arch) + { + // Skip the whole file for line * and skip + if exclude.line.is_none() && exclude.exclude_kind == ExcludeKind::Skip { + file_excludes.insert(file.to_string()); + } + + if !result.contains_key(file) { + result.insert(file.to_string(), vec![]); + } + result.get_mut(file).unwrap().push(exclude); + } } } - result + (result, file_excludes) } #[test] @@ -1163,7 +1323,7 @@ mod tests { let mut success = true; let mut test_reports = vec![]; - let excludes = read_excludes(); + let (excludes, file_excludes) = read_excludes(); let mut glob_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); glob_path.push("spectests"); @@ -1173,7 +1333,7 @@ mod tests { for entry in glob(glob_str).expect("Failed to read glob pattern") { match entry { Ok(wast_path) => { - let result = parse_and_run(&wast_path, &excludes); + let result = parse_and_run(&wast_path, &file_excludes, &excludes); match result { Ok(test_report) => { if test_report.has_failures() { From dfe7c0d764a953e079cb35b62d2907bccb4b8c19 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 20 Nov 2019 13:27:18 +0100 Subject: [PATCH 02/16] fix(runtime-c-api) Add support for GNUC when defining `ARCH_X86_64`. `ARCH_X86_64` is correctly defined for GCC or clang, but gnuc was missing. This patch fixes that. --- lib/runtime-c-api/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/runtime-c-api/build.rs b/lib/runtime-c-api/build.rs index 7750b0081..5897001b0 100644 --- a/lib/runtime-c-api/build.rs +++ b/lib/runtime-c-api/build.rs @@ -22,7 +22,7 @@ fn main() { #endif #endif -#if defined(GCC) || defined(__clang__) +#if defined(GCC) || defined(__GNUC__) || defined(__clang__) #if defined(__x86_64__) #define ARCH_X86_64 #endif From 9468e229f4f2c968955c16c0eb6fa016b0f19154 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 20 Nov 2019 13:30:02 +0100 Subject: [PATCH 03/16] chore(runtime-c-api) Update header files. --- lib/runtime-c-api/wasmer.h | 2 +- lib/runtime-c-api/wasmer.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/runtime-c-api/wasmer.h b/lib/runtime-c-api/wasmer.h index 836a41df2..40a265cff 100644 --- a/lib/runtime-c-api/wasmer.h +++ b/lib/runtime-c-api/wasmer.h @@ -8,7 +8,7 @@ #endif #endif -#if defined(GCC) || defined(__clang__) +#if defined(GCC) || defined(__GNUC__) || defined(__clang__) #if defined(__x86_64__) #define ARCH_X86_64 #endif diff --git a/lib/runtime-c-api/wasmer.hh b/lib/runtime-c-api/wasmer.hh index 79c350d60..b437edd4b 100644 --- a/lib/runtime-c-api/wasmer.hh +++ b/lib/runtime-c-api/wasmer.hh @@ -8,7 +8,7 @@ #endif #endif -#if defined(GCC) || defined(__clang__) +#if defined(GCC) || defined(__GNUC__) || defined(__clang__) #if defined(__x86_64__) #define ARCH_X86_64 #endif From 6ba3d1c5bc47bbba8303cd22039ce810f85c0a26 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 20 Nov 2019 13:32:31 +0100 Subject: [PATCH 04/16] doc(changelog) Add #987. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ed6bfc74..40a600caf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## **[Unreleased]** +- [#987](https://github.com/wasmerio/wasmer/pull/987) Fix `runtime-c-api` header files when compiled by gnuc. + ## 0.10.2 - 2019-11-18 - [#968](https://github.com/wasmerio/wasmer/pull/968) Added `--invoke` option to the command From 1685455eb64bf1f770cbebe861e3f39d72800bef Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 20 Nov 2019 14:50:37 -0800 Subject: [PATCH 05/16] Allow to do wasmer execution without the `run` argument --- src/bin/wasmer.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 7af5df3e2..012758504 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -842,7 +842,20 @@ fn get_compiler_by_backend(backend: Backend) -> Option> { } fn main() { - let options = CLIOptions::from_args(); + let options = { + let args: Vec = env::args().into_iter().filter(|x| !x.starts_with("-")).collect(); + match args.get(1).map_or("", |s| &s) { + // Default + "run" | "cache" | "validate" | "self_update" | "" => { + CLIOptions::from_args() + } + // Wasmer trying to run a file directly + _ => { + let run_options = Run::from_args(); + CLIOptions::Run(run_options) + } + } + }; match options { CLIOptions::Run(options) => run(options), #[cfg(not(target_os = "windows"))] From cb7fcb94522d8b9b43d9322800553d81578555d7 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Wed, 20 Nov 2019 14:59:55 -0800 Subject: [PATCH 06/16] Simplify default run logic --- src/bin/wasmer.rs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 012758504..ef3ea2d9e 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -842,20 +842,8 @@ fn get_compiler_by_backend(backend: Backend) -> Option> { } fn main() { - let options = { - let args: Vec = env::args().into_iter().filter(|x| !x.starts_with("-")).collect(); - match args.get(1).map_or("", |s| &s) { - // Default - "run" | "cache" | "validate" | "self_update" | "" => { - CLIOptions::from_args() - } - // Wasmer trying to run a file directly - _ => { - let run_options = Run::from_args(); - CLIOptions::Run(run_options) - } - } - }; + let options = StructOpt::from_iter_safe(env::args()) + .unwrap_or_else(|_| CLIOptions::Run(Run::from_args())); match options { CLIOptions::Run(options) => run(options), #[cfg(not(target_os = "windows"))] From 4a84441ab0b879604c8db3a3beeabcdcc93ae2a4 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Wed, 20 Nov 2019 15:41:33 -0800 Subject: [PATCH 07/16] Run WASI C API tests based on feature; prevent cmake caching --- lib/runtime-c-api/tests/CMakeLists.txt | 14 ++++++++++---- .../tests/runtime_c_api_tests.rs | 9 ++++++++- lib/runtime-c-api/tests/test-import-object | Bin 14932 -> 19040 bytes .../tests/test-wasi-import-object | Bin 15612 -> 0 bytes 4 files changed, 18 insertions(+), 5 deletions(-) delete mode 100755 lib/runtime-c-api/tests/test-wasi-import-object diff --git a/lib/runtime-c-api/tests/CMakeLists.txt b/lib/runtime-c-api/tests/CMakeLists.txt index d8f206c49..e4a573e63 100644 --- a/lib/runtime-c-api/tests/CMakeLists.txt +++ b/lib/runtime-c-api/tests/CMakeLists.txt @@ -7,7 +7,6 @@ add_executable(test-globals test-globals.c) add_executable(test-import-function test-import-function.c) add_executable(test-imports test-imports.c) add_executable(test-import-object test-import-object.c) -add_executable(test-wasi-import-object test-wasi-import-object.c) add_executable(test-instantiate test-instantiate.c) add_executable(test-memory test-memory.c) add_executable(test-module test-module.c) @@ -19,6 +18,10 @@ add_executable(test-validate test-validate.c) add_executable(test-context test-context.c) add_executable(test-module-import-instantiate test-module-import-instantiate.c) +if (DEFINED WASI_TESTS) + add_executable(test-wasi-import-object test-wasi-import-object.c) +endif() + find_library( WASMER_LIB NAMES libwasmer_runtime_c_api.dylib libwasmer_runtime_c_api.so wasmer_runtime_c_api.dll PATHS ${CMAKE_SOURCE_DIR}/../../../target/release/ @@ -64,9 +67,12 @@ target_link_libraries(test-import-object general ${WASMER_LIB}) target_compile_options(test-import-object PRIVATE ${COMPILER_OPTIONS}) add_test(test-import-object test-import-object) -target_link_libraries(test-wasi-import-object general ${WASMER_LIB}) -target_compile_options(test-wasi-import-object PRIVATE ${COMPILER_OPTIONS}) -add_test(test-wasi-import-object test-wasi-import-object) + +if (DEFINED WASI_TESTS) + target_link_libraries(test-wasi-import-object general ${WASMER_LIB}) + target_compile_options(test-wasi-import-object PRIVATE ${COMPILER_OPTIONS}) + add_test(test-wasi-import-object test-wasi-import-object) +endif() target_link_libraries(test-instantiate general ${WASMER_LIB}) target_compile_options(test-instantiate PRIVATE ${COMPILER_OPTIONS}) diff --git a/lib/runtime-c-api/tests/runtime_c_api_tests.rs b/lib/runtime-c-api/tests/runtime_c_api_tests.rs index 0e3257786..ed4146363 100644 --- a/lib/runtime-c-api/tests/runtime_c_api_tests.rs +++ b/lib/runtime-c-api/tests/runtime_c_api_tests.rs @@ -4,7 +4,14 @@ use std::process::Command; fn test_c_api() { let project_tests_dir = concat!(env!("CARGO_MANIFEST_DIR"), "/tests"); - run_command("cmake", project_tests_dir, vec!["."]); + let cmake_args = vec![ + ".", + #[cfg(feature = "wasi")] + "-DWASI_TESTS=ON", + ]; + // we use -f so it doesn't fail if the fiel doesn't exist + run_command("rm", project_tests_dir, vec!["-f", "CMakeCache.txt"]); + run_command("cmake", project_tests_dir, cmake_args); run_command("make", project_tests_dir, vec!["-Wdev", "-Werror=dev"]); run_command("make", project_tests_dir, vec!["test", "ARGS=\"-V\""]); } diff --git a/lib/runtime-c-api/tests/test-import-object b/lib/runtime-c-api/tests/test-import-object index 42e1496de5000443de925286aeb63b7aa2e67456..bb0a97db3c95f2045f3f2e76e4099a5dc7ac76c9 100755 GIT binary patch delta 1524 zcmYk6O=ufO6vt;*T1iP0Tk?k@N0GCRaHN1Kl1yC%LXmJtLn*G6xL|r&Z=|(lyt0&? zZ7jDXc6%tLZOF%z;zJKUn)J{H^^j93g@BU(daBm?h1 zzyG|qvu{Vcx@|W;l7ipu{QA(#nB-z?QD%$9X&yHoa;a5gZkBKpP zASuD3pAu7L8|Kz{x{%gX*c8AouF0{E9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aC^W)FbV3OD&#d!I8I^zS5X3E$rZ0Yl|6QR|@81{-~C38C?GZiRFTw From 76e346b7080e3ef2a8e71cffaebf82a1916ce429 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Wed, 20 Nov 2019 15:50:46 -0800 Subject: [PATCH 08/16] Clean up from feedback, update changelog --- CHANGELOG.md | 1 + src/bin/wasmer.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40a600caf..c658e024d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## **[Unreleased]** +- [#990](https://github.com/wasmerio/wasmer/pull/990) Default wasmer CLI to `run`. Wasmer will now attempt to parse unrecognized command line options as if they were applied to the run command: `wasmer mywasm.wasm --dir=.` now works! - [#987](https://github.com/wasmerio/wasmer/pull/987) Fix `runtime-c-api` header files when compiled by gnuc. ## 0.10.2 - 2019-11-18 diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 5df7d5e5d..26afcc039 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -848,7 +848,7 @@ fn get_compiler_by_backend(backend: Backend) -> Option> { } fn main() { - let options = StructOpt::from_iter_safe(env::args()) + let options = CLIOptions::from_iter_safe(env::args()) .unwrap_or_else(|_| CLIOptions::Run(Run::from_args())); match options { CLIOptions::Run(options) => run(options), From fc733647ec169aeb6ef4a7896e0974d8b00b053e Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Wed, 20 Nov 2019 16:38:44 -0800 Subject: [PATCH 09/16] Add info in c api readme in the testing section --- lib/runtime-c-api/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/runtime-c-api/README.md b/lib/runtime-c-api/README.md index 8ce84a130..06e545bf7 100644 --- a/lib/runtime-c-api/README.md +++ b/lib/runtime-c-api/README.md @@ -105,6 +105,10 @@ int main() # Testing +Tests are run using the release build of the library. If you make +changes or compile with non-default features, please ensure you +rebuild in release mode for the tests to see the changes. + The tests can be run via `cargo test`, such as: ```sh From 70197c2e07d6df2179676bba0e977dcd03e66a2b Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 20 Nov 2019 16:38:50 -0800 Subject: [PATCH 10/16] Update wapm-cli to latest version --- wapm-cli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wapm-cli b/wapm-cli index c2da5cda3..3e9b1ea7b 160000 --- a/wapm-cli +++ b/wapm-cli @@ -1 +1 @@ -Subproject commit c2da5cda3b8f9cf7dcea144f8cabdf342f38a0bf +Subproject commit 3e9b1ea7b2d1ddae9de2e2ae6a2af03cdae0e385 From 274367b1527038236503724aaf7f9408a39bf70c Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 20 Nov 2019 17:15:20 -0800 Subject: [PATCH 11/16] Fixed CLI arguments issue --- Cargo.lock | 1 + Cargo.toml | 1 + src/bin/wasmer.rs | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 24fa874a3..a20878c06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1336,6 +1336,7 @@ name = "wasmer" version = "0.10.2" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 8724d91d4..5c48c6551 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ include = [ [dependencies] byteorder = "1.3" +clap="2.33.0" errno = "0.2" structopt = "0.3" wabt = "0.9.1" diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 26afcc039..93add0a13 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -16,6 +16,7 @@ use std::io::Read; use std::path::PathBuf; use std::process::exit; use std::str::FromStr; +use clap; use std::collections::HashMap; use structopt::StructOpt; @@ -848,8 +849,22 @@ fn get_compiler_by_backend(backend: Backend) -> Option> { } fn main() { + // We try to run wasmer with the normal arguments. + // Eg. `wasmer ` + // In case that fails, we fallback trying the Run subcommand directly. + // Eg. `wasmer myfile.wasm --dir=.` let options = CLIOptions::from_iter_safe(env::args()) - .unwrap_or_else(|_| CLIOptions::Run(Run::from_args())); + .unwrap_or_else(|e| { + match e.kind { + // This fixes a issue that: + // 1. Shows the version twice when doing `wasmer -V` + // 2. Shows the run help (instead of normal help) when doing `wasmer --help` + clap::ErrorKind::VersionDisplayed | clap::ErrorKind::HelpDisplayed => { + e.exit() + } + _ => CLIOptions::Run(Run::from_args()) + } + }); match options { CLIOptions::Run(options) => run(options), #[cfg(not(target_os = "windows"))] From f0fc15a4aa1bff9025c295282cc9be6115037c33 Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 20 Nov 2019 17:15:31 -0800 Subject: [PATCH 12/16] Updated WAPM CLI to to 0.4.1 --- wapm-cli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wapm-cli b/wapm-cli index 3e9b1ea7b..3562d6dda 160000 --- a/wapm-cli +++ b/wapm-cli @@ -1 +1 @@ -Subproject commit 3e9b1ea7b2d1ddae9de2e2ae6a2af03cdae0e385 +Subproject commit 3562d6dda52df526e6e1917dd33bb2454917ab9c From 8f625498197e439a01ee1745b555493242dcd720 Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 20 Nov 2019 17:18:52 -0800 Subject: [PATCH 13/16] Added changes in CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c658e024d..c7b0088dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## **[Unreleased]** +- [#992](https://github.com/wasmerio/wasmer/pull/992) Updates WAPM version to 0.4.1, fix arguments issue introduced in #990 - [#990](https://github.com/wasmerio/wasmer/pull/990) Default wasmer CLI to `run`. Wasmer will now attempt to parse unrecognized command line options as if they were applied to the run command: `wasmer mywasm.wasm --dir=.` now works! - [#987](https://github.com/wasmerio/wasmer/pull/987) Fix `runtime-c-api` header files when compiled by gnuc. From a71b9519c453527145c2473e7f751e235b646142 Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 20 Nov 2019 17:19:42 -0800 Subject: [PATCH 14/16] Fix lint issues --- src/bin/wasmer.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 93add0a13..966c6c0f6 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -9,6 +9,7 @@ )] extern crate structopt; +use clap; use std::env; use std::fs::{read_to_string, File}; use std::io; @@ -16,7 +17,6 @@ use std::io::Read; use std::path::PathBuf; use std::process::exit; use std::str::FromStr; -use clap; use std::collections::HashMap; use structopt::StructOpt; @@ -853,18 +853,15 @@ fn main() { // Eg. `wasmer ` // In case that fails, we fallback trying the Run subcommand directly. // Eg. `wasmer myfile.wasm --dir=.` - let options = CLIOptions::from_iter_safe(env::args()) - .unwrap_or_else(|e| { - match e.kind { - // This fixes a issue that: - // 1. Shows the version twice when doing `wasmer -V` - // 2. Shows the run help (instead of normal help) when doing `wasmer --help` - clap::ErrorKind::VersionDisplayed | clap::ErrorKind::HelpDisplayed => { - e.exit() - } - _ => CLIOptions::Run(Run::from_args()) - } - }); + let options = CLIOptions::from_iter_safe(env::args()).unwrap_or_else(|e| { + match e.kind { + // This fixes a issue that: + // 1. Shows the version twice when doing `wasmer -V` + // 2. Shows the run help (instead of normal help) when doing `wasmer --help` + clap::ErrorKind::VersionDisplayed | clap::ErrorKind::HelpDisplayed => e.exit(), + _ => CLIOptions::Run(Run::from_args()), + } + }); match options { CLIOptions::Run(options) => run(options), #[cfg(not(target_os = "windows"))] From dc01afb3b5658d021929b349b6b79b10538f7494 Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 20 Nov 2019 17:28:43 -0800 Subject: [PATCH 15/16] Use structopt clap instead of global clap --- Cargo.lock | 1 - Cargo.toml | 1 - src/bin/wasmer.rs | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a20878c06..24fa874a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1336,7 +1336,6 @@ name = "wasmer" version = "0.10.2" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 5c48c6551..8724d91d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,6 @@ include = [ [dependencies] byteorder = "1.3" -clap="2.33.0" errno = "0.2" structopt = "0.3" wabt = "0.9.1" diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 966c6c0f6..36e0100d6 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -9,7 +9,6 @@ )] extern crate structopt; -use clap; use std::env; use std::fs::{read_to_string, File}; use std::io; @@ -19,7 +18,7 @@ use std::process::exit; use std::str::FromStr; use std::collections::HashMap; -use structopt::StructOpt; +use structopt::{clap, StructOpt}; use wasmer::*; use wasmer_clif_backend::CraneliftCompiler; From 5e728ae893b9d7499ed522ac113b7f8d77a4d360 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Wed, 20 Nov 2019 18:28:58 -0800 Subject: [PATCH 16/16] Update install.sh --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index a4fc2b841..0420aad32 100755 --- a/install.sh +++ b/install.sh @@ -211,6 +211,7 @@ initArch() { case $ARCH in amd64) ARCH="amd64";; x86_64) ARCH="amd64";; + aarch64) ARCH="arm64";; # i386) ARCH="386";; *) printf "$red> The system architecture (${ARCH}) is not supported by this installation script.$reset\n"; exit 1;; esac