Skip to content

Initial WebAssembly/WASI cross-compilation support - #56555

Merged
matthewbauer merged 12 commits into
NixOS:stagingfrom
matthewbauer:wasm
Apr 24, 2019
Merged

Initial WebAssembly/WASI cross-compilation support#56555
matthewbauer merged 12 commits into
NixOS:stagingfrom
matthewbauer:wasm

Conversation

@matthewbauer

@matthewbauer matthewbauer commented Mar 1, 2019

Copy link
Copy Markdown
Member
Motivation for this change

Need to add LLVM 8 to get this working. Can compile basic C programs. Things like C++ are unfortunately not supported right now.

/cc @ElvishJerricco

Test case:

with import <nixpkgs> {
  crossSystem = (import <nixpkgs/lib>).systems.examples.wasi32;
};
let
  cpp = builtins.toFile "test.c++" ''
    #include <iostream>

    int main() {
      std::cout << "Hello world!" << std::endl;
    }
  '';
in runCommandCC "cross-test" {} ''
      $CXX -o test ${cpp}
      ${stdenv.hostPlatform.emulator buildPackages} test > $out
''
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • 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 nox --run "nox-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)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@matthewbauer
matthewbauer requested review from LnL7 and dtzWill March 1, 2019 00:27
@GrahamcOfBorg GrahamcOfBorg added the 6.topic: stdenv Standard environment label Mar 1, 2019

@ElvishJerricco ElvishJerricco left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just took a cursory glance. Will do a more in depth review tomorrow.

In general though, this looks like several PRs in one. Stuff like the new version of llvm and the V8 changes seem like they should be different PRs to get better review.

Comment thread pkgs/build-support/cc-wrapper/default.nix Outdated
Comment thread pkgs/development/compilers/llvm/7/compiler-rt.nix Outdated
Comment thread pkgs/os-specific/linux/musl/web.nix Outdated
@matthewbauer

Copy link
Copy Markdown
Member Author

Yeah good point, i can split into llvm8 init, wasm init, and the v8 update.

@GrahamcOfBorg GrahamcOfBorg added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Mar 2, 2019
Comment thread lib/systems/parse.nix Outdated
@qknight

qknight commented Mar 4, 2019

Copy link
Copy Markdown
Member

this looks really cool!

@matthewbauer matthewbauer changed the title Initial WebAssembly cross-compilation support [wip] Initial WebAssembly cross-compilation support Mar 9, 2019
@matthewbauer matthewbauer changed the title [wip] Initial WebAssembly cross-compilation support Initial WebAssembly cross-compilation support Mar 22, 2019
@ElvishJerricco

Copy link
Copy Markdown
Contributor

This should probably switch to https://github.com/CraneStation/wasi-sysroot for libc. WASI is likely to become pretty standard, unlike both the jfbastien and the WebGHC ones.

@matthewbauer matthewbauer added this to the 19.09 milestone Apr 10, 2019
@GrahamcOfBorg GrahamcOfBorg added 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. and removed 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Apr 13, 2019
@matthewbauer

Copy link
Copy Markdown
Member Author

@ElvishJerricco Yeah i agree on that. Ideally the jfbastien and webghc musl stuff could be upstreamed. But right now that's not really a real ABI. Luckily we can reuse most of the changes here though.

@matthewbauer matthewbauer changed the title Initial WebAssembly cross-compilation support Initial WebAssembly/WASI cross-compilation support Apr 13, 2019
@matthewbauer
matthewbauer force-pushed the wasm branch 3 times, most recently from 76ece4a to fd5a881 Compare April 13, 2019 20:53
@ofborg ofborg Bot added 2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: GNOME GNOME desktop environment and its underlying platform 6.topic: haskell General-purpose, statically typed, purely functional programming language 6.topic: lua Lua is a powerful, efficient, lightweight, embeddable scripting language. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: printing Drivers, CUPS & Co. 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: qt/kde Object-oriented framework for GUI creation 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. 6.topic: steam Steam game store/launcher (store.steampowered.com) 6.topic: vim Advanced text editor 6.topic: xfce The Xfce Desktop Environment 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` labels Apr 24, 2019
@matthewbauer
matthewbauer changed the base branch from staging to master April 24, 2019 02:03
@matthewbauer
matthewbauer changed the base branch from master to staging April 24, 2019 02:03
@matthewbauer

Copy link
Copy Markdown
Member Author

@GrahamcOfBorg eval

@ofborg ofborg Bot removed 6.topic: GNOME GNOME desktop environment and its underlying platform 6.topic: haskell General-purpose, statically typed, purely functional programming language 6.topic: lua Lua is a powerful, efficient, lightweight, embeddable scripting language. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: printing Drivers, CUPS & Co. 6.topic: python Python is a high-level, general-purpose programming language. labels Apr 24, 2019
@dtzWill

dtzWill commented Apr 24, 2019 via email

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: stdenv Standard environment 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants