From a62a8ab20525c52de2bf37bb9125281cf5534301 Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Mon, 9 May 2022 20:55:21 +0100 Subject: [PATCH 01/16] Build web REPL on Netlify --- www/build.sh | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/www/build.sh b/www/build.sh index d31c99bb64..f5a9ea868b 100755 --- a/www/build.sh +++ b/www/build.sh @@ -11,21 +11,9 @@ cd $SCRIPT_RELATIVE_DIR rm -rf build/ cp -r public/ build/ -pushd build - # grab the source code and copy it to Netlify's server; if it's not there, fail the build. +pushd build wget https://github.com/rtfeldman/elm-css/files/8037422/roc-source-code.zip - -# Copy REPL webpage source files -cp -r ../../repl_www/public/* . - -# grab the pre-compiled REPL and copy it to Netlify's server; if it's not there, fail the build. -wget https://github.com/brian-carroll/mock-repl/archive/refs/heads/deploy.zip -unzip deploy.zip -mv mock-repl-deploy/* . -rmdir mock-repl-deploy -rm deploy.zip - popd pushd .. @@ -47,10 +35,12 @@ export ROC_DOCS_URL_ROOT=/builtins BUILTINS_WASM32_O="" BUILTINS_HOST_O="" -# We run the CLI with --no-default-features because that way we don't have the -# "llvm" feature and therefore don't depend on LLVM being installed on the -# system. (Netlify's build servers have Rust installed, but not LLVM.) cargo run --bin roc-docs compiler/builtins/roc/*.roc mv generated-docs/*.* www/build # move all the .js, .css, etc. files to build/ mv generated-docs/ www/build/builtins # move all the folders to build/builtins/ + +# Web REPL +repl_www/build.sh +cp -r repl_www/public/* www/build + popd From 1c56280a2c235a00a8867dac6251d75f06e85168 Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Sat, 14 May 2022 09:44:28 +0100 Subject: [PATCH 02/16] Install Zig on Netlify --- www/netlify.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/www/netlify.sh b/www/netlify.sh index bf388c1ea4..72b0daa6fa 100644 --- a/www/netlify.sh +++ b/www/netlify.sh @@ -6,11 +6,15 @@ set -euxo pipefail rustup update rustup default stable +rustup target add wasm32-unknown-unknown wasm32-wasi -# TODO remove this once we actually build the web repl! -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -REPL_WASM_DATA=${SCRIPT_DIR}/../repl_wasm/data/ -mkdir -p ${REPL_WASM_DATA} -touch ${REPL_WASM_DATA}/pre_linked_binary.o +ZIG_DIR="zig-linux-x86_64-0.9.1" +wget https://ziglang.org/download/0.9.1/${ZIG_DIR}.tar.xz + +uname -a + +xz --decompress ${ZIG_DIR}.tar.xz +tar xvf ${ZIG_DIR}.tar +export PATH="${ZIG_DIR}:${PATH}" bash build.sh From 3e7928096d7196fd0880fa87db533cde9ef1bac7 Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Sat, 14 May 2022 10:09:50 +0100 Subject: [PATCH 03/16] Clean up Netlify script --- www/netlify.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/www/netlify.sh b/www/netlify.sh index 72b0daa6fa..7de90bfe7c 100644 --- a/www/netlify.sh +++ b/www/netlify.sh @@ -8,13 +8,9 @@ rustup update rustup default stable rustup target add wasm32-unknown-unknown wasm32-wasi -ZIG_DIR="zig-linux-x86_64-0.9.1" -wget https://ziglang.org/download/0.9.1/${ZIG_DIR}.tar.xz - -uname -a - -xz --decompress ${ZIG_DIR}.tar.xz -tar xvf ${ZIG_DIR}.tar -export PATH="${ZIG_DIR}:${PATH}" +ZIG_DIRNAME="zig-linux-x86_64-0.9.1" +wget https://ziglang.org/download/0.9.1/${ZIG_DIRNAME}.tar.xz +tar --extract --xz --file=${ZIG_DIRNAME}.tar.xz +export PATH="$(pwd)/${ZIG_DIRNAME}:${PATH}" bash build.sh From 6a91e661921ea00d6ad4604d67ac6e938f471eb6 Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Sun, 15 May 2022 12:57:37 +0100 Subject: [PATCH 04/16] Delete env var NO_ZIG_INSTALLED since Zig is now installed on Netlify --- compiler/builtins/build.rs | 9 --------- repl_wasm/build.rs | 9 --------- www/build.sh | 6 +----- 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/compiler/builtins/build.rs b/compiler/builtins/build.rs index 59503cc89a..2805784dec 100644 --- a/compiler/builtins/build.rs +++ b/compiler/builtins/build.rs @@ -20,15 +20,6 @@ fn zig_executable() -> String { fn main() { println!("cargo:rerun-if-changed=build.rs"); - // When we build on Netlify, zig is not installed (but also not used, - // since all we're doing is generating docs), so we can skip the steps - // that require having zig installed. - if env::var_os("NO_ZIG_INSTALLED").is_some() { - // We still need to do the other things before this point, because - // setting the env vars is needed for other parts of the build. - return; - } - // "." is relative to where "build.rs" is // dunce can be removed once ziglang/zig#5109 is fixed let build_script_dir_path = dunce::canonicalize(Path::new(".")).unwrap(); diff --git a/repl_wasm/build.rs b/repl_wasm/build.rs index b050c20673..832a1b7c56 100644 --- a/repl_wasm/build.rs +++ b/repl_wasm/build.rs @@ -13,15 +13,6 @@ fn main() { let source_path = format!("src/{}.c", PLATFORM_FILENAME); println!("cargo:rerun-if-changed={}", source_path); - // When we build on Netlify, zig is not installed (but also not used, - // since all we're doing is generating docs), so we can skip the steps - // that require having zig installed. - if env::var_os("NO_ZIG_INSTALLED").is_some() { - // We still need to do the other things before this point, because - // setting the env vars is needed for other parts of the build. - return; - } - std::fs::create_dir_all("./data").unwrap(); // Zig can produce *either* an object containing relocations OR an object containing libc code diff --git a/www/build.sh b/www/build.sh index f5a9ea868b..382c4a7227 100755 --- a/www/build.sh +++ b/www/build.sh @@ -31,15 +31,11 @@ RUSTFLAGS=-Awarnings # is set up to serve them. export ROC_DOCS_URL_ROOT=/builtins -# These just need to be defined so that some env! macros don't fail. -BUILTINS_WASM32_O="" -BUILTINS_HOST_O="" - cargo run --bin roc-docs compiler/builtins/roc/*.roc mv generated-docs/*.* www/build # move all the .js, .css, etc. files to build/ mv generated-docs/ www/build/builtins # move all the folders to build/builtins/ -# Web REPL +echo "Building Web REPL..." repl_www/build.sh cp -r repl_www/public/* www/build From 1b6c2fccef58bc3ddb05e8aa71b7d60845e42d0f Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Sun, 15 May 2022 13:45:37 +0100 Subject: [PATCH 05/16] Install wasm-opt on Netlify, since wasm-pack fails to do so --- .gitignore | 1 + www/build.sh | 3 +++ www/netlify.sh | 12 +++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 87635559c0..03c01ea6aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ target generated-docs +netlify-install zig-cache .direnv .envrc diff --git a/www/build.sh b/www/build.sh index 382c4a7227..90b1d6f20e 100755 --- a/www/build.sh +++ b/www/build.sh @@ -39,4 +39,7 @@ echo "Building Web REPL..." repl_www/build.sh cp -r repl_www/public/* www/build +echo "Asset sizes:" +ls -lh www/build/* + popd diff --git a/www/netlify.sh b/www/netlify.sh index 7de90bfe7c..e9dd0e5d99 100644 --- a/www/netlify.sh +++ b/www/netlify.sh @@ -8,9 +8,19 @@ rustup update rustup default stable rustup target add wasm32-unknown-unknown wasm32-wasi +cd netlify-install + ZIG_DIRNAME="zig-linux-x86_64-0.9.1" wget https://ziglang.org/download/0.9.1/${ZIG_DIRNAME}.tar.xz tar --extract --xz --file=${ZIG_DIRNAME}.tar.xz -export PATH="$(pwd)/${ZIG_DIRNAME}:${PATH}" +# Work around an issue with wasm-pack where it fails to install wasm-opt (from binaryen) on some CI systems +# https://github.com/rustwasm/wasm-pack/issues/864 +BINARYEN_DIRNAME="binaryen-version_108-x86_64-linux" +wget https://github.com/WebAssembly/binaryen/releases/download/version_108/${BINARYEN_DIRNAME}.tar.gz +tar --extract --gzip --file=${BINARYEN_DIRNAME}.tar.gz + +cd .. + +export PATH="$(pwd)/netlify-install/${BINARYEN_DIRNAME}/bin:$(pwd)/netlify-install/${ZIG_DIRNAME}:${PATH}" bash build.sh From 25fdeb5ca81574c89baf4122cf922a3ca7077a6c Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Sun, 15 May 2022 15:47:25 +0100 Subject: [PATCH 06/16] Install wasm-opt on Earthly --- Earthfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Earthfile b/Earthfile index 6f9287159c..0a13a7999f 100644 --- a/Earthfile +++ b/Earthfile @@ -42,6 +42,9 @@ install-zig-llvm-valgrind-clippy-rustfmt: RUN rustup target add wasm32-unknown-unknown wasm32-wasi RUN apt -y install libssl-dev RUN OPENSSL_NO_VENDOR=1 cargo install wasm-pack + RUN wget https://github.com/WebAssembly/binaryen/releases/download/version_108/binaryen-version_108-x86_64-linux.tar.gz + RUN tar -xzf binaryen-version_108-x86_64-linux.tar.gz + RUN ln -s /earthbuild/binaryen-version_108-x86_64-linux/bin/wasm-opt /bin/wasm-opt # criterion RUN cargo install cargo-criterion # sccache @@ -105,7 +108,7 @@ test-rust: # RUN echo "4" | cargo run --locked --release --features="target-x86" -- --target=x86_32 examples/benchmarks/NQueens.roc # RUN --mount=type=cache,target=$SCCACHE_DIR \ # cargo test --locked --release --features with_sound --test cli_run i386 --features="i386-cli-run" && sccache --show-stats - # make sure doc generation works (that is, make sure build.sh returns status code 0) + # make sure website deployment works (that is, make sure build.sh returns status code 0) RUN bash www/build.sh From 03ae3f3c47f4b1b99635b5729ef23b29d11c4167 Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Sun, 15 May 2022 15:48:43 +0100 Subject: [PATCH 07/16] Create netlify-install directory on Netlify --- www/netlify.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/www/netlify.sh b/www/netlify.sh index e9dd0e5d99..bda845f48c 100644 --- a/www/netlify.sh +++ b/www/netlify.sh @@ -8,6 +8,7 @@ rustup update rustup default stable rustup target add wasm32-unknown-unknown wasm32-wasi +mkdir -p netlify-install cd netlify-install ZIG_DIRNAME="zig-linux-x86_64-0.9.1" From da869203247b9ad8f673c3c15ea2e4b657ef1bd5 Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Mon, 16 May 2022 08:18:05 +0100 Subject: [PATCH 08/16] Try installing wasm-opt via apt --- .gitignore | 1 - Earthfile | 5 +---- www/netlify.sh | 11 ++--------- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 03c01ea6aa..87635559c0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ target generated-docs -netlify-install zig-cache .direnv .envrc diff --git a/Earthfile b/Earthfile index 0a13a7999f..9aaec6d614 100644 --- a/Earthfile +++ b/Earthfile @@ -40,11 +40,8 @@ install-zig-llvm-valgrind-clippy-rustfmt: RUN rustup component add rustfmt # wasm repl & tests RUN rustup target add wasm32-unknown-unknown wasm32-wasi - RUN apt -y install libssl-dev + RUN apt -y install libssl-dev binaryen RUN OPENSSL_NO_VENDOR=1 cargo install wasm-pack - RUN wget https://github.com/WebAssembly/binaryen/releases/download/version_108/binaryen-version_108-x86_64-linux.tar.gz - RUN tar -xzf binaryen-version_108-x86_64-linux.tar.gz - RUN ln -s /earthbuild/binaryen-version_108-x86_64-linux/bin/wasm-opt /bin/wasm-opt # criterion RUN cargo install cargo-criterion # sccache diff --git a/www/netlify.sh b/www/netlify.sh index bda845f48c..3e56e9c253 100644 --- a/www/netlify.sh +++ b/www/netlify.sh @@ -8,20 +8,13 @@ rustup update rustup default stable rustup target add wasm32-unknown-unknown wasm32-wasi -mkdir -p netlify-install -cd netlify-install - ZIG_DIRNAME="zig-linux-x86_64-0.9.1" wget https://ziglang.org/download/0.9.1/${ZIG_DIRNAME}.tar.xz tar --extract --xz --file=${ZIG_DIRNAME}.tar.xz +export PATH="$(pwd)/${ZIG_DIRNAME}:${PATH}" # Work around an issue with wasm-pack where it fails to install wasm-opt (from binaryen) on some CI systems # https://github.com/rustwasm/wasm-pack/issues/864 -BINARYEN_DIRNAME="binaryen-version_108-x86_64-linux" -wget https://github.com/WebAssembly/binaryen/releases/download/version_108/${BINARYEN_DIRNAME}.tar.gz -tar --extract --gzip --file=${BINARYEN_DIRNAME}.tar.gz +apt -y install binaryen -cd .. - -export PATH="$(pwd)/netlify-install/${BINARYEN_DIRNAME}/bin:$(pwd)/netlify-install/${ZIG_DIRNAME}:${PATH}" bash build.sh From c62c7c0722485e09f0e5c4d8ce80c3f6b9fe8151 Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Mon, 16 May 2022 08:18:47 +0100 Subject: [PATCH 09/16] Make Cargo verbose to debug a web REPL build issuex --- repl_www/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repl_www/build.sh b/repl_www/build.sh index 9e762ddfd4..02055230d3 100755 --- a/repl_www/build.sh +++ b/repl_www/build.sh @@ -26,7 +26,7 @@ then wasm-bindgen --target web --keep-debug target/wasm32-unknown-unknown/release/roc_repl_wasm.wasm --out-dir repl_wasm/pkg/ else # A `--profiling` build is optimized and has debug info, so we get stack traces for compiler `todo!()` - wasm-pack build --profiling --target web repl_wasm -- --features console_error_panic_hook + wasm-pack build --profiling --target web repl_wasm -- --features console_error_panic_hook -v fi cp repl_wasm/pkg/*.wasm $WWW_ROOT From 65bbd85cc7141f4814b57831a05b9d7da90514bc Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Mon, 16 May 2022 09:02:43 +0100 Subject: [PATCH 10/16] Disable wasm-opt by default and run it when needed --- Earthfile | 3 ++- repl_wasm/Cargo.toml | 5 +++-- repl_www/build.sh | 20 +++++++++----------- www/netlify.sh | 8 ++++++-- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Earthfile b/Earthfile index 9aaec6d614..c9272f2ca1 100644 --- a/Earthfile +++ b/Earthfile @@ -40,7 +40,7 @@ install-zig-llvm-valgrind-clippy-rustfmt: RUN rustup component add rustfmt # wasm repl & tests RUN rustup target add wasm32-unknown-unknown wasm32-wasi - RUN apt -y install libssl-dev binaryen + RUN apt -y install libssl-dev RUN OPENSSL_NO_VENDOR=1 cargo install wasm-pack # criterion RUN cargo install cargo-criterion @@ -106,6 +106,7 @@ test-rust: # RUN --mount=type=cache,target=$SCCACHE_DIR \ # cargo test --locked --release --features with_sound --test cli_run i386 --features="i386-cli-run" && sccache --show-stats # make sure website deployment works (that is, make sure build.sh returns status code 0) + ENV REPL_DEBUG=1 RUN bash www/build.sh diff --git a/repl_wasm/Cargo.toml b/repl_wasm/Cargo.toml index 7acb6b2e89..c46ec537fb 100644 --- a/repl_wasm/Cargo.toml +++ b/repl_wasm/Cargo.toml @@ -29,5 +29,6 @@ roc_types = {path = "../compiler/types"} [features] wasmer = ["futures"] -[package.metadata.wasm-pack.profile.profiling] -wasm-opt = ['-Os', '-g'] # `wasm-pack --profiling` is supposed to have debug info `-g` by default, but doesn't +# Tell wasm-pack not to run wasm-opt automatically. We run it explicitly when we need to. +# (Workaround for a CI install issue with wasm-pack https://github.com/rustwasm/wasm-pack/issues/864) +wasm-opt = false diff --git a/repl_www/build.sh b/repl_www/build.sh index 02055230d3..99014dcbe5 100755 --- a/repl_www/build.sh +++ b/repl_www/build.sh @@ -18,18 +18,16 @@ fi WWW_ROOT="${1:-repl_www/public}" mkdir -p $WWW_ROOT -# When debugging the REPL, use `REPL_DEBUG=1 repl_www/build.sh` -if [ -n "${REPL_DEBUG:-}" ] -then - # Leave out wasm-opt since it takes too long when debugging, and provide some debug options - cargo build --target wasm32-unknown-unknown -p roc_repl_wasm --release --features console_error_panic_hook - wasm-bindgen --target web --keep-debug target/wasm32-unknown-unknown/release/roc_repl_wasm.wasm --out-dir repl_wasm/pkg/ -else - # A `--profiling` build is optimized and has debug info, so we get stack traces for compiler `todo!()` - wasm-pack build --profiling --target web repl_wasm -- --features console_error_panic_hook -v -fi +# We want a release build, but with debug info (to get stack traces for Wasm backend `todo!()`) +# This configuration is called `--profiling` +wasm-pack build --profiling --target web repl_wasm -- --features console_error_panic_hook -v +cp repl_wasm/pkg/roc_repl_wasm_bg.wasm $WWW_ROOT -cp repl_wasm/pkg/*.wasm $WWW_ROOT +# To disable optimizations while debugging, run `REPL_DEBUG=1 repl_www/build.sh` +if [ "${REPL_DEBUG:-}" == "" ] +then + wasm-opt -Os --debuginfo repl_wasm/pkg/roc_repl_wasm_bg.wasm -o $WWW_ROOT/roc_repl_wasm_bg.wasm +fi # Copy the JS from wasm_bindgen, replacing its invalid `import` statement with a `var`. # The JS import from the invalid path 'env', seems to be generated when there are unresolved symbols. diff --git a/www/netlify.sh b/www/netlify.sh index 3e56e9c253..20ea56bfc0 100644 --- a/www/netlify.sh +++ b/www/netlify.sh @@ -11,10 +11,14 @@ rustup target add wasm32-unknown-unknown wasm32-wasi ZIG_DIRNAME="zig-linux-x86_64-0.9.1" wget https://ziglang.org/download/0.9.1/${ZIG_DIRNAME}.tar.xz tar --extract --xz --file=${ZIG_DIRNAME}.tar.xz -export PATH="$(pwd)/${ZIG_DIRNAME}:${PATH}" +PATH="$(pwd)/${ZIG_DIRNAME}:${PATH}" # Work around an issue with wasm-pack where it fails to install wasm-opt (from binaryen) on some CI systems # https://github.com/rustwasm/wasm-pack/issues/864 -apt -y install binaryen +BINARYEN_DIRNAME="binaryen-version_108-x86_64-linux" +wget https://github.com/WebAssembly/binaryen/releases/download/version_108/${BINARYEN_DIRNAME}.tar.gz +tar --extract --gzip --file=${BINARYEN_DIRNAME}.tar.gz +PATH="$(pwd)/${BINARYEN_DIRNAME}/bin:${PATH}" +export PATH bash build.sh From a80707209ff53a2b1b7dbdb1f0dea36e4bf5f405 Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Mon, 16 May 2022 09:05:42 +0100 Subject: [PATCH 11/16] Fix Cargo.toml bug --- repl_wasm/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/repl_wasm/Cargo.toml b/repl_wasm/Cargo.toml index c46ec537fb..9388ead285 100644 --- a/repl_wasm/Cargo.toml +++ b/repl_wasm/Cargo.toml @@ -31,4 +31,5 @@ wasmer = ["futures"] # Tell wasm-pack not to run wasm-opt automatically. We run it explicitly when we need to. # (Workaround for a CI install issue with wasm-pack https://github.com/rustwasm/wasm-pack/issues/864) +[package.metadata.wasm-pack.profile.profiling] wasm-opt = false From 18380b7151687664da047b32db286e3766c234c2 Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Tue, 17 May 2022 08:15:13 +0100 Subject: [PATCH 12/16] Add some CI debug lines --- repl_www/build.sh | 11 ++++++++++- www/netlify.sh | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/repl_www/build.sh b/repl_www/build.sh index 99014dcbe5..9a1fe410bb 100755 --- a/repl_www/build.sh +++ b/repl_www/build.sh @@ -18,13 +18,22 @@ fi WWW_ROOT="${1:-repl_www/public}" mkdir -p $WWW_ROOT +# Debugging build scripts on CI +lsb_release -a +cargo --version +rustc --version +wasm-pack --version +which wasm-opt && wasm-opt --version + +echo $PATH | tr ':' '\n' + # We want a release build, but with debug info (to get stack traces for Wasm backend `todo!()`) # This configuration is called `--profiling` wasm-pack build --profiling --target web repl_wasm -- --features console_error_panic_hook -v cp repl_wasm/pkg/roc_repl_wasm_bg.wasm $WWW_ROOT # To disable optimizations while debugging, run `REPL_DEBUG=1 repl_www/build.sh` -if [ "${REPL_DEBUG:-}" == "" ] +if [ "${REPL_DEBUG:-}" == "" ] && which wasm-opt then wasm-opt -Os --debuginfo repl_wasm/pkg/roc_repl_wasm_bg.wasm -o $WWW_ROOT/roc_repl_wasm_bg.wasm fi diff --git a/www/netlify.sh b/www/netlify.sh index 20ea56bfc0..d973f943e7 100644 --- a/www/netlify.sh +++ b/www/netlify.sh @@ -20,5 +20,7 @@ wget https://github.com/WebAssembly/binaryen/releases/download/version_108/${BIN tar --extract --gzip --file=${BINARYEN_DIRNAME}.tar.gz PATH="$(pwd)/${BINARYEN_DIRNAME}/bin:${PATH}" +echo $PATH | tr ':' '\n' + export PATH bash build.sh From d2fb13668f48b6e69363d1359440c35bb814ddfd Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Tue, 17 May 2022 08:32:53 +0100 Subject: [PATCH 13/16] show rustup for debug --- repl_www/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/repl_www/build.sh b/repl_www/build.sh index 9a1fe410bb..2ba1bcdd00 100755 --- a/repl_www/build.sh +++ b/repl_www/build.sh @@ -22,6 +22,7 @@ mkdir -p $WWW_ROOT lsb_release -a cargo --version rustc --version +rustup show wasm-pack --version which wasm-opt && wasm-opt --version From b54c1e2bc5849043c00e0d56363b65c10cacaf66 Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Tue, 17 May 2022 08:40:29 +0100 Subject: [PATCH 14/16] Copy .js from wasm-bindgen too! --- repl_www/build.sh | 5 ++++- www/build.sh | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/repl_www/build.sh b/repl_www/build.sh index 2ba1bcdd00..be68a157e5 100755 --- a/repl_www/build.sh +++ b/repl_www/build.sh @@ -31,12 +31,15 @@ echo $PATH | tr ':' '\n' # We want a release build, but with debug info (to get stack traces for Wasm backend `todo!()`) # This configuration is called `--profiling` wasm-pack build --profiling --target web repl_wasm -- --features console_error_panic_hook -v -cp repl_wasm/pkg/roc_repl_wasm_bg.wasm $WWW_ROOT +cp -v repl_wasm/pkg/roc_repl_wasm.js $WWW_ROOT # To disable optimizations while debugging, run `REPL_DEBUG=1 repl_www/build.sh` if [ "${REPL_DEBUG:-}" == "" ] && which wasm-opt then wasm-opt -Os --debuginfo repl_wasm/pkg/roc_repl_wasm_bg.wasm -o $WWW_ROOT/roc_repl_wasm_bg.wasm +else + echo "wasm-opt is not installed. Skipping .wasm optimization." + cp -v repl_wasm/pkg/roc_repl_wasm_bg.wasm $WWW_ROOT fi # Copy the JS from wasm_bindgen, replacing its invalid `import` statement with a `var`. diff --git a/www/build.sh b/www/build.sh index 90b1d6f20e..cfc845f998 100755 --- a/www/build.sh +++ b/www/build.sh @@ -36,8 +36,7 @@ mv generated-docs/*.* www/build # move all the .js, .css, etc. files to build/ mv generated-docs/ www/build/builtins # move all the folders to build/builtins/ echo "Building Web REPL..." -repl_www/build.sh -cp -r repl_www/public/* www/build +repl_www/build.sh www/build echo "Asset sizes:" ls -lh www/build/* From 063f7d4a2664f704173d566315cb979f335aefac Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 20 May 2022 12:02:54 +0200 Subject: [PATCH 15/16] Don't ignore warnings, remove fuse-ld arg see https://github.com/rust-lang/cargo/issues/8010 on why I removed RUSTFLAGS="-Awarnings" --- www/build.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/www/build.sh b/www/build.sh index cfc845f998..4ca72c5b26 100755 --- a/www/build.sh +++ b/www/build.sh @@ -21,10 +21,8 @@ echo 'Generating docs...' cargo --version rustc --version -# We set RUSTFLAGS to -Awarnings to ignore warnings during this build, -# because when building without "the" llvm feature (which is only ever done -# for this exact use case), the result is lots of "unused" warnings! -RUSTFLAGS=-Awarnings +# removing `-C link-arg=-fuse-ld=lld` from RUSTFLAGS because this causes an error when compiling `roc_repl_wasm` +RUSTFLAGS="-C target-cpu=native" # We set ROC_DOCS_ROOT_DIR=builtins so that links will be generated relative to # "/builtins/" rather than "/" - which is what we want based on how the server From 1d3078cab3312a12f45911c5567ad1d5007757db Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Fri, 20 May 2022 12:55:33 +0100 Subject: [PATCH 16/16] Remove debug code --- repl_www/build.sh | 10 ---------- www/netlify.sh | 2 -- 2 files changed, 12 deletions(-) diff --git a/repl_www/build.sh b/repl_www/build.sh index be68a157e5..23a8e9a1d5 100755 --- a/repl_www/build.sh +++ b/repl_www/build.sh @@ -18,16 +18,6 @@ fi WWW_ROOT="${1:-repl_www/public}" mkdir -p $WWW_ROOT -# Debugging build scripts on CI -lsb_release -a -cargo --version -rustc --version -rustup show -wasm-pack --version -which wasm-opt && wasm-opt --version - -echo $PATH | tr ':' '\n' - # We want a release build, but with debug info (to get stack traces for Wasm backend `todo!()`) # This configuration is called `--profiling` wasm-pack build --profiling --target web repl_wasm -- --features console_error_panic_hook -v diff --git a/www/netlify.sh b/www/netlify.sh index d973f943e7..20ea56bfc0 100644 --- a/www/netlify.sh +++ b/www/netlify.sh @@ -20,7 +20,5 @@ wget https://github.com/WebAssembly/binaryen/releases/download/version_108/${BIN tar --extract --gzip --file=${BINARYEN_DIRNAME}.tar.gz PATH="$(pwd)/${BINARYEN_DIRNAME}/bin:${PATH}" -echo $PATH | tr ':' '\n' - export PATH bash build.sh