From 17960d1154d0682b5f41fdeff2a6594d20ce07b1 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:17:21 +0100 Subject: [PATCH] fix nightly testing + updates --- .github/workflows/ci_manager.yml | 2 +- .github/workflows/nightly_linux_x86_64.yml | 2 +- ci/package_release.sh | 11 +++++-- crates/cli/tests/cli_tests.rs | 2 +- crates/packaging/src/cache.rs | 2 +- devtools/debug_tips.md | 6 ++-- examples/platform-switching/README.md | 14 +++------ examples/platform-switching/main.roc | 3 -- examples/platform-switching/rocLovesC.roc | 6 +++- examples/platform-switching/rocLovesZig.roc | 7 ++++- www/content/install/linux_x86_64.md | 33 ++------------------- www/content/install/macos_apple_silicon.md | 22 ++------------ www/content/install/macos_x86_64.md | 23 ++------------ www/content/install/other.md | 10 ++----- 14 files changed, 39 insertions(+), 104 deletions(-) delete mode 100644 examples/platform-switching/main.roc diff --git a/.github/workflows/ci_manager.yml b/.github/workflows/ci_manager.yml index eefe41b9e6b..724a5498db4 100644 --- a/.github/workflows/ci_manager.yml +++ b/.github/workflows/ci_manager.yml @@ -1,5 +1,5 @@ on: - pull_request: +# pull_request: name: CI manager diff --git a/.github/workflows/nightly_linux_x86_64.yml b/.github/workflows/nightly_linux_x86_64.yml index 577d43392f8..e184d14e749 100644 --- a/.github/workflows/nightly_linux_x86_64.yml +++ b/.github/workflows/nightly_linux_x86_64.yml @@ -1,5 +1,5 @@ on: - #pull_request: + pull_request: workflow_dispatch: schedule: - cron: "0 9 * * *" diff --git a/ci/package_release.sh b/ci/package_release.sh index 2928ab60dc3..35fefd6a6a8 100755 --- a/ci/package_release.sh +++ b/ci/package_release.sh @@ -7,14 +7,19 @@ set -euxo pipefail strip ./target/release-with-lto/roc strip ./target/release-with-lto/roc_language_server -mkdir -p $1 $1/examples $1/crates/compiler/builtins/bitcode +mkdir -p $1 $1/examples mv target/release-with-lto/{roc,roc_language_server,lib} $1 mv LICENSE LEGAL_DETAILS $1 mv examples/platform-switching $1/examples -mv crates/roc_std $1/crates -mv crates/compiler/builtins/bitcode/src $1/crates/compiler/builtins/bitcode +# temporary github.com/roc-lang/roc/pull/7231 +rm $1/examples/platform-switching/rocLovesRust.roc +rm -rf $1/examples/platform-switching/rust-platform + +# copy zig builtins +mkdir $1/examples/platform-switching/zig-platform/glue +mv crates/compiler/builtins/bitcode/src/* $1/examples/platform-switching/zig-platform/glue tar -czvf "$1.tar.gz" $1 diff --git a/crates/cli/tests/cli_tests.rs b/crates/cli/tests/cli_tests.rs index 434b6ef4d87..cb000510d53 100644 --- a/crates/cli/tests/cli_tests.rs +++ b/crates/cli/tests/cli_tests.rs @@ -50,7 +50,7 @@ mod cli_tests { const TEST_LEGACY_LINKER: bool = false; #[test] - #[ignore = "Works when run manually, but not in CI"] + #[ignore = "Needs investigation, see also github.com/roc-lang/roc/pull/7231"] fn platform_switching_rust() { // pre-build the platform std::process::Command::new("bash") diff --git a/crates/packaging/src/cache.rs b/crates/packaging/src/cache.rs index d819cece5a0..b412e383c22 100644 --- a/crates/packaging/src/cache.rs +++ b/crates/packaging/src/cache.rs @@ -54,7 +54,7 @@ fn nixos_error_if_dynamic(url: &str, dest_dir: &Path) { Dynamically linked platforms can't be used on NixOS.\n\n\ You can:\n\n\t\ - Download the source of the platform and build it locally, like in this example:\n\t \ - https://github.com/roc-lang/roc/blob/main/examples/platform-switching/rocLovesRust.roc.\n\t \ + https://github.com/roc-lang/roc/blob/main/examples/platform-switching/rocLovesC.roc.\n\t \ For some graphical platforms you may need to use https://github.com/guibou/nixGL.\n\n\t\ - Contact the author of the platform to ask them to statically link their platform.\n\t \ musl can be used to prevent a dynamic dependency on the systems' libc.\n\t \ diff --git a/devtools/debug_tips.md b/devtools/debug_tips.md index 8677952ed14..c5bca5a1509 100644 --- a/devtools/debug_tips.md +++ b/devtools/debug_tips.md @@ -61,7 +61,7 @@ $ source <(cargo llvm-cov show-env --export-prefix) $ cargo llvm-cov clean --workspace $ cargo build --bin roc # Replace with the command you want to generate coverage for: -$ ./target/debug/roc build ./examples/platform-switching/rocLovesRust.roc +$ ./target/debug/roc build yourFile.roc # To view in editor $ cargo llvm-cov report --lcov --output-path lcov.info # To view in browser. This html report also allows you to see how many times each line of code was run. @@ -71,7 +71,7 @@ Viewing lcov.info will depend on your editor. For vscode, you can use the [cover ## Trace all Function Calls -[uftrace](https://github.com/namhyung/uftrace) allows you to trace all functions that were called in the compiler in order. For example, you can use it with `./target/debug/roc build examples/platform-switching/rocLovesRust.roc`. The output looks like this: +[uftrace](https://github.com/namhyung/uftrace) allows you to trace all functions that were called in the compiler in order. For example, you can use it with `./target/debug/roc build yourFile.roc`. The output looks like this: ``` roc::main() { roc_tracing::setup_tracing(); @@ -92,7 +92,7 @@ It can be valuable if you want to compare two compiler versions/commits and see 2. In the roc repo in rust-toolchain.toml, switch to the commented out nightly channel 3. `export RUSTFLAGS="-Awarnings -Z instrument-mcount -C passes=ee-instrument"` 4. `cargo build --bin roc` -5. Example usage: `uftrace record --filter 'roc_*' ./target/debug/roc build examples/platform-switching/rocLovesRust.roc` +5. Example usage: `uftrace record --filter 'roc_*' ./target/debug/roc build yourFile.roc` 6. Show the trace and drop all functions that do not start with `roc`: `uftrace replay -f none --notrace '^[^r]|^r[^o]|^ro[^c]' -D 5`. `-D 5` sets the function call depth, feel free to modify it to best suit your purpose. Depending on which functions you are interested in, you may also want to set `let threads = Threads::Single;` in the function `load` in `crates/compiler/load_internal/src/file.rs`. That avoids function calls from being obscured between multiple threads. diff --git a/examples/platform-switching/README.md b/examples/platform-switching/README.md index 1db17157f8f..981b49eb943 100644 --- a/examples/platform-switching/README.md +++ b/examples/platform-switching/README.md @@ -1,20 +1,14 @@ + # Platform switching To run, `cd` into this directory and run this in your terminal: ```bash -roc run +roc --build-host --suppress-build-host-warning rocLovesC.roc ``` -This will run `main.roc` because, unless you explicitly give it a filename, `roc run` -defaults to running a file named `main.roc`. Other `roc` commands (like `roc build`, `roc test`, and so on) also default to `main.roc` unless you explicitly give them a filename. - -## About this example - -This uses a very simple platform which does nothing more than printing the string you give it. - -The line `main = "Which platform am I running on now?\n"` sets this string to be `"Which platform am I running on now?"` with a newline at the end, and the lines `packages { pf: "c-platform/main.roc" }` and `provides [main] to pf` specify that the `c-platform/` directory contains this app's platform. +## About these examples -This platform is called `c-platform` because its lower-level code is written in C. There's also a `rust-platform`, `zig-platform`, and so on; if you like, you can try switching `pf: "c-platform/main.roc"` to `pf: "zig-platform/main.roc"` or `pf: "rust-platform/main.roc"` to try one of those platforms instead. They all do similar things, so the application won't look any different. +They use a very simple [platform](https://www.roc-lang.org/platforms) which does nothing more than printing the string you give it. If you want to start building your own platforms, these are some very simple example platforms to use as starting points. diff --git a/examples/platform-switching/main.roc b/examples/platform-switching/main.roc deleted file mode 100644 index d33bf330bc7..00000000000 --- a/examples/platform-switching/main.roc +++ /dev/null @@ -1,3 +0,0 @@ -app [main] { pf: platform "c-platform/main.roc" } - -main = "Which platform am I running on now?\n" diff --git a/examples/platform-switching/rocLovesC.roc b/examples/platform-switching/rocLovesC.roc index 94636868d32..70be654a368 100644 --- a/examples/platform-switching/rocLovesC.roc +++ b/examples/platform-switching/rocLovesC.roc @@ -1,5 +1,9 @@ app [main] { pf: platform "c-platform/main.roc" } -# run with `roc --build-host --suppress-build-host-warning rocLovesZig.roc` +# may require: +# ubuntu: sudo apt install build-essential clang +# fedora: sudo dnf install clang + +# run with `roc --build-host --suppress-build-host-warning rocLovesC.roc` main = "Roc <3 C!\n" diff --git a/examples/platform-switching/rocLovesZig.roc b/examples/platform-switching/rocLovesZig.roc index 28b9fd4f268..448a14b8f91 100644 --- a/examples/platform-switching/rocLovesZig.roc +++ b/examples/platform-switching/rocLovesZig.roc @@ -1,5 +1,10 @@ app [main] { pf: platform "zig-platform/main.roc" } -# run with `roc --build-host --suppress-build-host-warning rocLovesZig.roc` +# To run: +# cd examples/platform-switching/zig-platform +# mkdir glue +# cp crates/compiler/builtins/bitcode/src/* ./glue +# cd - +# roc --build-host --suppress-build-host-warning rocLovesZig.roc main = "Roc <3 Zig!\n" diff --git a/www/content/install/linux_x86_64.md b/www/content/install/linux_x86_64.md index d37d77d9700..145ac709896 100644 --- a/www/content/install/linux_x86_64.md +++ b/www/content/install/linux_x86_64.md @@ -22,7 +22,7 @@ which includes the Roc compiler and some helpful utilities. 1. Check everything worked by executing `roc version` -1. Install libc development files and ld (binutils) if you'd like to use the repl (`roc repl`): +1. If you'd like to use the repl (`roc repl`); install libc development files and ld (binutils) : - On Ubuntu/Debian: ```sh @@ -41,37 +41,10 @@ which includes the Roc compiler and some helpful utilities. sudo dnf install glibc-devel binutils ``` -## How to install Roc platform dependencies - -This step is not necessary if you only want to use the [basic-cli platform](https://github.com/roc-lang/basic-cli), like in the tutorial. -But, if you want to compile Roc apps with other platforms (either in [`examples/`](https://github.com/roc-lang/roc/tree/main/examples) or in your own projects), -you'll need to install one or more of these platform languages too. - -1. Install the Rust compiler, for apps with Rust-based platforms: - - ```sh - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - ``` - -1. For Zig-based platforms: [download zig 0.13.0](https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz), extract the archive and add export PATH=$PATH:~/path/to/zig to your shell startup script (.profile, .zshrc, …). - -1. Install a C compiler, for apps with C-based platforms: +1. Run [hello world](https://github.com/roc-lang/examples/blob/main/examples/HelloWorld/main.roc): ```sh - # On a Debian-based distro like Ubuntu - sudo apt update && sudo apt install build-essential clang - - # On an RPM-based distro like Fedora - sudo dnf check-update && sudo dnf install clang - ``` - - ```sh - # Note: If you installed Rust in this terminal session, you'll need to open a new one first! - ./roc examples/platform-switching/rocLovesRust.roc - - ./roc examples/platform-switching/rocLovesZig.roc - - ./roc examples/platform-switching/rocLovesC.roc + roc hello.roc ``` ## Next Steps diff --git a/www/content/install/macos_apple_silicon.md b/www/content/install/macos_apple_silicon.md index 71fed371949..c464edde16b 100644 --- a/www/content/install/macos_apple_silicon.md +++ b/www/content/install/macos_apple_silicon.md @@ -32,29 +32,11 @@ which includes the Roc compiler and some helpful utilities. 1. Check everything worked by executing `roc version` -## How to install Roc platform dependencies -This step is not necessary if you only want to use the [basic-cli platform](https://github.com/roc-lang/basic-cli), like in the tutorial. -But, if you want to compile Roc apps with other platforms (either in [`examples/`](https://github.com/roc-lang/roc/tree/main/examples) or in your own projects), -you'll need to install one or more of these platform languages too. - -1. Install the Rust compiler, for apps with Rust-based platforms: - - ```sh - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - ``` - -1. If you'd like to use Zig-based platforms: download [zig 0.13.0](https://ziglang.org/download/0.13.0/zig-macos-aarch64-0.13.0.tar.xz), extract the archive and add `export PATH=$PATH:~/path/to/zig` to your shell startup script (.profile, .zshrc, …). Note: zig 0.13.0 is currently available on homebrew, but future update may remove it. - -1. Run examples: +1. Run [hello world](https://github.com/roc-lang/examples/blob/main/examples/HelloWorld/main.roc): ```sh - # Note: If you installed rust in this terminal session, you'll need to open a new one first! - ./roc examples/platform-switching/rocLovesRust.roc - - ./roc examples/platform-switching/rocLovesZig.roc - - ./roc examples/platform-switching/rocLovesC.roc + roc hello.roc ``` ## Next Steps diff --git a/www/content/install/macos_x86_64.md b/www/content/install/macos_x86_64.md index 71a56ef9597..89e67c45d94 100644 --- a/www/content/install/macos_x86_64.md +++ b/www/content/install/macos_x86_64.md @@ -26,29 +26,10 @@ which includes the Roc compiler and some helpful utilities. 1. Check everything worked by executing `roc version` -## How to install Roc platform dependencies - -This step is not necessary if you only want to use the [basic-cli platform](https://github.com/roc-lang/basic-cli), like in the tutorial. -But, if you want to compile Roc apps with other platforms (either in [`examples/`](https://github.com/roc-lang/roc/tree/main/examples) or in your own projects), -you'll need to install one or more of these platform languages too. - -1. Install the Rust compiler, for apps with Rust-based platforms: +1. Run [hello world](https://github.com/roc-lang/examples/blob/main/examples/HelloWorld/main.roc): ```sh - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - ``` - -1. If you'd like to use Zig-based platforms: download [zig 0.13.0](https://ziglang.org/download/0.13.0/zig-macos-x86_64-0.13.0.tar.xz), extract the archive and add `export PATH=$PATH:~/path/to/zig` to your shell startup script (.profile, .zshrc, …). Note: zig 0.13.0 is not available on homebrew. - -1. Run examples: - - ```sh - # Note: If you installed rust in this terminal session, you'll need to open a new one first! - ./roc examples/platform-switching/rocLovesRust.roc - - ./roc examples/platform-switching/rocLovesZig.roc - - ./roc examples/platform-switching/rocLovesC.roc + roc hello.roc ``` ## Next Steps diff --git a/www/content/install/other.md b/www/content/install/other.md index 6b590ed29c0..360d2286f8a 100644 --- a/www/content/install/other.md +++ b/www/content/install/other.md @@ -4,16 +4,10 @@ 1. [Build Roc from source](https://github.com/roc-lang/roc/blob/main/BUILDING_FROM_SOURCE.md) -1. Run examples: +1. Run [hello world](https://github.com/roc-lang/examples/blob/main/examples/HelloWorld/main.roc): ```sh - cargo run examples/platform-switching/rocLovesRust.roc - - # This requires installing the Zig compiler, too. - cargo run examples/platform-switching/rocLovesZig.roc - - # This requires installing the `clang` C compiler, too. - cargo run examples/platform-switching/rocLovesC.roc + roc hello.roc ``` ## Next Steps