mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-28 23:58:40 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d56dee00f | |||
| 1f0bf9ba63 | |||
| 0b0ae19656 | |||
| 9027c50405 | |||
| 4ce54ede15 | |||
| d8b1fac690 | |||
| 1996fad075 | |||
| 7fe996e7ba |
@@ -105,13 +105,6 @@ jobs:
|
||||
- test-linux:
|
||||
llvm: "14"
|
||||
resource_class: large
|
||||
test-llvm15-go120:
|
||||
docker:
|
||||
- image: golang:1.20-rc-buster
|
||||
steps:
|
||||
- test-linux:
|
||||
llvm: "15"
|
||||
resource_class: large
|
||||
|
||||
workflows:
|
||||
test-all:
|
||||
@@ -119,4 +112,3 @@ workflows:
|
||||
# This tests our lowest supported versions of Go and LLVM, to make sure at
|
||||
# least the smoke tests still pass.
|
||||
- test-llvm14-go118
|
||||
- test-llvm15-go120
|
||||
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19'
|
||||
go-version: '1.20'
|
||||
cache: true
|
||||
- name: Cache LLVM source
|
||||
uses: actions/cache@v3
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
uses: actions/cache@v3
|
||||
id: cache-llvm-build
|
||||
with:
|
||||
key: llvm-build-15-macos-v2
|
||||
key: llvm-build-15-macos-v3
|
||||
path: llvm-build
|
||||
- name: Build LLVM
|
||||
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
|
||||
@@ -103,11 +103,11 @@ jobs:
|
||||
run: |
|
||||
HOMEBREW_NO_AUTO_UPDATE=1 brew install llvm@15
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19'
|
||||
go-version: '1.20'
|
||||
cache: true
|
||||
- name: Build TinyGo
|
||||
run: go install
|
||||
|
||||
@@ -18,7 +18,7 @@ jobs:
|
||||
# statically linked binary.
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: golang:1.19-alpine
|
||||
image: golang:1.20-alpine
|
||||
steps:
|
||||
- name: Install apk dependencies
|
||||
# tar: needed for actions/cache@v3
|
||||
@@ -57,7 +57,7 @@ jobs:
|
||||
uses: actions/cache@v3
|
||||
id: cache-llvm-build
|
||||
with:
|
||||
key: llvm-build-15-linux-alpine-v2
|
||||
key: llvm-build-15-linux-alpine-v3
|
||||
path: llvm-build
|
||||
- name: Build LLVM
|
||||
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
|
||||
@@ -118,7 +118,7 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19'
|
||||
go-version: '1.20'
|
||||
cache: true
|
||||
- name: Install wasmtime
|
||||
run: |
|
||||
@@ -158,7 +158,7 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19'
|
||||
go-version: '1.20'
|
||||
cache: true
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
@@ -186,7 +186,7 @@ jobs:
|
||||
uses: actions/cache@v3
|
||||
id: cache-llvm-build
|
||||
with:
|
||||
key: llvm-build-15-linux-asserts-v2
|
||||
key: llvm-build-15-linux-asserts-v3
|
||||
path: llvm-build
|
||||
- name: Build LLVM
|
||||
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
|
||||
@@ -252,7 +252,7 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19'
|
||||
go-version: '1.20'
|
||||
cache: true
|
||||
- name: Cache LLVM source
|
||||
uses: actions/cache@v3
|
||||
@@ -272,7 +272,7 @@ jobs:
|
||||
uses: actions/cache@v3
|
||||
id: cache-llvm-build
|
||||
with:
|
||||
key: llvm-build-15-linux-arm-v2
|
||||
key: llvm-build-15-linux-arm-v3
|
||||
path: llvm-build
|
||||
- name: Build LLVM
|
||||
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
|
||||
@@ -352,7 +352,7 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19'
|
||||
go-version: '1.20'
|
||||
cache: true
|
||||
- name: Cache LLVM source
|
||||
uses: actions/cache@v3
|
||||
@@ -372,7 +372,7 @@ jobs:
|
||||
uses: actions/cache@v3
|
||||
id: cache-llvm-build
|
||||
with:
|
||||
key: llvm-build-15-linux-arm64-v2
|
||||
key: llvm-build-15-linux-arm64-v3
|
||||
path: llvm-build
|
||||
- name: Build LLVM
|
||||
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
|
||||
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19'
|
||||
go-version: '1.20'
|
||||
cache: true
|
||||
- name: Cache LLVM source
|
||||
uses: actions/cache@v3
|
||||
@@ -49,7 +49,7 @@ jobs:
|
||||
uses: actions/cache@v3
|
||||
id: cache-llvm-build
|
||||
with:
|
||||
key: llvm-build-15-windows-v2
|
||||
key: llvm-build-15-windows-v3
|
||||
path: llvm-build
|
||||
- name: Build LLVM
|
||||
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
|
||||
@@ -108,11 +108,11 @@ jobs:
|
||||
run: |
|
||||
scoop install binaryen
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19'
|
||||
go-version: '1.20'
|
||||
cache: true
|
||||
- name: Download TinyGo build
|
||||
uses: actions/download-artifact@v2
|
||||
@@ -132,11 +132,11 @@ jobs:
|
||||
needs: build-windows
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19'
|
||||
go-version: '1.20'
|
||||
cache: true
|
||||
- name: Download TinyGo build
|
||||
uses: actions/download-artifact@v2
|
||||
@@ -162,11 +162,11 @@ jobs:
|
||||
run: |
|
||||
scoop install binaryen wasmtime
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.19'
|
||||
go-version: '1.20'
|
||||
cache: true
|
||||
- name: Download TinyGo build
|
||||
uses: actions/download-artifact@v2
|
||||
|
||||
@@ -1,3 +1,100 @@
|
||||
0.27.0
|
||||
---
|
||||
|
||||
* **general**
|
||||
- all: update musl
|
||||
- all: remove "acm:"` prefix for USB vid/pid pair
|
||||
- all: add support for LLVM 15
|
||||
- all: use DWARF version 4
|
||||
- all: add initial (incomplete) support for Go 1.20
|
||||
- all: add `-gc=custom` option
|
||||
- `main`: print ldflags including ThinLTO flags with -x
|
||||
- `main`: fix error message when a serial port can't be accessed
|
||||
- `main`: add `-timeout` flag to allow setting how long TinyGo will try looking for a MSD volume for flashing
|
||||
- `test`: print PASS on pass when running standalone test binaries
|
||||
- `test`: fix printing of benchmark output
|
||||
- `test`: print package name when compilation failed (not just when the test failed)
|
||||
* **compiler**
|
||||
- refactor to support LLVM 15
|
||||
- `builder`: print compiler commands while building a library
|
||||
- `compiler`: fix stack overflow when creating recursive pointer types (fix for LLVM 15+ only)
|
||||
- `compiler`: allow map keys and values of ≥256 bytes
|
||||
- `cgo`: add support for `C.float` and `C.double`
|
||||
- `cgo`: support anonymous enums included in multiple Go files
|
||||
- `cgo`: add support for bitwise operators
|
||||
- `interp`: add support for constant icmp instructions
|
||||
- `transform`: fix memory corruption issues
|
||||
* **standard library**
|
||||
- `machine/usb`: remove allocs in USB ISR
|
||||
- `machine/usb`: add `Port()` and deprecate `New()` to have the API better match the singleton that is actually being returned
|
||||
- `machine/usb`: change HID usage-maximum to 0xFF
|
||||
- `machine/usb`: add USB HID joystick support
|
||||
- `machine/usb`: change to not send before endpoint initialization
|
||||
- `net`: implement `Pipe`
|
||||
- `os`: add stub for `os.Chtimes`
|
||||
- `reflect`: stub out `Type.FieldByIndex`
|
||||
- `reflect`: add `Value.IsZero` method
|
||||
- `reflect`: fix bug in `.Field` method when the field fits in a pointer but the parent doesn't
|
||||
- `runtime`: switch some `panic()` calls in the gc to `runtimePanic()` for consistency
|
||||
- `runtime`: add xorshift-based fastrand64
|
||||
- `runtime`: fix alignment for arm64, arm, xtensa, riscv
|
||||
- `runtime`: implement precise GC
|
||||
- `runtime/debug`: stub `PrintStack`
|
||||
- `sync`: implement simple pooling in `sync.Pool`
|
||||
- `syscall`: stubbed `Setuid`, Exec and friends
|
||||
- `syscall`: add more stubs as needed for Go 1.20 support
|
||||
- `testing`: implement `t.Setenv`
|
||||
- `unsafe`: add support for Go 1.20 slice/string functions
|
||||
* **targets**
|
||||
- `all`: do not set stack size per board
|
||||
- `all`: update picolibc to v1.7.9
|
||||
- `atsame5x`: fix CAN extendedID handling
|
||||
- `atsame5x`: reduce heap allocation
|
||||
- `avr`: drop GNU toolchain dependency
|
||||
- `avr`: fix .data initialization for binaries over 64kB
|
||||
- `avr`: support ThinLTO
|
||||
- `baremetal`: implements calloc
|
||||
- `darwin`: fix `syscall.Open` on darwin/arm64
|
||||
- `darwin`: fix error with `tinygo lldb`
|
||||
- `esp`: use LLVM Xtensa linker instead of Espressif toolchain
|
||||
- `esp`: use ThinLTO for Xtensa
|
||||
- `esp32c3`: add SPI support
|
||||
- `linux`: include musl `getpagesize` function in release
|
||||
- `nrf51`: add ADC implementation
|
||||
- `nrf52840`: add PDM support
|
||||
- `riscv`: add "target-abi" metadata flag
|
||||
- `rp2040`: remove mem allocation in GPIO ISR
|
||||
- `rp2040`: avoid allocating clock on heap
|
||||
- `rp2040`: add basic GPIO support for PIO
|
||||
- `rp2040`: fix USB interrupt issue
|
||||
- `rp2040`: fix RP2040-E5 USB errata
|
||||
- `stm32`: always set ADC pins to pullups floating
|
||||
- `stm32f1`, `stm32f4`: fix ADC by clearing the correct bit for rank after each read
|
||||
- `stm32wl`: Fix incomplete RNG initialisation
|
||||
- `stm32wlx`: change order for init so clock speeds are set before peripheral start
|
||||
- `wasi`: makes wasmtime "run" explicit
|
||||
- `wasm`: fix GC scanning of allocas
|
||||
- `wasm`: allow custom malloc implementation
|
||||
- `wasm`: remove `-wasm-abi=` flag (use `-target` instead)
|
||||
- `wasm`: fix scanning of the stack
|
||||
- `wasm`: fix panic when allocating 0 bytes using malloc
|
||||
- `wasm`: always run wasm-opt even with `-scheduler=none`
|
||||
- `wasm`: avoid miscompile with ThinLTO
|
||||
- `wasm`: allow the emulator to expand `{tmpDir}`
|
||||
- `wasm`: support ThinLTO
|
||||
- `windows`: update mingw-w64 version to avoid linker warning
|
||||
- `windows`: add ARM64 support
|
||||
* **boards**
|
||||
- Add Waveshare RP2040 Zero
|
||||
- Add Arduino Leonardo support
|
||||
- Add Adafruit KB2040
|
||||
- Add Adafruit Feather M0 Express
|
||||
- Add Makerfabs ESP32C3SPI35 TFT Touchscreen board
|
||||
- Add Espressif ESP32-C3-DevKit-RUST-1 board
|
||||
- `lgt92`: fix OpenOCD configuration
|
||||
- `xiao-rp2040`: fix D9 and D10 constants
|
||||
- `xiao-rp2040`: add pin definitions
|
||||
|
||||
0.26.0
|
||||
---
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# tinygo-llvm stage obtains the llvm source for TinyGo
|
||||
FROM golang:1.19 AS tinygo-llvm
|
||||
FROM golang:1.20 AS tinygo-llvm
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y apt-utils make cmake clang-11 ninja-build
|
||||
|
||||
@@ -242,7 +242,7 @@ llvm-source: $(LLVM_PROJECTDIR)/llvm
|
||||
# Configure LLVM.
|
||||
TINYGO_SOURCE_DIR=$(shell pwd)
|
||||
$(LLVM_BUILDDIR)/build.ninja:
|
||||
mkdir -p $(LLVM_BUILDDIR) && cd $(LLVM_BUILDDIR) && cmake -G Ninja $(TINYGO_SOURCE_DIR)/$(LLVM_PROJECTDIR)/llvm "-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64;RISCV;WebAssembly" "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AVR;Xtensa" -DCMAKE_BUILD_TYPE=Release -DLIBCLANG_BUILD_STATIC=ON -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_LIBEDIT=OFF -DLLVM_ENABLE_Z3_SOLVER=OFF -DLLVM_ENABLE_OCAMLDOC=OFF -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=OFF -DCLANG_ENABLE_STATIC_ANALYZER=OFF -DCLANG_ENABLE_ARCMT=OFF $(LLVM_OPTION)
|
||||
mkdir -p $(LLVM_BUILDDIR) && cd $(LLVM_BUILDDIR) && cmake -G Ninja $(TINYGO_SOURCE_DIR)/$(LLVM_PROJECTDIR)/llvm "-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64;RISCV;WebAssembly" "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AVR;Xtensa" -DCMAKE_BUILD_TYPE=Release -DLIBCLANG_BUILD_STATIC=ON -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_ZSTD=OFF -DLLVM_ENABLE_LIBEDIT=OFF -DLLVM_ENABLE_Z3_SOLVER=OFF -DLLVM_ENABLE_OCAMLDOC=OFF -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=OFF -DCLANG_ENABLE_STATIC_ANALYZER=OFF -DCLANG_ENABLE_ARCMT=OFF $(LLVM_OPTION)
|
||||
|
||||
# Build LLVM.
|
||||
$(LLVM_BUILDDIR): $(LLVM_BUILDDIR)/build.ninja
|
||||
|
||||
@@ -15,7 +15,7 @@ require (
|
||||
github.com/mattn/go-tty v0.0.4
|
||||
go.bug.st/serial v1.3.5
|
||||
golang.org/x/sys v0.4.0
|
||||
golang.org/x/tools v0.5.0
|
||||
golang.org/x/tools v0.5.1-0.20230114154351-e035d0c426c8
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
tinygo.org/x/go-llvm v0.0.0-20221028183034-8341240c0b32
|
||||
)
|
||||
|
||||
@@ -56,8 +56,8 @@ golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
|
||||
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/tools v0.5.0 h1:+bSpV5HIeWkuvgaMfI3UmKRThoTA5ODJTUd8T17NO+4=
|
||||
golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k=
|
||||
golang.org/x/tools v0.5.1-0.20230114154351-e035d0c426c8 h1:LHoToPgySGSr2NcUHbjENAidHz38RkKaNmmntwn9TjI=
|
||||
golang.org/x/tools v0.5.1-0.20230114154351-e035d0c426c8/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
// Version of TinyGo.
|
||||
// Update this value before release of new version of software.
|
||||
const Version = "0.27.0-dev"
|
||||
const Version = "0.27.0"
|
||||
|
||||
var (
|
||||
// This variable is set at build time using -ldflags parameters.
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
//go:build linux || darwin || windows
|
||||
|
||||
package runtime
|
||||
|
||||
// Update the C environment if cgo is loaded.
|
||||
// Called from Go 1.20 and above.
|
||||
//
|
||||
//go:linkname syscallSetenv syscall.runtimeSetenv
|
||||
func syscallSetenv(key, value string) {
|
||||
keydata := cstring(key)
|
||||
valdata := cstring(value)
|
||||
setenv(&keydata[0], &valdata[0])
|
||||
if key == "GODEBUG" && godebugUpdate != nil {
|
||||
// Starting with Go 1.20, we need to call a callback (set by
|
||||
// internal/godebug) to notify the GODEBUG environment variable has
|
||||
// changed. This is necessary to get archive/zip to pass tests.
|
||||
godebugUpdate(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
// Update the C environment if cgo is loaded.
|
||||
// Called from Go 1.20 and above.
|
||||
//
|
||||
//go:linkname syscallUnsetenv syscall.runtimeUnsetenv
|
||||
func syscallUnsetenv(key string) {
|
||||
keydata := cstring(key)
|
||||
unsetenv(&keydata[0])
|
||||
}
|
||||
|
||||
// Compatibility with Go 1.19 and below.
|
||||
//
|
||||
//go:linkname syscall_setenv_c syscall.setenv_c
|
||||
func syscall_setenv_c(key string, val string) {
|
||||
syscallSetenv(key, val)
|
||||
}
|
||||
|
||||
// Compatibility with Go 1.19 and below.
|
||||
//
|
||||
//go:linkname syscall_unsetenv_c syscall.unsetenv_c
|
||||
func syscall_unsetenv_c(key string) {
|
||||
syscallUnsetenv(key)
|
||||
}
|
||||
|
||||
// cstring converts a Go string to a C string.
|
||||
// borrowed from syscall
|
||||
func cstring(s string) []byte {
|
||||
data := make([]byte, len(s)+1)
|
||||
copy(data, s)
|
||||
// final byte should be zero from the initial allocation
|
||||
return data
|
||||
}
|
||||
+10
-44
@@ -2,50 +2,6 @@
|
||||
|
||||
package runtime
|
||||
|
||||
// Update the C environment if cgo is loaded.
|
||||
// Called from Go 1.20 and above.
|
||||
//
|
||||
//go:linkname syscallSetenv syscall.runtimeSetenv
|
||||
func syscallSetenv(key, value string) {
|
||||
keydata := cstring(key)
|
||||
valdata := cstring(value)
|
||||
// ignore any errors
|
||||
libc_setenv(&keydata[0], &valdata[0], 1)
|
||||
}
|
||||
|
||||
// Update the C environment if cgo is loaded.
|
||||
// Called from Go 1.20 and above.
|
||||
//
|
||||
//go:linkname syscallUnsetenv syscall.runtimeUnsetenv
|
||||
func syscallUnsetenv(key string) {
|
||||
keydata := cstring(key)
|
||||
// ignore any errors
|
||||
libc_unsetenv(&keydata[0])
|
||||
}
|
||||
|
||||
// Compatibility with Go 1.19 and below.
|
||||
//
|
||||
//go:linkname syscall_setenv_c syscall.setenv_c
|
||||
func syscall_setenv_c(key string, val string) {
|
||||
syscallSetenv(key, val)
|
||||
}
|
||||
|
||||
// Compatibility with Go 1.19 and below.
|
||||
//
|
||||
//go:linkname syscall_unsetenv_c syscall.unsetenv_c
|
||||
func syscall_unsetenv_c(key string) {
|
||||
syscallUnsetenv(key)
|
||||
}
|
||||
|
||||
// cstring converts a Go string to a C string.
|
||||
// borrowed from syscall
|
||||
func cstring(s string) []byte {
|
||||
data := make([]byte, len(s)+1)
|
||||
copy(data, s)
|
||||
// final byte should be zero from the initial allocation
|
||||
return data
|
||||
}
|
||||
|
||||
// int setenv(const char *name, const char *val, int replace);
|
||||
//
|
||||
//export setenv
|
||||
@@ -55,3 +11,13 @@ func libc_setenv(name *byte, val *byte, replace int32) int32
|
||||
//
|
||||
//export unsetenv
|
||||
func libc_unsetenv(name *byte) int32
|
||||
|
||||
func setenv(key, val *byte) {
|
||||
// ignore any errors
|
||||
libc_setenv(key, val, 1)
|
||||
}
|
||||
|
||||
func unsetenv(key *byte) {
|
||||
// ignore any errors
|
||||
libc_unsetenv(key)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//go:build windows
|
||||
|
||||
package runtime
|
||||
|
||||
// Set environment variable in Windows:
|
||||
//
|
||||
// BOOL SetEnvironmentVariableA(
|
||||
// [in] LPCSTR lpName,
|
||||
// [in, optional] LPCSTR lpValue
|
||||
// );
|
||||
//
|
||||
//export SetEnvironmentVariableA
|
||||
func _SetEnvironmentVariableA(key, val *byte) bool
|
||||
|
||||
func setenv(key, val *byte) {
|
||||
// ignore any errors
|
||||
_SetEnvironmentVariableA(key, val)
|
||||
}
|
||||
|
||||
func unsetenv(key *byte) {
|
||||
// ignore any errors
|
||||
_SetEnvironmentVariableA(key, nil)
|
||||
}
|
||||
@@ -96,8 +96,11 @@ func SetFinalizer(obj interface{}, finalizer interface{}) {
|
||||
// Unimplemented.
|
||||
}
|
||||
|
||||
var godebugUpdate func(string, string)
|
||||
|
||||
//go:linkname godebug_setUpdate internal/godebug.setUpdate
|
||||
func godebug_setUpdate(update func(string, string)) {
|
||||
// Unimplemented. The 'update' function needs to be called whenever the
|
||||
// GODEBUG environment variable changes (for example, via os.Setenv).
|
||||
// The 'update' function needs to be called whenever the GODEBUG environment
|
||||
// variable changes (for example, via os.Setenv).
|
||||
godebugUpdate = update
|
||||
}
|
||||
|
||||
@@ -146,6 +146,8 @@ func Unlink(path string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
|
||||
|
||||
func Kill(pid int, sig Signal) (err error) {
|
||||
return ENOSYS // TODO
|
||||
}
|
||||
@@ -290,6 +292,18 @@ func Environ() []string {
|
||||
return envs
|
||||
}
|
||||
|
||||
// BytePtrFromString returns a pointer to a NUL-terminated array of
|
||||
// bytes containing the text of s. If s contains a NUL byte at any
|
||||
// location, it returns (nil, EINVAL).
|
||||
func BytePtrFromString(s string) (*byte, error) {
|
||||
for i := 0; i < len(s); i++ {
|
||||
if s[i] == 0 {
|
||||
return nil, EINVAL
|
||||
}
|
||||
}
|
||||
return &cstring(s)[0], nil
|
||||
}
|
||||
|
||||
// cstring converts a Go string to a C string.
|
||||
func cstring(s string) []byte {
|
||||
data := make([]byte, len(s)+1)
|
||||
|
||||
@@ -52,6 +52,9 @@ const (
|
||||
DT_SOCK = 0xc
|
||||
DT_UNKNOWN = 0x0
|
||||
DT_WHT = 0xe
|
||||
F_GETFL = 0x3
|
||||
F_SETFL = 0x4
|
||||
O_NONBLOCK = 0x4
|
||||
)
|
||||
|
||||
// Source: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/sys/errno.h.auto.html
|
||||
@@ -62,6 +65,7 @@ const (
|
||||
EEXIST Errno = 17
|
||||
EINTR Errno = 4
|
||||
ENOTDIR Errno = 20
|
||||
EISDIR Errno = 21
|
||||
EINVAL Errno = 22
|
||||
EMFILE Errno = 24
|
||||
EPIPE Errno = 32
|
||||
@@ -271,6 +275,32 @@ func Getpagesize() int {
|
||||
return int(libc_getpagesize())
|
||||
}
|
||||
|
||||
// The following RawSockAddr* types have been copied from the Go source tree and
|
||||
// are here purely to fix build errors.
|
||||
|
||||
type RawSockaddr struct {
|
||||
Len uint8
|
||||
Family uint8
|
||||
Data [14]int8
|
||||
}
|
||||
|
||||
type RawSockaddrInet4 struct {
|
||||
Len uint8
|
||||
Family uint8
|
||||
Port uint16
|
||||
Addr [4]byte /* in_addr */
|
||||
Zero [8]int8
|
||||
}
|
||||
|
||||
type RawSockaddrInet6 struct {
|
||||
Len uint8
|
||||
Family uint8
|
||||
Port uint16
|
||||
Flowinfo uint32
|
||||
Addr [16]byte /* in6_addr */
|
||||
Scope_id uint32
|
||||
}
|
||||
|
||||
// int pipe(int32 *fds);
|
||||
//
|
||||
//export pipe
|
||||
|
||||
@@ -71,6 +71,14 @@ func Getpagesize() int {
|
||||
return 4096 // TODO
|
||||
}
|
||||
|
||||
type RawSockaddrInet4 struct {
|
||||
// stub
|
||||
}
|
||||
|
||||
type RawSockaddrInet6 struct {
|
||||
// stub
|
||||
}
|
||||
|
||||
// int open(const char *pathname, int flags, mode_t mode);
|
||||
//
|
||||
//export open
|
||||
|
||||
@@ -87,6 +87,22 @@ const (
|
||||
PROT_READ = 1
|
||||
PROT_WRITE = 2
|
||||
PROT_EXEC = 4
|
||||
|
||||
// ../../lib/wasi-libc/expected/wasm32-wasi/predefined-macros.txt
|
||||
F_GETFL = 3
|
||||
F_SETFL = 4
|
||||
)
|
||||
|
||||
// These values are needed as a stub until Go supports WASI as a full target.
|
||||
// The constant values don't have a meaning and don't correspond to anything
|
||||
// real.
|
||||
const (
|
||||
_ = iota
|
||||
SYS_FCNTL
|
||||
SYS_FCNTL64
|
||||
SYS_FSTATAT64
|
||||
SYS_OPENAT
|
||||
SYS_UNLINKAT
|
||||
)
|
||||
|
||||
//go:extern errno
|
||||
@@ -308,6 +324,32 @@ func Getpagesize() int {
|
||||
return 65536
|
||||
}
|
||||
|
||||
type Utsname struct {
|
||||
Sysname [65]int8
|
||||
Nodename [65]int8
|
||||
Release [65]int8
|
||||
Version [65]int8
|
||||
Machine [65]int8
|
||||
Domainname [65]int8
|
||||
}
|
||||
|
||||
// Stub Utsname, needed because WASI pretends to be linux/arm.
|
||||
func Uname(buf *Utsname) (err error)
|
||||
|
||||
type RawSockaddrInet4 struct {
|
||||
// stub
|
||||
}
|
||||
|
||||
type RawSockaddrInet6 struct {
|
||||
// stub
|
||||
}
|
||||
|
||||
// This is a stub, it is not functional.
|
||||
func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
|
||||
|
||||
// This is a stub, it is not functional.
|
||||
func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
|
||||
|
||||
// int stat(const char *path, struct stat * buf);
|
||||
//
|
||||
//export stat
|
||||
|
||||
@@ -210,3 +210,11 @@ func Getpagesize() int {
|
||||
// common assumption when pagesize is unknown
|
||||
return 4096
|
||||
}
|
||||
|
||||
type RawSockaddrInet4 struct {
|
||||
// stub
|
||||
}
|
||||
|
||||
type RawSockaddrInet6 struct {
|
||||
// stub
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
package syscall
|
||||
|
||||
func Exec(argv0 string, argv []string, envv []string) (err error)
|
||||
|
||||
// The two SockaddrInet* structs have been copied from the Go source tree.
|
||||
|
||||
type SockaddrInet4 struct {
|
||||
Port int
|
||||
Addr [4]byte
|
||||
raw RawSockaddrInet4
|
||||
}
|
||||
|
||||
type SockaddrInet6 struct {
|
||||
Port int
|
||||
ZoneId uint32
|
||||
Addr [16]byte
|
||||
raw RawSockaddrInet6
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user