Skip to content
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
68 changes: 68 additions & 0 deletions .github/actions/setup-deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: 'Setup various CI dependencies'
inputs:
target:
description: 'rust target being set up'
required: true
wasi_sdk:
description: 'wasi-sdk version to install'
default: 27
wasmtime:
description: 'wasmtime version to install'
default: dev

runs:
using: composite
steps:
- uses: dtolnay/rust-toolchain@stable
with:
target: ${{ inputs.target }}
- run: echo "CARGO_BUILD_TARGET=${{ matrix.target }}" >> $GITHUB_ENV
shell: bash

- name: Install GCC (i686-unknown-linux-gnu)
if: ${{ inputs.target == 'i686-unknown-linux-gnu' }}
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends gcc-multilib
shell: bash
- name: Install GCC (aarch64-unknown-linux-gnu)
if: ${{ inputs.target == 'aarch64-unknown-linux-gnu' }}
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends gcc-aarch64-linux-gnu libc6-dev-arm64-cross
shell: bash
- name: Install GCC (arm-unknown-linux-gnueabi)
if: ${{ inputs.target == 'arm-unknown-linux-gnueabi' }}
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends gcc-arm-linux-gnueabi libc6-dev-armel-cross
shell: bash
- name: Install GCC (x86_64-pc-windows-gnu)
if: ${{ inputs.target == 'x86_64-pc-windows-gnu' }}
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends gcc-mingw-w64-x86-64
shell: bash
- name: Install emscripten (wasm32-unknown-emscripten)
if: ${{ inputs.target == 'wasm32-unknown-emscripten' }}
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends emscripten
shell: bash

- name: Install wasi-sdk/Wasmtime (wasm32-wasip2)
if: ${{ inputs.target == 'wasm32-wasip2' }}
working-directory: ${{ runner.tool_cache }}
run: |
curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${{ inputs.wasi_sdk }}/wasi-sdk-${{ inputs.wasi_sdk }}.0-x86_64-linux.tar.gz
tar xf wasi-sdk-${{ inputs.wasi_sdk }}.0-x86_64-linux.tar.gz
WASI_SDK_PATH=`pwd`/wasi-sdk-${{ inputs.wasi_sdk }}.0-x86_64-linux
echo "WASI_SDK_PATH=$WASI_SDK_PATH" >> $GITHUB_ENV
echo "CC_wasm32_wasip2=$WASI_SDK_PATH/bin/clang" >> $GITHUB_ENV
echo "CARGO_TARGET_WASM32_WASIP2_LINKER=$WASI_SDK_PATH/bin/clang" >> $GITHUB_ENV
echo "CARGO_TARGET_WASM32_WASIP2_RUSTFLAGS=-Clink-arg=-Wl,--export=cabi_realloc" >> $GITHUB_ENV
curl -LO https://github.com/bytecodealliance/wasmtime/releases/download/${{ inputs.wasmtime }}/wasmtime-${{ inputs.wasmtime }}-x86_64-linux.tar.xz
tar xf wasmtime-${{ inputs.wasmtime }}-x86_64-linux.tar.xz
echo "CARGO_TARGET_WASM32_WASIP2_RUNNER=`pwd`/wasmtime-${{ inputs.wasmtime }}-x86_64-linux/wasmtime -W exceptions" >> $GITHUB_ENV
shell: bash
75 changes: 15 additions & 60 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- x86_64-pc-windows-gnu
- x86_64-pc-windows-msvc
- wasm32-unknown-emscripten
- wasm32-wasip2
lua: [lua54, lua53, lua52, lua51]
include:
- target: x86_64-unknown-linux-gnu
Expand All @@ -37,44 +38,16 @@ jobs:
os: windows-latest
- target: wasm32-unknown-emscripten
os: ubuntu-latest
- target: wasm32-wasip2
os: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: dtolnay/rust-toolchain@stable
- uses: ./.github/actions/setup-deps
with:
target: ${{ matrix.target }}
- name: Install GCC (i686-unknown-linux-gnu)
if: ${{ matrix.target == 'i686-unknown-linux-gnu' }}
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends gcc-multilib
shell: bash
- name: Install GCC (aarch64-unknown-linux-gnu)
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends gcc-aarch64-linux-gnu libc6-dev-arm64-cross
shell: bash
- name: Install GCC (arm-unknown-linux-gnueabi)
if: ${{ matrix.target == 'arm-unknown-linux-gnueabi' }}
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends gcc-arm-linux-gnueabi libc6-dev-armel-cross
shell: bash
- name: Install GCC (x86_64-pc-windows-gnu)
if: ${{ matrix.target == 'x86_64-pc-windows-gnu' }}
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends gcc-mingw-w64-x86-64
shell: bash
- name: Install emscripten (wasm32-unknown-emscripten)
if: ${{ matrix.target == 'wasm32-unknown-emscripten' }}
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends emscripten
shell: bash
- name: Build ${{ matrix.lua }}
run: |
cargo build --manifest-path testcrate/Cargo.toml --target ${{ matrix.target }} --release --features ${{ matrix.lua }}
cargo build --manifest-path testcrate/Cargo.toml --release --features ${{ matrix.lua }}
shell: bash

test:
Expand All @@ -83,7 +56,11 @@ jobs:
needs: build
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
target:
- x86_64-unknown-linux-gnu
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
- wasm32-wasip2
lua: [lua54, lua53, lua52, lua51]
include:
- os: ubuntu-latest
Expand All @@ -92,9 +69,11 @@ jobs:
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: ubuntu-latest
target: wasm32-wasip2
steps:
- uses: actions/checkout@main
- uses: dtolnay/rust-toolchain@stable
- uses: ./.github/actions/setup-deps
with:
target: ${{ matrix.target }}
- name: Run ${{ matrix.lua }} tests
Expand All @@ -103,12 +82,11 @@ jobs:
shell: bash

test_standalone:
name: Test
name: Test Standalone
runs-on: ${{ matrix.os }}
needs: build
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
Expand All @@ -118,36 +96,13 @@ jobs:
target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@main
- uses: dtolnay/rust-toolchain@stable
- uses: ./.github/actions/setup-deps
with:
target: ${{ matrix.target }}
- name: Run standalone tests
run: |
cargo test
test_emscripten:
name: Test emscripten
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
lua: [lua54, lua53, lua52, lua51]
steps:
- uses: actions/checkout@main
- uses: dtolnay/rust-toolchain@stable
with:
target: wasm32-unknown-emscripten
- name: Install emscripten
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends emscripten
shell: bash
- name: Run ${{ matrix.lua }} tests
run: |
export CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER=node
cargo test --manifest-path testcrate/Cargo.toml --release --features ${{ matrix.lua }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the command mentioned in the PR description that's missing --target so this was actually testing a native build instead of Emscripten. The Emscripten failures look like this and I'm not knowledgable enough about Emscripten to know what the error there is or how to fix it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, good catch, I'll take a look to this

shell: bash

rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions lua-5.1.5/liolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,13 @@ static int io_popen (lua_State *L) {


static int io_tmpfile (lua_State *L) {
#if !defined(__wasi__)
FILE **pf = newfile(L);
*pf = tmpfile();
return (*pf == NULL) ? pushresult(L, 0, NULL) : 1;
#else
luaL_error(L, "not supported on WASI");
#endif
}


Expand Down
12 changes: 12 additions & 0 deletions lua-5.1.5/loslib.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ static int os_pushresult (lua_State *L, int i, const char *filename) {


static int os_execute (lua_State *L) {
#if !defined(__wasi__)
lua_pushinteger(L, system(luaL_optstring(L, 1, NULL)));
return 1;
#else
luaL_error(L, "not supported on WASI");
#endif
}


Expand All @@ -55,13 +59,17 @@ static int os_rename (lua_State *L) {


static int os_tmpname (lua_State *L) {
#if !defined(__wasi__)
char buff[LUA_TMPNAMBUFSIZE];
int err;
lua_tmpnam(buff, err);
if (err)
return luaL_error(L, "unable to generate a unique filename");
lua_pushstring(L, buff);
return 1;
#else
luaL_error(L, "not supported on WASI");
#endif
}


Expand All @@ -72,8 +80,12 @@ static int os_getenv (lua_State *L) {


static int os_clock (lua_State *L) {
#if !defined(__wasi__)
lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC);
return 1;
#else
luaL_error(L, "not supported on WASI");
#endif
}


Expand Down
2 changes: 2 additions & 0 deletions lua-5.1.5/luaconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
#if defined(LUA_USE_POSIX)
#define LUA_USE_MKSTEMP
#define LUA_USE_ISATTY
#if !defined(__wasi__)
#define LUA_USE_POPEN
#endif
#define LUA_USE_ULONGJMP
#endif

Expand Down
2 changes: 1 addition & 1 deletion lua-5.2.4/lauxlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) {

#if !defined(inspectstat) /* { */

#if defined(LUA_USE_POSIX)
#if defined(LUA_USE_POSIX) && !defined(__wasi__)

#include <sys/wait.h>

Expand Down
4 changes: 4 additions & 0 deletions lua-5.2.4/liolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,13 @@ static int io_popen (lua_State *L) {


static int io_tmpfile (lua_State *L) {
#if !defined(__wasi__)
LStream *p = newfile(L);
p->f = tmpfile();
return (p->f == NULL) ? luaL_fileresult(L, 0, NULL) : 1;
#else
luaL_error(L, "not supported on WASI");
#endif
}


Expand Down
12 changes: 12 additions & 0 deletions lua-5.2.4/loslib.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@


static int os_execute (lua_State *L) {
#if !defined(__wasi__)
const char *cmd = luaL_optstring(L, 1, NULL);
int stat = system(cmd);
if (cmd != NULL)
Expand All @@ -86,6 +87,9 @@ static int os_execute (lua_State *L) {
lua_pushboolean(L, stat); /* true if there is a shell */
return 1;
}
#else
luaL_error(L, "not supported on WASI");
#endif
}


Expand All @@ -103,13 +107,17 @@ static int os_rename (lua_State *L) {


static int os_tmpname (lua_State *L) {
#if !defined(__wasi__)
char buff[LUA_TMPNAMBUFSIZE];
int err;
lua_tmpnam(buff, err);
if (err)
return luaL_error(L, "unable to generate a unique filename");
lua_pushstring(L, buff);
return 1;
#else
luaL_error(L, "not supported on WASI");
#endif
}


Expand All @@ -120,8 +128,12 @@ static int os_getenv (lua_State *L) {


static int os_clock (lua_State *L) {
#if !defined(__wasi__)
lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC);
return 1;
#else
luaL_error(L, "not supported on WASI");
#endif
}


Expand Down
2 changes: 2 additions & 0 deletions lua-5.2.4/luaconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@
#if defined(LUA_USE_POSIX)
#define LUA_USE_MKSTEMP
#define LUA_USE_ISATTY
#if !defined(__wasi__)
#define LUA_USE_POPEN
#endif
#define LUA_USE_ULONGJMP
#define LUA_USE_GMTIME_R
#endif
Expand Down
2 changes: 1 addition & 1 deletion lua-5.3.6/lauxlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) {

#if !defined(l_inspectstat) /* { */

#if defined(LUA_USE_POSIX)
#if defined(LUA_USE_POSIX) && !defined(__wasi__)

#include <sys/wait.h>

Expand Down
Loading
Loading