Skip to content

Commit

Permalink
fix nightly testing + updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton-4 authored Dec 17, 2024
1 parent ef2f813 commit 17960d1
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_manager.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
on:
pull_request:
# pull_request:

name: CI manager

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly_linux_x86_64.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
on:
#pull_request:
pull_request:
workflow_dispatch:
schedule:
- cron: "0 9 * * *"
Expand Down
11 changes: 8 additions & 3 deletions ci/package_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion crates/cli/tests/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion crates/packaging/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
6 changes: 3 additions & 3 deletions devtools/debug_tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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();
Expand All @@ -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<post-inline>"`
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.
Expand Down
14 changes: 4 additions & 10 deletions examples/platform-switching/README.md
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 0 additions & 3 deletions examples/platform-switching/main.roc

This file was deleted.

6 changes: 5 additions & 1 deletion examples/platform-switching/rocLovesC.roc
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 6 additions & 1 deletion examples/platform-switching/rocLovesZig.roc
Original file line number Diff line number Diff line change
@@ -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"
33 changes: 3 additions & 30 deletions www/content/install/linux_x86_64.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
22 changes: 2 additions & 20 deletions www/content/install/macos_apple_silicon.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 2 additions & 21 deletions www/content/install/macos_x86_64.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 2 additions & 8 deletions www/content/install/other.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 17960d1

Please sign in to comment.