Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Obviate manual dependency on wasm-gc executable #3854

Merged
merged 1 commit into from
Oct 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \
export PATH="$PATH:$HOME/.cargo/bin" && \
rustup toolchain install nightly && \
rustup target add wasm32-unknown-unknown --toolchain nightly && \
cargo install --git https://github.com/alexcrichton/wasm-gc && \
rustup default nightly && \
rustup default stable && \
cargo build "--$PROFILE"
Expand Down
13 changes: 4 additions & 9 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ curl https://sh.rustup.rs -sSf | sh
rustup update nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
rustup update stable
cargo install --git https://github.com/alexcrichton/wasm-gc
----

You will also need to install the following packages:
Expand Down Expand Up @@ -231,13 +230,9 @@ If you are trying to set up Substrate on Windows, you should do the following:
rustup update stable
rustup target add wasm32-unknown-unknown --toolchain nightly

4. Next, you install wasm-gc, which is used to slim down Wasm files:
4. Then, you need to install LLVM: https://releases.llvm.org/download.html

cargo install --git https://github.com/alexcrichton/wasm-gc --force

5. Then, you need to install LLVM: https://releases.llvm.org/download.html

6. Next, you need to install OpenSSL, which we will do with `vcpkg`:
5. Next, you need to install OpenSSL, which we will do with `vcpkg`:

mkdir \Tools
cd \Tools
Expand All @@ -246,14 +241,14 @@ If you are trying to set up Substrate on Windows, you should do the following:
.\bootstrap-vcpkg.bat
.\vcpkg.exe install openssl:x64-windows-static

7. After, you need to add OpenSSL to your System Variables. Note that in order for the following commands to work, you need to use Windows Powershell:
6. After, you need to add OpenSSL to your System Variables. Note that in order for the following commands to work, you need to use Windows Powershell:

$env:OPENSSL_DIR = 'C:\Tools\vcpkg\installed\x64-windows-static'
$env:OPENSSL_STATIC = 'Yes'
[System.Environment]::SetEnvironmentVariable('OPENSSL_DIR', $env:OPENSSL_DIR, [System.EnvironmentVariableTarget]::User)
[System.Environment]::SetEnvironmentVariable('OPENSSL_STATIC', $env:OPENSSL_STATIC, [System.EnvironmentVariableTarget]::User)

8. Finally, you need to install `cmake`: https://cmake.org/download/
7. Finally, you need to install `cmake`: https://cmake.org/download/

==== Shared Steps

Expand Down
1 change: 1 addition & 0 deletions core/utils/wasm-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ tempfile = "3.1.0"
toml = "0.5.3"
walkdir = "2.2.9"
fs2 = "0.4.3"
wasm-gc-api = "0.1.11"
1 change: 0 additions & 1 deletion core/utils/wasm-builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ be `NODE_RUNTIME`.
WASM builder requires the following prerequisities for building the WASM binary:

- rust nightly + `wasm32-unknown-unknown` toolchain
- wasm-gc


License: GPL-3.0
1 change: 0 additions & 1 deletion core/utils/wasm-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
//! WASM builder requires the following prerequisities for building the WASM binary:
//!
//! - rust nightly + `wasm32-unknown-unknown` toolchain
//! - wasm-gc
//!

use std::{env, fs, path::PathBuf, process::{Command, Stdio, self}};
Expand Down
13 changes: 1 addition & 12 deletions core/utils/wasm-builder/src/prerequisites.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.

use std::{process::{Command, Stdio}, fs};

use std::env;
use std::{env, fs};
use tempfile::tempdir;

/// Checks that all prerequisites are installed.
Expand All @@ -28,15 +26,6 @@ pub fn check() -> Option<&'static str> {
return Some("Rust nightly not installed, please install it!")
}

if Command::new("wasm-gc")
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
.map(|s| !s.success()).unwrap_or(true)
{
return Some("`wasm-gc` not installed, please install it!")
}

check_wasm_toolchain_installed()
}

Expand Down
13 changes: 3 additions & 10 deletions core/utils/wasm-builder/src/wasm_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use crate::write_file_if_changed;

use std::{fs, path::{Path, PathBuf}, borrow::ToOwned, process::{Command, self}, env};
use std::{fs, path::{Path, PathBuf}, borrow::ToOwned, process, env};

use toml::value::Table;

Expand Down Expand Up @@ -352,15 +352,8 @@ fn compact_wasm_file(
.join(format!("{}.wasm", wasm_binary));
let wasm_compact_file = project.join(format!("{}.compact.wasm", wasm_binary));

let res = Command::new("wasm-gc")
.arg(&wasm_file)
.arg(&wasm_compact_file)
.status()
.map(|s| s.success());

if !res.unwrap_or(false) {
panic!("Failed to compact generated WASM binary.");
}
wasm_gc::garbage_collect_file(&wasm_file, &wasm_compact_file)
.expect("Failed to compact generated WASM binary.");

(WasmBinary(wasm_compact_file), WasmBinaryBloaty(wasm_file))
}
Expand Down
4 changes: 0 additions & 4 deletions node-template/scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,3 @@ if [ -z $CI_PROJECT_NAME ] ; then
fi

rustup target add wasm32-unknown-unknown --toolchain nightly

# Install wasm-gc. It's useful for stripping slimming down wasm binaries.
command -v wasm-gc || \
cargo +nightly install --git https://github.com/alexcrichton/wasm-gc --force
4 changes: 0 additions & 4 deletions scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,3 @@ if [ -z $CI_PROJECT_NAME ] ; then
fi

rustup target add wasm32-unknown-unknown --toolchain nightly

# Install wasm-gc. It's useful for stripping slimming down wasm binaries.
command -v wasm-gc || \
cargo +nightly install --git https://github.com/alexcrichton/wasm-gc --force