Граф коммитов

1853 коммитов

Автор SHA1 Сообщение Дата
Ayke van Laethem
67de8b490d gc: use raw stack access whenever possible
The only architecture that actually needs special support for scanning
the stack is WebAssembly. All others allow raw access to the stack with
a small bit of assembly. Therefore, don't manually keep track of all
these objects on the stack manually and instead just use conservative
stack scanning.

This results in a massive code size decrease in the affected targets
(only tested linux/amd64 for code size) - sometimes around 33%. It also
allows for future improvements such as using proper stackful goroutines.
2020-10-02 08:54:43 +02:00
Ayke van Laethem
bfa29f17da runtime: move/refactor some GC-related code
Instead of putting tinygo_scanCurrentStack in scheduler_*.S files, put
them in dedicated files. The function tinygo_scanCurrentStack has
nothing to do with scheduling and so doesn't belong there. Additionally,
while scheduling code is made specific for the Cortex-M, the
tinygo_scanCurrentStack is generic to all ARM targets so this move
removes some duplication there.

Specifically:

  * tinygo_scanCurrentStack is moved out of scheduler_cortexm.S as it
    isn't really part of the scheduler. It is now gc_arm.S.
  * Same for the AVR target.
  * Same for the RISCV target.
  * scheduler_gba.S is removed, using gc_arm.S instead as it only
    contains tinygo_scanCurrentStack.
2020-10-02 08:54:43 +02:00
Ayke van Laethem
7123941df0 main: add support for debugging qemu-user targets
This commit allows debugging like the following:

    GOARCH=arm tinygo gdb ./testdata/alias.go

This can be very useful to debug issues on a different instruction set
architecture but still on a host system.

I tested the following 7 configurations to make sure it works and I
didn't break anything:

    GOOS=amd64
    GOOS=386
    GOOS=arm
    GOOS=arm64
    tinygo gdb -target=hifive1-qemu
    tinygo gdb -target=cortex-m-qemu
    tinygo gdb -target=microbit
2020-10-02 08:54:43 +02:00
Ayke van Laethem
05d2f2c412 main: improve support for x86-32 and add tests
To avoid breaking this, make sure we actually test x86-32 (aka i386 aka
GOARCH=386) support in CI.

Also remove the now-unnecessary binutils-arm-none-eabi package to speed
up CI a bit.
2020-10-02 08:54:43 +02:00
Ayke van Laethem
9a12d129ab testing: implement dummy Helper method
This lets a few more packages pass tests: container/heap and
encoding/ascii85.
2020-10-01 02:14:59 +02:00
Ayke van Laethem
0ecfe9eade ci: fix make wasmtest
This fixes issue https://github.com/tinygo-org/tinygo/issues/1418. In
short, it appears there was a race condition that was only visible on
GOARCH=386 but not on GOARCH=amd64. Updating to a more recent chromedp
version fixes the issue.
2020-10-01 02:07:00 +02:00
Takeshi Yoneda
f50ad3585d
support WASI target (#1373)
* initial commit for WASI support

* merge "time" package with wasi build tag
* override syscall package with wasi build tag
* create runtime_wasm_{js,wasi}.go files
* create syscall_wasi.go file
* create time/zoneinfo_wasi.go file as the replacement of zoneinfo_js.go
* add targets/wasi.json target

* set visbility hidden for runtime extern variables

Accodring to the WASI docs (https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md#current-unstable-abi),
none of exports of WASI executable(Command) should no be accessed.

v0.19.0 of bytecodealliance/wasmetime, which is often refered to as the reference implementation of WASI,
does not accept any exports except functions and the only limited variables like "table", "memory".

* merge syscall_{baremetal,wasi}.go

* fix js target build

* mv wasi functions to syscall/wasi && implement sleepTicks

* WASI: set visibility hidden for globals variables

* mv back syscall/wasi/* to runtime package

* WASI: add test

* unexport wasi types

* WASI test: fix wasmtime path

* stop changing visibility of runtime.alloc

* use GOOS=linux, GOARCH=arm for wasi target

Signed-off-by: mathetake <takeshi@tetrate.io>

* WASI: fix build tags for os/runtime packages

Signed-off-by: mathetake <takeshi@tetrate.io>

* run WASI test only on Linux

Signed-off-by: mathetake <takeshi@tetrate.io>

* set InternalLinkage instead of changing visibility

Signed-off-by: mathetake <takeshi@tetrate.io>
2020-09-29 21:58:03 +02:00
Ayke van Laethem
d39c7abb4d nrf: fix double stop signal in I2C 2020-09-27 15:21:54 +02:00
Daniel M. Lambea
9e61e6fe4d
nrf: add I2C error checking (#1392)
* machine/nrf: add I2C error checking
2020-09-26 09:20:43 +02:00
Lucas Teske
d1f90ef59c nintendoswitch: fix crash when printing long lines (> 120) 2020-09-26 02:52:10 +02:00
Ayke van Laethem
54602fe0c3 main: add support for -c and -o flags to tinygo test 2020-09-25 16:18:10 +02:00
Ayke van Laethem
c10dcd429c main: refactor -o flag 2020-09-25 16:18:10 +02:00
Ayke van Laethem
b713001313 test: support non-host tests
For example, for running tests with -target=wasm or
-target=cortex-m-qemu. It looks at the output to determine whether tests
were successful in the absence of a status code.
2020-09-24 21:17:26 +02:00
Ayke van Laethem
1096596b69 compiler: fix floating point bugs
There were a few bugs related to floating point. After fixing these, the
math package started passing all tests.
2020-09-21 10:43:46 +02:00
Ayke van Laethem
7b601b3e3c loader: fix linkname in test binaries
This is an issue in particular in the math package, of which most
functions are defined in the runtime package.
2020-09-21 10:43:46 +02:00
Ayke van Laethem
ec54e7763d runtime: fix UTF-8 decoding
The algorithm now checks for invalid UTF-8 sequences, which is required
by the Go spec.

This gets the tests of the unicode/utf8 package to pass.

Also add bytes.Equal for Go 1.11, which again is necessary for the
unicode/utf8 package.
2020-09-21 08:49:13 +02:00
Elliott Sales de Andrade
41afb77080
builder: also check lib64 for clang include path.
On 64-bit Fedora, `lib64` is where the clang headers are, not `lib`. For
multiarch systems, both will exist, but it's likely you want 64-bit, so
check that first.
2020-09-20 14:00:02 +02:00
Jacques Supcik
13fe668929
compileopts: simplify copyProperties using reflection 2020-09-20 13:49:16 +02:00
sago35
2a72262c33 version: update TinyGo version to 0.16.0-dev 2020-09-18 01:32:31 +02:00
deadprogram
e8615d1007 Prepare for 0.15.0 release
Signed-off-by: deadprogram <ron@hybridgroup.com>
2020-09-17 11:48:55 +02:00
sago35
9245337ecf atsamd2x: fix BAUD value 2020-09-17 09:46:15 +02:00
sago35
8170f59440 atsamd5x: fix BAUD value 2020-09-17 09:46:15 +02:00
Lucas Teske
622de53854 nintendoswitch: simplified assembly code 2020-09-17 07:46:29 +02:00
Lucas Teske
6cd9e3c348 arm64: make dynamic loader structs and constants private 2020-09-17 07:46:29 +02:00
Lucas Teske
33e2411b6a nintendoswitch: fix import cycle on dynamic_arm64.go 2020-09-17 07:46:29 +02:00
Lucas Teske
fb1fc267ab nintendoswitch: Add dynamic loader for runtime loading PIE sections 2020-09-17 07:46:29 +02:00
Olivier Fauchon
490e377bba bluepill: Enable stm32's USART2 for the board and map it to UART1 tinygo's device 2020-09-17 06:26:57 +02:00
Ayke van Laethem
fcedf0beaa stacksize: deal with DW_CFA_advance_loc1
In some cases this operation is emitted. It appears to be emitted when a
switch is lowered to a jump table in the ARM backend.
2020-09-16 05:06:34 +02:00
Ayke van Laethem
4dadb31e18 microbit: reelboard: flash using OpenOCD when needed
When using a SoftDevice, the MSD flash method is not appropriate as it
will erase the entire flash area before writing the new firmware. This
also wipes the SoftDevice. Instead, use OpenOCD to only rewrite the
parts of flash that need to be rewritten and leave the SoftDevice alone.
2020-09-15 17:07:40 +02:00
Ayke van Laethem
5b81b835ba esp32: add SPI support 2020-09-14 12:24:46 +02:00
ardnew
a9a6d0ee63 add basic UART handler 2020-09-14 08:48:01 +02:00
Ayke van Laethem
19d5e05e37 esp32: configure the I/O matrix for GPIO pins
Only some pins (notably including GPIO2 aka machine.LED) have GPIO for
the default function 1. Other pins (such as GPIO 15) had a different
function by default. Function 3 means GPIO for all the pins, so always
use that when configuring a pin to use as a GPIO pin.

In the future, the mux configuration will need to be updated for other
functions such as SPI, I2C, etc.
2020-09-13 11:24:33 +02:00
Ayke van Laethem
9e599bac49 nintendoswitch: support outputting .nro files directly
By modifying the linker script a bit and adding the NRO0 header directly
in the assembly, it's possible to craft an ELF file that can be
converted straight to a binary (using objcopy or similar) that is a NRO
file. This avoids custom code for NRO files or an extra build step.

With another change, .nro files are recognized by TinyGo so that this
will create a ready-to-run NRO file:

    tinygo build -o test.nro -target=nintendoswitch examples/serial
2020-09-12 18:37:58 +02:00
Nia Weiss
81e325205f update my name in the contributors list 2020-09-12 16:51:47 +02:00
deadprogram
71cbb1495e docs: add ESP32, ESP8266, and Adafruit Feather STM32F405 to list of supported boards
Signed-off-by: deadprogram <ron@hybridgroup.com>
2020-09-11 09:36:19 +02:00
ardnew
efc824a103 change default flash method to DFU (using dfu-util over USB) 2020-09-11 09:09:02 +02:00
ardnew
cb4f3f12e6 replace flash method with openocd, disable automatic stack sizing 2020-09-11 09:09:02 +02:00
ardnew
d1b470f04e remove UART/SPI vars until peripherals implemented 2020-09-11 09:09:02 +02:00
ardnew
7aaa9e45a6 add pin/bus doc comments, I2C pins 2020-09-11 09:09:02 +02:00
ardnew
5c9930df3f move clock settings docs comment to respective const definitions 2020-09-11 09:09:02 +02:00
ardnew
cf6b544cd9 remove (or stub) UART/SPI/I2C peripheral code from initial feather-stm32f405 board support 2020-09-11 09:09:02 +02:00
ardnew
097f628955 add feather-stm32f405 smoketest target 2020-09-11 09:09:02 +02:00
ardnew
20a1c730a1 add STM32F405 machine/runtime, and new board/target feather-stm32f405 2020-09-11 09:09:02 +02:00
jreamy
04f65f1189
Adding support for the Arduino Zero (#1365)
* machine/arduino-zero: adding support for Arduino Zero

Co-authored-by: Ayke
Co-authored-by: Jack Reamy
2020-09-10 10:32:12 +02:00
Ayke van Laethem
2ce17a1892 esp8266: add support for this chip
Many thanks to cnlohr for the nosdk8266 project:
    https://github.com/cnlohr/nosdk8266
2020-09-09 19:17:11 +02:00
Lucas Teske
0b9b293651
nintendoswitch: Fix invalid memory read / write in print calls 2020-09-09 18:51:00 +02:00
Ayke van Laethem
f20c932bb9 nrf52840: use higher priority for USB-CDC code
This ensures that stdout (println etc) keeps working in interrupts.

Generally you shouldn't print anything in an interrupt. However,
printing things for debugging is very useful and printing panic messages
can be critical when the code doesn't work for some reason.
2020-09-09 17:15:50 +02:00
Ayke van Laethem
e7227df80d main: implement tinygo targets to list usable targets
This patch adds the `tinygo targets` command, which lists usable
targets (targets that can be used in the `-target` flag).

The assumption here is that usable targets can either be flashed or
emulated by TinyGo. There is one exception where it doesn't work yet:
the nintendoswitch target. Right now it requires some manual steps to
build a .nro file which can then be run by yuzu, hence why it doesn't
show up in the list.
2020-09-09 13:05:14 +02:00
Ayke van Laethem
b99175a436 avr: configure emulator in board files
Instead of specifying the emulator command in atmega328p.json, specify
it in the two boards based on it (arduino and arduino-nano). This makes
the configuration consistent with the machine package, which only
defines the CPUFrequency function in the board files (and not in
machine_atmega328p.json).
2020-09-09 13:05:14 +02:00
Ayke van Laethem
de3ffe0af7 main: add cached GOROOT to info subcommand
This is necessary for an upcoming VS Code extension to support TinyGo,
and may be useful for other people wanting to use proper autocompletion
etc in their IDE.
2020-09-07 13:07:17 +02:00