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

Add UnsupportedTarget error to compiler #1881

Merged
merged 2 commits into from
Dec 7, 2020

Conversation

webmaster128
Copy link
Contributor

@webmaster128 webmaster128 commented Dec 6, 2020

Closes #1878

Description

We can error early on for system combinations that are known to not work. This gives users a much better idea why things error and allows adapting the strategy without investing lots of time in debugging.

The different behaviour is tested here:

Something that is not yet clear to me is if target is the proper OS source information and if the Compiler supports cross compilation where compile evironment is different from runtime environment.

Review

  • Add a short description of the the change to the CHANGELOG.md file

/// The compiler cannot be used the current environment.
/// This can refer to the OS, the chipset or any other aspect of the environment the compiler runs in.
#[cfg_attr(feature = "std", error("Environment {0} is not yet supported (see https://docs.wasmer.io/ecosystem/wasmer/wasmer-features)"))]
UnsupportedEnvironment(String),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe UnsupportedTarget should be the way to think about this?

Copy link
Member

@syrusakbary syrusakbary Dec 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think UnsupportedTarget reflects much better the propose of the error!

Copy link
Member

@syrusakbary syrusakbary Dec 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it would be great to have the Target and Compiler name as part of the error!

Suggested change
UnsupportedEnvironment(String),
/// The compiler cannot be used the provided target.
/// This can refer to the OS, the chipset or any other aspect of the environment the compiler runs in.
#[cfg_attr(feature = "std", error("The target {0} is not yet supported in the compiler {1} (see https://docs.wasmer.io/ecosystem/wasmer/wasmer-features)"))]
UnsupportedTarget(Target, Compiler),

Note: we will need the Compiler trait to derive from Display (not just Send) and implement the Display trait for each of the compilers (CraneliftCompiler, LLVMCompiler and SinglepassCompiler).

Copy link
Contributor Author

@webmaster128 webmaster128 Dec 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to UnsupportedTarget and added tests. There is also an error for 32 bit now.

I'm not convinced about the proposed arguments:

  • Using Target shows a lot of information to the user but does not provide information, which aspect of the target the problem is.
  • Adding Compiler seems redundant to me. It puts some of the context information in the error message. But this context should be available by knowledge of the compiler or stack traces. Adding it to one error case only feels very inconsistent.

@webmaster128 webmaster128 changed the title Add UnsupportedEnvironment error to comiler Add UnsupportedTarget error to compiler Dec 7, 2020
@syrusakbary
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented Dec 7, 2020

@bors bors bot merged commit 3290cd5 into wasmerio:master Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RuntimeError with Trap(StackOverflow) on Windows+singlepass
2 participants