Merge remote-tracking branch 'remote/main' into builtin-task

This commit is contained in:
Luke Boswell 2024-08-26 05:55:55 +10:00
commit 6db429ff17
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
6 changed files with 66 additions and 61 deletions

View file

@ -11,7 +11,7 @@ env:
# use .tar.gz for quick testing # use .tar.gz for quick testing
ARCHIVE_FORMAT: .tar.br ARCHIVE_FORMAT: .tar.br
# Make a new basic-cli git tag and set it here before starting this workflow # Make a new basic-cli git tag and set it here before starting this workflow
RELEASE_TAG: 0.12.0 RELEASE_TAG: 0.14.0
jobs: jobs:
prepare: prepare:
@ -34,14 +34,14 @@ jobs:
fi fi
# get latest nightly releases # get latest nightly releases
- run: curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_x86_64-latest.tar.gz #- run: curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_x86_64-latest.tar.gz
- run: curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_arm64-latest.tar.gz #- run: curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_arm64-latest.tar.gz
- run: curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-macos_x86_64-latest.tar.gz #- run: curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-macos_x86_64-latest.tar.gz
- run: curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-macos_apple_silicon-latest.tar.gz #- run: curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-macos_apple_silicon-latest.tar.gz
#- run: curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_x86_64-TESTING.tar.gz - run: curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_x86_64-TESTING.tar.gz
#- run: curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_arm64-TESTING.tar.gz - run: curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_arm64-TESTING.tar.gz
#- run: curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-macos_x86_64-TESTING.tar.gz - run: curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-macos_x86_64-TESTING.tar.gz
#- run: curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-macos_apple_silicon-TESTING.tar.gz - run: curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-macos_apple_silicon-TESTING.tar.gz
- name: Save roc_nightly archives - name: Save roc_nightly archives
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
@ -60,16 +60,16 @@ jobs:
- name: build basic-cli with surgical linker and also with legacy linker - name: build basic-cli with surgical linker and also with legacy linker
env: env:
CARGO_BUILD_TARGET: x86_64-unknown-linux-musl CARGO_BUILD_TARGET: x86_64-unknown-linux-musl
run: ./ci/build_basic_cli.sh linux_x86_64 "--linker legacy" run: ./ci/build_basic_cli.sh linux_x86_64
- name: Save .rh, .rm and .o file - name: Save .rh, .rm and .a file
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: linux-x86_64-files name: linux-x86_64-files
path: | path: |
basic-cli/platform/metadata_linux-x64.rm basic-cli/platform/metadata_linux-x64.rm
basic-cli/platform/linux-x64.rh basic-cli/platform/linux-x64.rh
basic-cli/platform/linux-x64.o basic-cli/platform/linux-x64.a
build-linux-arm64-files: build-linux-arm64-files:
@ -89,12 +89,12 @@ jobs:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS: "-Clink-self-contained=yes -Clinker=rust-lld" CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS: "-Clink-self-contained=yes -Clinker=rust-lld"
run: ./ci/build_basic_cli.sh linux_arm64 run: ./ci/build_basic_cli.sh linux_arm64
- name: Save .o file - name: Save .a file
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: linux-arm64-files name: linux-arm64-files
path: | path: |
basic-cli/platform/linux-arm64.o basic-cli/platform/linux-arm64.a
build-macos-x86_64-files: build-macos-x86_64-files:
runs-on: [macos-12] # I expect the generated files to work on macOS 12 and up runs-on: [macos-12] # I expect the generated files to work on macOS 12 and up
@ -107,15 +107,15 @@ jobs:
- run: ./ci/build_basic_cli.sh macos_x86_64 - run: ./ci/build_basic_cli.sh macos_x86_64
- name: Save .o files - name: Save .a file
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: macos-x86_64-files name: macos-x86_64-files
path: | path: |
basic-cli/platform/macos-x64.o basic-cli/platform/macos-x64.a
build-macos-apple-silicon-files: build-macos-apple-silicon-files:
name: build apple silicon .o file name: build apple silicon .a file
runs-on: [self-hosted, macOS, ARM64] runs-on: [self-hosted, macOS, ARM64]
needs: [prepare] needs: [prepare]
steps: steps:
@ -126,12 +126,12 @@ jobs:
- run: ./ci/build_basic_cli.sh macos_apple_silicon - run: ./ci/build_basic_cli.sh macos_apple_silicon
- name: Save macos-arm64.o file - name: Save macos-arm64.a file
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: macos-apple-silicon-files name: macos-apple-silicon-files
path: | path: |
basic-cli/platform/macos-arm64.o basic-cli/platform/macos-arm64.a
create-release-archive: create-release-archive:
needs: [build-linux-x86_64-files, build-linux-arm64-files, build-macos-x86_64-files, build-macos-apple-silicon-files] needs: [build-linux-x86_64-files, build-linux-arm64-files, build-macos-x86_64-files, build-macos-apple-silicon-files]
@ -250,10 +250,11 @@ jobs:
git checkout ${{ env.RELEASE_TAG }} git checkout ${{ env.RELEASE_TAG }}
cp -r examples ../.. cp -r examples ../..
cp -r ci ../.. cp -r ci ../..
cp -r LICENSE ../..
# LICENSE is necessary for command test # LICENSE is necessary for command test
cp -r LICENSE ../..
- name: run tests - name: run tests
run: | run: |
cd basic-cli-platform cd basic-cli-platform
ROC=./roc_nightly/roc EXAMPLES_DIR=./examples/ ROC_BUILD_FLAGS=--prebuilt-platform ./ci/all_tests.sh # no need to build platform anymore
NO_BUILD=1 ROC=./roc_nightly/roc EXAMPLES_DIR=./examples/ ./ci/all_tests.sh

View file

@ -10,7 +10,7 @@ concurrency:
env: env:
# use .tar.gz for quick testing # use .tar.gz for quick testing
ARCHIVE_FORMAT: .tar.br ARCHIVE_FORMAT: .tar.br
BASIC_WEBSERVER_BRANCH: main RELEASE_TAG: 0.8.0
jobs: jobs:
fetch-releases: fetch-releases:
@ -46,16 +46,16 @@ jobs:
- name: build basic-webserver with legacy linker - name: build basic-webserver with legacy linker
env: env:
CARGO_BUILD_TARGET: x86_64-unknown-linux-musl CARGO_BUILD_TARGET: x86_64-unknown-linux-musl
run: ./ci/build_basic_webserver.sh linux_x86_64 "--linker legacy" run: ./ci/build_basic_webserver.sh linux_x86_64
- name: Save .rh, .rm and .o file - name: Save .rh, .rm and .a file
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: linux-x86_64-files name: linux-x86_64-files
path: | path: |
basic-webserver/platform/metadata_linux-x64.rm basic-webserver/platform/metadata_linux-x64.rm
basic-webserver/platform/linux-x64.rh basic-webserver/platform/linux-x64.rh
basic-webserver/platform/linux-x64.o basic-webserver/platform/linux-x64.a
build-linux-arm64-files: build-linux-arm64-files:
@ -75,12 +75,12 @@ jobs:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS: "-Clink-self-contained=yes -Clinker=rust-lld" CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS: "-Clink-self-contained=yes -Clinker=rust-lld"
run: ./ci/build_basic_webserver.sh linux_arm64 run: ./ci/build_basic_webserver.sh linux_arm64
- name: Save .o file - name: Save .a file
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: linux-arm64-files name: linux-arm64-files
path: | path: |
basic-webserver/platform/linux-arm64.o basic-webserver/platform/linux-arm64.a
build-macos-x86_64-files: build-macos-x86_64-files:
runs-on: [macos-12] # I expect the generated files to work on macOS 12 and up runs-on: [macos-12] # I expect the generated files to work on macOS 12 and up
@ -93,15 +93,15 @@ jobs:
- run: ./ci/build_basic_webserver.sh macos_x86_64 - run: ./ci/build_basic_webserver.sh macos_x86_64
- name: Save .o files - name: Save .a files
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: macos-x86_64-files name: macos-x86_64-files
path: | path: |
basic-webserver/platform/macos-x64.o basic-webserver/platform/macos-x64.a
build-macos-apple-silicon-files: build-macos-apple-silicon-files:
name: build apple silicon .o file name: build apple silicon .a file
runs-on: [self-hosted, macOS, ARM64] runs-on: [self-hosted, macOS, ARM64]
needs: [fetch-releases] needs: [fetch-releases]
steps: steps:
@ -112,12 +112,12 @@ jobs:
- run: ./ci/build_basic_webserver.sh macos_apple_silicon - run: ./ci/build_basic_webserver.sh macos_apple_silicon
- name: Save macos-arm64.o file - name: Save macos-arm64.a file
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: macos-apple-silicon-files name: macos-apple-silicon-files
path: | path: |
basic-webserver/platform/macos-arm64.o basic-webserver/platform/macos-arm64.a
create-release-archive: create-release-archive:
needs: [build-linux-x86_64-files, build-linux-arm64-files, build-macos-x86_64-files, build-macos-apple-silicon-files] needs: [build-linux-x86_64-files, build-linux-arm64-files, build-macos-x86_64-files, build-macos-apple-silicon-files]
@ -147,7 +147,7 @@ jobs:
- run: | - run: |
git clone https://github.com/roc-lang/basic-webserver.git git clone https://github.com/roc-lang/basic-webserver.git
cd basic-webserver cd basic-webserver
git checkout ${{ env.BASIC_WEBSERVER_BRANCH }} git checkout ${{ env.RELEASE_TAG }}
cd .. cd ..
- run: cp macos-apple-silicon-files/* ./basic-webserver/platform - run: cp macos-apple-silicon-files/* ./basic-webserver/platform

View file

@ -37,16 +37,23 @@ rm roc_nightly.tar.gz
mv roc_nightly* roc_nightly mv roc_nightly* roc_nightly
cd roc_nightly cd roc_nightly
export PATH="$(pwd -P):$PATH"
cd ..
# temp test
roc version
cd basic-cli
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if [[ $(uname -m) == "aarch64" ]]; then
target_arch="aarch64-unknown-linux-musl"
else
target_arch="x86_64-unknown-linux-musl"
fi
fi
./jump-start.sh
# build the basic cli platform # build the basic cli platform
./roc build ../basic-cli/examples/countdown.roc --optimize roc build.roc --prebuilt-platform
# We need this extra variable so we can safely check if $2 is empty later
EXTRA_ARGS=${2:-}
# In some rare cases it's nice to be able to use the legacy linker, so we produce the .o file to be able to do that
if [ -n "${EXTRA_ARGS}" ];
then ./roc build $EXTRA_ARGS ../basic-cli/examples/countdown.roc --optimize
fi
cd .. cd ..

View file

@ -4,6 +4,9 @@
set -euxo pipefail set -euxo pipefail
git clone https://github.com/roc-lang/basic-webserver.git git clone https://github.com/roc-lang/basic-webserver.git
cd basic-webserver
git checkout $RELEASE_TAG
cd ..
OS=$(uname -s) OS=$(uname -s)
ARCH=$(uname -m) ARCH=$(uname -m)
@ -37,20 +40,13 @@ rm roc_nightly.tar.gz
# simplify dir name # simplify dir name
mv roc_nightly* roc_nightly mv roc_nightly* roc_nightly
# add roc to PATH
cd roc_nightly cd roc_nightly
export PATH="$(pwd -P):$PATH"
cd ..
# prevent https://github.com/roc-lang/basic-webserver/issues/9 cd basic-webserver
if [ "$OS" != "Linux" ] || [ "$ARCH" != "x86_64" ]; then
# build the basic-webserver platform
./roc build ../basic-webserver/examples/echo.roc --optimize
fi
# We need this extra variable so we can safely check if $2 is empty later roc build.roc --prebuilt-platform
EXTRA_ARGS=${2:-}
# In some rare cases it's nice to be able to use the legacy linker, so we produce the .o file to be able to do that
if [ -n "${EXTRA_ARGS}" ];
then ./roc build $EXTRA_ARGS ../basic-webserver/examples/echo.roc --optimize
fi
cd .. cd ..

View file

@ -404,7 +404,8 @@ impl<'ctx> RocUnion<'ctx> {
let mut width = self.data_width; let mut width = self.data_width;
// add padding between data and the tag id // add padding between data and the tag id
width = round_up_to_alignment(width, tag_id_width); let tag_id_alignment = tag_id_width.max(1);
width = round_up_to_alignment(width, tag_id_alignment);
// add tag id // add tag id
width += tag_id_width; width += tag_id_width;

View file

@ -1027,7 +1027,7 @@ impl<'a> UnionLayout<'a> {
tags.iter() tags.iter()
.map(|field_layouts| LayoutRepr::struct_(field_layouts).alignment_bytes(interner)) .map(|field_layouts| LayoutRepr::struct_(field_layouts).alignment_bytes(interner))
.max() .max()
.unwrap_or(0) .unwrap_or(1)
} }
pub fn allocation_alignment_bytes<I>(&self, interner: &I) -> u32 pub fn allocation_alignment_bytes<I>(&self, interner: &I) -> u32
@ -1196,8 +1196,8 @@ impl Discriminant {
} }
} }
pub const fn alignment_bytes(&self) -> u32 { pub fn alignment_bytes(&self) -> u32 {
self.stack_size() self.stack_size().max(1)
} }
pub const fn layout(&self) -> InLayout<'static> { pub const fn layout(&self) -> InLayout<'static> {
@ -2381,9 +2381,9 @@ impl<'a, 'b> Env<'a, 'b> {
} }
} }
pub const fn round_up_to_alignment(width: u32, alignment: u32) -> u32 { pub fn round_up_to_alignment(width: u32, alignment: u32) -> u32 {
match alignment { match alignment {
0 => width, 0 => panic!("Alignment invalid: Got 0, but alignment must be at least 1"),
1 => width, 1 => width,
_ => { _ => {
if width % alignment > 0 { if width % alignment > 0 {
@ -2770,7 +2770,7 @@ impl<'a> LayoutRepr<'a> {
.iter() .iter()
.map(|x| interner.get_repr(*x).alignment_bytes(interner)) .map(|x| interner.get_repr(*x).alignment_bytes(interner))
.max() .max()
.unwrap_or(0), .unwrap_or(1),
Union(variant) => { Union(variant) => {
use UnionLayout::*; use UnionLayout::*;