-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(nix): Use wasi-sdk 12 to provide barretenberg-wasm in overlay (#315)
* fix(nix): Use wasi-sdk 12 to provide barretenberg-wasm in overlay * chore: Remove the wasm stuff from main package * chore(nix): Switch the default llvm to 11 * chore(nix): Add transcript00 to the overlay chore(nix): Cleanup for nix flake check * Use hash for each platform * avoid symlinks * try wasi-sdk that someone wrote on github * fix hash for linux * try to ignore libstdc++ * need the whole name * try to include std lib instead of ignore * cleanup and nix flake check * chore(ci): Check the nix flake in CI * run default build instead of llvm12
- Loading branch information
Showing
6 changed files
with
112 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ stdenv, cmake, ninja, binaryen, callPackage }: | ||
let | ||
toolchain_file = ./cpp/cmake/toolchains/wasm32-wasi.cmake; | ||
wasi-sdk = callPackage ./wasi-sdk.nix { }; | ||
in | ||
stdenv.mkDerivation | ||
{ | ||
pname = "barretenberg.wasm"; | ||
version = "0.1.0"; | ||
|
||
src = ./cpp; | ||
|
||
nativeBuildInputs = [ cmake ninja binaryen wasi-sdk ]; | ||
|
||
buildInputs = [ ]; | ||
|
||
cmakeFlags = [ | ||
"-DTESTING=OFF" | ||
"-DBENCHMARKS=OFF" | ||
"-DCMAKE_TOOLCHAIN_FILE=${toolchain_file}" | ||
"-DCMAKE_C_COMPILER=${wasi-sdk}/bin/clang" | ||
"-DCMAKE_CXX_COMPILER=${wasi-sdk}/bin/clang++" | ||
"-DCMAKE_AR=${wasi-sdk}/bin/llvm-ar" | ||
"-DCMAKE_RANLIB=${wasi-sdk}/bin/llvm-ranlib" | ||
"-DCMAKE_SYSROOT=${wasi-sdk}/share/wasi-sysroot" | ||
"-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER" | ||
"-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY" | ||
"-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY" | ||
"-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY" | ||
"-DCMAKE_C_COMPILER_WORKS=ON" | ||
"-DCMAKE_CXX_COMPILER_WORKS=ON" | ||
]; | ||
|
||
enableParallelBuilding = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copied from https://github.com/ereslibre/nixities/blob/2c60af777fc863f90e6e4eeffcf3465def93a1f3/packages/wasi-sdk/default.nix | ||
# with a fix for the autoPatchelfHook needing libstdc++.so and some refactor | ||
{ lib, pkgs, stdenv }: | ||
let | ||
pname = "wasi-sdk"; | ||
version = "12"; | ||
in | ||
pkgs.stdenv.mkDerivation { | ||
inherit pname version; | ||
|
||
sourceRoot = "${pname}-${version}.0"; | ||
dontBuild = true; | ||
dontConfigure = true; | ||
dontStrip = true; | ||
|
||
nativeBuildInputs = | ||
lib.optional stdenv.isLinux (with pkgs; [ autoPatchelfHook ]); | ||
|
||
# Needed by autoPatchelfHook to have libstdc++ | ||
# see https://discourse.nixos.org/t/autopatchelfhook-not-patching-all-dependencies/14634/6 | ||
buildInputs = | ||
lib.optional stdenv.isLinux [ stdenv.cc.cc.lib ]; | ||
|
||
installPhase = '' | ||
mkdir -p $out/{bin,lib,share} | ||
mv bin/* $out/bin/ | ||
mv lib/* $out/lib/ | ||
mv share/* $out/share/ | ||
''; | ||
|
||
src = | ||
let | ||
tarball = | ||
if stdenv.hostPlatform.isDarwin then { | ||
suffix = "macos"; | ||
hash = "sha256-juJfnD/eYY/upcV62tOFFSYmeEtra1L7Vj5e2DK/U+8="; | ||
} else { | ||
suffix = "linux"; | ||
hash = "sha256-+kdpTXW/b86Y++eScZMpiyXuA9reJ/ykU9fdUwN4lzo="; | ||
}; | ||
in | ||
|
||
pkgs.fetchurl { | ||
url = | ||
"https://github.com/WebAssembly/${pname}/releases/download/${pname}-${version}/${pname}-${version}.0-${tarball.suffix}.tar.gz"; | ||
hash = tarball.hash; | ||
}; | ||
} |