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 'wasm32-unknown' to known targets #90223

Closed
wants to merge 1 commit into from

Conversation

dfordivam
Copy link
Contributor

Motivation for this change

This adds the support of wasm32-unknown / wasm32-unknown-unknown like targets.

WebGHC uses the wasm32-unknown-unknown-wasm target for the web-assembly cross compilation support for GHC/Haskell. But this can be used by any other tool chain doing web-assembly cross compilation.

It is necessary to upstream this as it is not possible to make it work using overlays. (let me know if I am wrong)

The wasm is meant to be different from the wasi / wasm32-unknown-wasi/ wasm32-wasi target (already present in nixpkgs), as it is a general web-assembly target, and is not tied to the wasi specification.

wasi is an already supported cross-compilation target in nixpkgs. But for WebGHC it cannot be used right now, as it is somewhat constrained interface. In future WebGHC might also move to using the wasi interface, but for the time being it uses a custom musl fork, and therefore chose to use a more general wasm32-unknown target for itself.

This is the first of the two PRs needed for upstreaming all the nixpkgs changes for wasm cross compilation support of WebGHC.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Sorry, something went wrong.

@@ -71,6 +73,7 @@ in {
wasi = filterDoubles predicates.isWasi;
windows = filterDoubles predicates.isWindows;
genode = filterDoubles predicates.isGenode;
wasm = filterDoubles predicates.isWasm;
Copy link
Member

Choose a reason for hiding this comment

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

This should go up above with the CPU arches

@@ -342,6 +343,7 @@ rec {
uclibceabihf = { float = "soft"; };
uclibceabi = { float = "hard"; };
uclibc = {};
wasm = {};
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this? this would be for e.g. wasm32-unknown-none-wasm.

@@ -280,6 +280,7 @@ rec {
windows = { execFormat = pe; families = { }; };
ghcjs = { execFormat = unknown; families = { }; };
genode = { execFormat = elf; families = { }; };
unknown = { execFormat = unknown; families = { }; };
Copy link
Member

Choose a reason for hiding this comment

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

I am a bit uncomfortable adding unknown as it's not actually an OS (kernel should be renamed OS). But yes there doesn't seem to be many good options, maybe we could even temporarily call it webghc, just like the ghcjs up above.

I would like to use to use browser, cause at the end of the day regardless of what sort of libc you get there is the externally implemented wasm interfaces that seem to be the moral equivalent of the syscalls---interfaces into the hosting system (OS) which is outsides the program's own control.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did some study of this, but did not find very convincing solution to what the OS should be called.

Regarding the unknown OS though, it has been widely used in the wasm cross-compilation target.
In fact it is present in the code mentioned at the top of this file http://llvm.org/doxygen/Triple_8cpp_source.html
case UnknownOS: return "unknown";
(Also there is no none option).

Nevertheless at this stage getting this correct is not even that important. If wasm32-unknown-none-musl is the one which works without adding unknown to the OS list, I am ok with it. Only when the changes are being upstreamed to ghc this will have to be fixed properly.

@dfordivam
Copy link
Contributor Author

Closing this as there is no consensus on the appropriate target, and moreover the target used by WebGHC might change in future, especially if it starts using wasi.

@dfordivam dfordivam closed this Sep 26, 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.

None yet

3 participants