mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2dd06c4378 |
@@ -26,6 +26,8 @@ jobs:
|
|||||||
goarch: arm64
|
goarch: arm64
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
|
- name: exit early
|
||||||
|
run: command-does-not-exist
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
HOMEBREW_NO_AUTO_UPDATE=1 brew install qemu binaryen
|
HOMEBREW_NO_AUTO_UPDATE=1 brew install qemu binaryen
|
||||||
@@ -128,6 +130,8 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
version: [16, 17, 18]
|
version: [16, 17, 18]
|
||||||
steps:
|
steps:
|
||||||
|
- name: exit early
|
||||||
|
run: command-does-not-exist
|
||||||
- name: Set up Homebrew
|
- name: Set up Homebrew
|
||||||
uses: Homebrew/actions/setup-homebrew@master
|
uses: Homebrew/actions/setup-homebrew@master
|
||||||
- name: Fix Python symlinks
|
- name: Fix Python symlinks
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
version: ${{ steps.version.outputs.version }}
|
version: ${{ steps.version.outputs.version }}
|
||||||
steps:
|
steps:
|
||||||
|
- name: exit early
|
||||||
|
run: command-does-not-exist
|
||||||
- name: Install apk dependencies
|
- name: Install apk dependencies
|
||||||
# tar: needed for actions/cache@v4
|
# tar: needed for actions/cache@v4
|
||||||
# git+openssh: needed for checkout (I think?)
|
# git+openssh: needed for checkout (I think?)
|
||||||
@@ -171,6 +173,8 @@ jobs:
|
|||||||
# potential bugs.
|
# potential bugs.
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- name: exit early
|
||||||
|
run: command-does-not-exist
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ jobs:
|
|||||||
nix-test:
|
nix-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- name: exit early
|
||||||
|
run: command-does-not-exist
|
||||||
- name: Uninstall system LLVM
|
- name: Uninstall system LLVM
|
||||||
# Hack to work around issue where we still include system headers for
|
# Hack to work around issue where we still include system headers for
|
||||||
# some reason.
|
# some reason.
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
|
- name: exit early
|
||||||
|
run: command-does-not-exist
|
||||||
# Prepare, install tools
|
# Prepare, install tools
|
||||||
- name: Add GOBIN to $PATH
|
- name: Add GOBIN to $PATH
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -23,26 +23,30 @@ jobs:
|
|||||||
minimum-size: 8GB
|
minimum-size: 8GB
|
||||||
maximum-size: 24GB
|
maximum-size: 24GB
|
||||||
disk-root: "C:"
|
disk-root: "C:"
|
||||||
- uses: brechtm/setup-scoop@v2
|
#- uses: brechtm/setup-scoop@v2
|
||||||
with:
|
# with:
|
||||||
scoop_update: 'false'
|
# scoop_update: 'false'
|
||||||
- name: Install Dependencies
|
#- name: Install Dependencies
|
||||||
shell: bash
|
# shell: bash
|
||||||
run: |
|
# run: |
|
||||||
scoop install ninja binaryen
|
# scoop install ninja binaryen
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
- name: submodules
|
||||||
submodules: true
|
shell: bash
|
||||||
|
run: git submodule update --init lib/mingw-w64
|
||||||
- name: Extract TinyGo version
|
- name: Extract TinyGo version
|
||||||
id: version
|
id: version
|
||||||
shell: bash
|
shell: bash
|
||||||
run: ./.github/workflows/tinygo-extract-version.sh | tee -a "$GITHUB_OUTPUT"
|
run: ./.github/workflows/tinygo-extract-version.sh | tee -a "$GITHUB_OUTPUT"
|
||||||
- name: Install Go
|
- name: command
|
||||||
uses: actions/setup-go@v5
|
shell: bash
|
||||||
with:
|
run: go env
|
||||||
go-version: '1.23'
|
#- name: Install Go
|
||||||
cache: true
|
# uses: actions/setup-go@v5
|
||||||
|
# with:
|
||||||
|
# go-version: '1.23'
|
||||||
|
# cache: true
|
||||||
- name: Restore cached LLVM source
|
- name: Restore cached LLVM source
|
||||||
uses: actions/cache/restore@v4
|
uses: actions/cache/restore@v4
|
||||||
id: cache-llvm-source
|
id: cache-llvm-source
|
||||||
@@ -91,6 +95,25 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
key: ${{ steps.cache-llvm-build.outputs.cache-primary-key }}
|
key: ${{ steps.cache-llvm-build.outputs.cache-primary-key }}
|
||||||
path: llvm-build
|
path: llvm-build
|
||||||
|
- name: Restore Go cache
|
||||||
|
uses: actions/cache/restore@v4
|
||||||
|
with:
|
||||||
|
key: go-cache-v2
|
||||||
|
path: |
|
||||||
|
C:/Users/runneradmin/AppData/Local/go-build
|
||||||
|
C:/Users/runneradmin/go/pkg/mod
|
||||||
|
- name: Test TinyGo
|
||||||
|
shell: bash
|
||||||
|
run: make test GOTESTFLAGS="-short -run=TestBuild -v"
|
||||||
|
- name: Save Go cache
|
||||||
|
uses: actions/cache/save@v4
|
||||||
|
with:
|
||||||
|
key: go-cache-v2
|
||||||
|
path: |
|
||||||
|
C:/Users/runneradmin/AppData/Local/go-build
|
||||||
|
C:/Users/runneradmin/go/pkg/mod
|
||||||
|
- name: exit
|
||||||
|
run: command-does-not-exist
|
||||||
- name: Cache wasi-libc sysroot
|
- name: Cache wasi-libc sysroot
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
id: cache-wasi-libc
|
id: cache-wasi-libc
|
||||||
@@ -105,9 +128,6 @@ jobs:
|
|||||||
scoop install wasmtime@14.0.4
|
scoop install wasmtime@14.0.4
|
||||||
- name: make gen-device
|
- name: make gen-device
|
||||||
run: make -j3 gen-device
|
run: make -j3 gen-device
|
||||||
- name: Test TinyGo
|
|
||||||
shell: bash
|
|
||||||
run: make test GOTESTFLAGS="-short"
|
|
||||||
- name: Build TinyGo release tarball
|
- name: Build TinyGo release tarball
|
||||||
shell: bash
|
shell: bash
|
||||||
run: make build/release -j4
|
run: make build/release -j4
|
||||||
|
|||||||
+4
-4
@@ -191,7 +191,7 @@ gen-device: gen-device-stm32
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
gen-device-avr:
|
gen-device-avr:
|
||||||
@if [ ! -e lib/avr/README.md ]; then echo "Submodules have not been downloaded. Please download them using:\n git submodule update --init"; exit 1; fi
|
#@if [ ! -e lib/avr/README.md ]; then echo "Submodules have not been downloaded. Please download them using:\n git submodule update --init"; exit 1; fi
|
||||||
$(GO) build -o ./build/gen-device-avr ./tools/gen-device-avr/
|
$(GO) build -o ./build/gen-device-avr ./tools/gen-device-avr/
|
||||||
./build/gen-device-avr lib/avr/packs/atmega src/device/avr/
|
./build/gen-device-avr lib/avr/packs/atmega src/device/avr/
|
||||||
./build/gen-device-avr lib/avr/packs/tiny src/device/avr/
|
./build/gen-device-avr lib/avr/packs/tiny src/device/avr/
|
||||||
@@ -263,7 +263,7 @@ endif
|
|||||||
.PHONY: wasi-libc
|
.PHONY: wasi-libc
|
||||||
wasi-libc: lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a
|
wasi-libc: lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a
|
||||||
lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a:
|
lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a:
|
||||||
@if [ ! -e lib/wasi-libc/Makefile ]; then echo "Submodules have not been downloaded. Please download them using:\n git submodule update --init"; exit 1; fi
|
#@if [ ! -e lib/wasi-libc/Makefile ]; then echo "Submodules have not been downloaded. Please download them using:\n git submodule update --init"; exit 1; fi
|
||||||
cd lib/wasi-libc && $(MAKE) -j4 EXTRA_CFLAGS="-O2 -g -DNDEBUG -mnontrapping-fptoint -msign-ext" MALLOC_IMPL=none CC="$(CLANG)" AR=$(LLVM_AR) NM=$(LLVM_NM)
|
cd lib/wasi-libc && $(MAKE) -j4 EXTRA_CFLAGS="-O2 -g -DNDEBUG -mnontrapping-fptoint -msign-ext" MALLOC_IMPL=none CC="$(CLANG)" AR=$(LLVM_AR) NM=$(LLVM_NM)
|
||||||
|
|
||||||
# Generate WASI syscall bindings
|
# Generate WASI syscall bindings
|
||||||
@@ -292,8 +292,8 @@ endif
|
|||||||
tinygo: ## Build the TinyGo compiler
|
tinygo: ## Build the TinyGo compiler
|
||||||
@if [ ! -f "$(LLVM_BUILDDIR)/bin/llvm-config" ]; then echo "Fetch and build LLVM first by running:"; echo " $(MAKE) llvm-source"; echo " $(MAKE) $(LLVM_BUILDDIR)"; exit 1; fi
|
@if [ ! -f "$(LLVM_BUILDDIR)/bin/llvm-config" ]; then echo "Fetch and build LLVM first by running:"; echo " $(MAKE) llvm-source"; echo " $(MAKE) $(LLVM_BUILDDIR)"; exit 1; fi
|
||||||
CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOENVFLAGS) $(GO) build -buildmode exe -o build/tinygo$(EXE) -tags "byollvm osusergo" .
|
CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOENVFLAGS) $(GO) build -buildmode exe -o build/tinygo$(EXE) -tags "byollvm osusergo" .
|
||||||
test: wasi-libc check-nodejs-version
|
test: #wasi-libc check-nodejs-version
|
||||||
CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) test $(GOTESTFLAGS) -timeout=1h -buildmode exe -tags "byollvm osusergo" $(GOTESTPKGS)
|
CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) test $(GOTESTFLAGS) -timeout=1h -race -buildmode exe -tags "byollvm osusergo" .
|
||||||
|
|
||||||
# Standard library packages that pass tests on darwin, linux, wasi, and windows, but take over a minute in wasi
|
# Standard library packages that pass tests on darwin, linux, wasi, and windows, but take over a minute in wasi
|
||||||
TEST_PACKAGES_SLOW = \
|
TEST_PACKAGES_SLOW = \
|
||||||
|
|||||||
+68
-17
@@ -7,6 +7,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/sha256"
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"io"
|
"io"
|
||||||
@@ -15,6 +16,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -27,7 +29,6 @@ import (
|
|||||||
"github.com/tetratelabs/wazero/sys"
|
"github.com/tetratelabs/wazero/sys"
|
||||||
"github.com/tinygo-org/tinygo/builder"
|
"github.com/tinygo-org/tinygo/builder"
|
||||||
"github.com/tinygo-org/tinygo/compileopts"
|
"github.com/tinygo-org/tinygo/compileopts"
|
||||||
"github.com/tinygo-org/tinygo/diagnostics"
|
|
||||||
"github.com/tinygo-org/tinygo/goenv"
|
"github.com/tinygo-org/tinygo/goenv"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -114,10 +115,15 @@ func TestBuild(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run("Host", func(t *testing.T) {
|
t.Run("Debugging", func(t *testing.T) {
|
||||||
t.Parallel()
|
for i := 0; i < 5; i++ {
|
||||||
runPlatTests(optionsFromTarget("", sema), tests, t)
|
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||||
|
options := optionsFromTarget("", sema)
|
||||||
|
runTest("alias.go", options, t, nil, nil)
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
return
|
||||||
|
|
||||||
// Test a few build options.
|
// Test a few build options.
|
||||||
t.Run("build-options", func(t *testing.T) {
|
t.Run("build-options", func(t *testing.T) {
|
||||||
@@ -420,22 +426,67 @@ func runTestWithConfig(name string, t *testing.T, options compileopts.Options, c
|
|||||||
|
|
||||||
// Build the test binary.
|
// Build the test binary.
|
||||||
stdout := &bytes.Buffer{}
|
stdout := &bytes.Buffer{}
|
||||||
_, err = buildAndRun(pkgName, config, stdout, cmdArgs, environmentVars, time.Minute, func(cmd *exec.Cmd, result builder.BuildResult) error {
|
_, fileExt := config.EmulatorFormat()
|
||||||
return cmd.Run()
|
tmpdir := t.TempDir()
|
||||||
})
|
result, err := builder.Build(pkgName, fileExt, tmpdir, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w := &bytes.Buffer{}
|
t.Fatal("build failed:", err)
|
||||||
diagnostics.CreateDiagnostics(err).WriteTo(w, "")
|
|
||||||
for _, line := range strings.Split(strings.TrimRight(w.String(), "\n"), "\n") {
|
|
||||||
t.Log(line)
|
|
||||||
}
|
|
||||||
if stdout.Len() != 0 {
|
|
||||||
t.Logf("output:\n%s", stdout.String())
|
|
||||||
}
|
|
||||||
t.Fail()
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data, err := os.ReadFile(result.Executable)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal("failed to read executable:", err)
|
||||||
|
}
|
||||||
|
hash := sha256.Sum256(data)
|
||||||
|
t.Logf("executable hash and size: %d %x", len(data), hash)
|
||||||
|
|
||||||
|
for i := 0; i < 100; i++ {
|
||||||
|
i := i
|
||||||
|
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
stdout := &bytes.Buffer{}
|
||||||
|
cmd := exec.Command(result.Executable)
|
||||||
|
cmd.Stdout = stdout
|
||||||
|
cmd.Stderr = stdout
|
||||||
|
err := cmd.Run()
|
||||||
|
if err != nil {
|
||||||
|
t.Log("run error:", err)
|
||||||
|
}
|
||||||
|
checkOutput(t, expectedOutputPath, stdout.Bytes())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
//_, err = buildAndRun(pkgName, config, stdout, cmdArgs, environmentVars, time.Minute, func(cmd *exec.Cmd, result builder.BuildResult) error {
|
||||||
|
// data, err := os.ReadFile(result.Executable)
|
||||||
|
// if err != nil {
|
||||||
|
// t.Fatal("failed to read executable:", err)
|
||||||
|
// }
|
||||||
|
// hash := sha256.Sum256(data)
|
||||||
|
// t.Logf("executable hash and size: %d %x", len(data), hash)
|
||||||
|
|
||||||
|
// t.Log("command:", cmd)
|
||||||
|
// err = cmd.Run()
|
||||||
|
// if err == nil {
|
||||||
|
// t.Log(" error is nil!")
|
||||||
|
// } else {
|
||||||
|
// t.Log(" error:", err)
|
||||||
|
// }
|
||||||
|
// return err
|
||||||
|
//})
|
||||||
|
//if err != nil {
|
||||||
|
// w := &bytes.Buffer{}
|
||||||
|
// diagnostics.CreateDiagnostics(err).WriteTo(w, "")
|
||||||
|
// for _, line := range strings.Split(strings.TrimRight(w.String(), "\n"), "\n") {
|
||||||
|
// t.Log(line)
|
||||||
|
// }
|
||||||
|
// if stdout.Len() != 0 {
|
||||||
|
// t.Logf("output:\n%s", stdout.String())
|
||||||
|
// }
|
||||||
|
// t.Fail()
|
||||||
|
// return
|
||||||
|
//}
|
||||||
|
|
||||||
actual := stdout.Bytes()
|
actual := stdout.Bytes()
|
||||||
if config.EmulatorName() == "simavr" {
|
if config.EmulatorName() == "simavr" {
|
||||||
// Strip simavr log formatting.
|
// Strip simavr log formatting.
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ func main(argc int32, argv *unsafe.Pointer) int {
|
|||||||
stackTop = getCurrentStackPointer()
|
stackTop = getCurrentStackPointer()
|
||||||
runMain()
|
runMain()
|
||||||
|
|
||||||
|
sleepTicks(nanosecondsToTicks(1e9))
|
||||||
|
|
||||||
// For libc compatibility.
|
// For libc compatibility.
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,13 @@ func mainCRTStartup() int {
|
|||||||
stackTop = getCurrentStackPointer()
|
stackTop = getCurrentStackPointer()
|
||||||
runMain()
|
runMain()
|
||||||
|
|
||||||
// For libc compatibility.
|
// Exit via exit(0) instead of returning.
|
||||||
|
// This matches mingw-w64-crt/crt/crtexe.c, which exits using exit(0)
|
||||||
|
// instead of returning the return value.
|
||||||
|
libc_exit(0)
|
||||||
|
|
||||||
|
// Unreachable, since we're already exited. But we need to return something
|
||||||
|
// to make this valid Go code.
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +98,9 @@ func os_runtime_args() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func putchar(c byte) {
|
func putchar(c byte) {
|
||||||
libc_putchar(int(c))
|
if libc_putchar(int(c)) < 0 {
|
||||||
|
libc_exit(42)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var heapSize uintptr = 128 * 1024 // small amount to start
|
var heapSize uintptr = 128 * 1024 // small amount to start
|
||||||
|
|||||||
Reference in New Issue
Block a user