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

216 коммитов

Автор SHA1 Сообщение Дата
Ayke van Laethem
7369a0e7f2 all: add support for Windows 2019-10-17 00:14:59 +02:00
Ayke van Laethem
e6cab6c327 main: add go env subcommand
This is required for integration in VS Code.
2019-10-14 17:58:06 +02:00
Ayke van Laethem
2463153a8c main: refactor environment variables into a separate package
This makes it possible to query these environment variables from
anywhere, which might be useful. More importantly, it puts them in a
central location from where they can be queried, useful for a `go env`
subcommand.
2019-10-14 17:58:06 +02:00
Ayke van Laethem
2a71aa90bc targets: refactor flash/gdb target configuration
Instead of specifying explicit commands, most of these commands have
been replaced by more specific properties.

This is work that will be necessary for an eventual -programmer flag to
the compiler, with which it is possible to select which programmer to
use to flash or debug a chip. That's not very useful for boards that
already include a programmer or bootloader for that purpose, but is very
useful for novel boards or single-purpose boards that are not already
included in TinyGo.
2019-10-14 16:44:33 +02:00
Ron Evans
ba49148644 flash: support flashing boards using Mass Storage Device (MSD) operation for uf2 and daplink bootloaders
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-10-13 15:11:21 +02:00
Ron Evans
02facb8568 flash: add ability to perform 1200baud port reset for MCUs that can detect this in order to go into bootloader mode for flashing without pressing any buttons. Also add support for this to the Arduino Nano33 IoT board target
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-10-13 00:43:00 +02:00
Ayke van Laethem
da7f7eef00 interp: avoid an extra TargetData argument
This can be easily calculated from the module datalayout string.
2019-09-24 18:16:43 +02:00
Jaden Weiss
17ef7a5c32
all: add support for go 1.13 2019-09-24 16:13:26 +02:00
Ron Evans
a7d00f1b6d machine/gameboy-advance: allow TinyGo to directly output GBA files that are ready for flashing by performing objcopy
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-09-21 15:03:18 +02:00
Jaden Weiss
abca3132a9 fix bugs found by LLVM assertions 2019-09-16 18:31:33 +02:00
Ayke van Laethem
b4859240e1 main: stop running the LLVM verifier for trivial changes
The above changes might indeed introduce inconsistencies in the IR, but
the code is small and doesn't change often so it's unnecessary to always
check for errors. It will be tested again later anyway.

The compile time impact was somewhere around 6%, so that's a nice
improvement.
2019-09-16 15:11:59 +02:00
Ron Evans
bc41cc688f main: check the major/minor installed version of Go before tinygo compile, to ensure that it is a supported version.
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-09-14 17:50:16 +02:00
Ayke van Laethem
542135c357 compiler,runtime: implement stack-based scheduler
This scheduler is intended to live along the (stackless) coroutine based
scheduler which is needed for WebAssembly and unsupported platforms. The
stack based scheduler is somewhat simpler in implementation as it does
not require full program transform passes and supports things like
function pointers and interface methods out of the box with no changes.

Code size is reduced in most cases, even in the case where no scheduler
scheduler is used at all. I'm not exactly sure why but these changes
likely allowed some further optimizations somewhere. Even RAM is
slightly reduced, perhaps some global was elminated in the process as
well.
2019-08-15 17:31:54 +02:00
Justin Clift
f76385850d main: fix outdated panic option text 2019-08-04 14:11:08 +02:00
Ayke van Laethem
d627208c48 all: make WebAssembly initial linear memory size configurable
When the target supports it, allow the (initial) heap size to be
configured. Currently only supported in WebAssembly.

This also changes the default heap size of WebAssembly from 64kB to 1MB.
2019-07-08 00:09:59 +02:00
Ayke van Laethem
00e91ec569
all: rename garbage collectors
dumb -> leaking:
  make it more clear what this "GC" does: leak everything.
marksweep -> conservative:
  "marksweep" is too generic, use "conservative" to differentiate
  between future garbage collectors: precise marksweep / mark-compact /
  refcounting.
2019-07-01 13:03:07 +02:00
Ayke van Laethem
a328bbdff3 main: small refactor in error printing
Use a type switch instead of an if/else chain. This results in much more
readable code.
2019-06-29 19:18:46 +02:00
m-chichikalov
84618c45eb Added supporting suctom TargetSpec json file via -target flag. 2019-06-20 19:10:15 +02:00
Carolyn Van Slyck
c0ff4e566d Include test in helptext 2019-06-20 19:05:06 +02:00
Carolyn Van Slyck
ce9b21a270 Default package name to . when not specified
When running tinygo build, and the positional argument for the
package is not specified, default it to "."
2019-06-20 19:05:06 +02:00
Ayke van Laethem
fa5855bff5 main: add support for -tags flags 2019-06-18 16:02:20 +02:00
Ron Evans
16201c41dc test: replace ExitStatus() with go1.11 compatible syntax
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-06-18 13:45:11 +02:00
Carolyn Van Slyck
208e1719ad Add test command to tinygo (#243)
* Add test command to tinygo
2019-06-18 12:23:59 +02:00
Ayke van Laethem
a3d1f1a514 all: try more locations to find Clang built-in headers
This commit fixes the case where TinyGo was built with `go build` and
LLVM sources were never downloaded into the TinyGo source directory.
2019-06-13 15:21:04 +02:00
Ayke van Laethem
776dc1e0d9 main: show a better error when version detection of GOROOT failed 2019-06-06 13:59:37 +02:00
j7b
0ae467d3e2
llvm cpu features 2019-05-28 15:41:34 +02:00
Ayke van Laethem
7e6a54ac62 main: add build tags for the Go stdlib version 2019-05-24 14:51:40 +02:00
Justin Clift
1113f9ec0c
main: comment the TinyGo IR header line
Without this, clang tries to process the header line as part of
its valid input. eg:

  main.ll:1:1: error: expected top-level entity
  Generated LLVM IR:
  ^
2019-05-10 22:50:18 +02:00
Ayke van Laethem
08ee1916f5 main: fix multiple errors being reported as one 2019-05-08 19:37:08 +02:00
Ayke van Laethem
141a70f401 main: make $GOROOT more robust and configurable
Check various locations that $GOROOT may live, including the location of
the go binary. But make it possible to override this autodetection by
setting GOROOT manually as an environment variable.
2019-05-07 09:14:43 +02:00
Ayke van Laethem
9cad8bd0c8 main: add fallback mechanism for LLVM commands
On Debian, all LLVM commands have a version suffix (clang-8, ld.lld-8,
wasm-ld-8, etc.). However. Most other distributions only provide a
version prefix for Clang and not for all the other commands.

This commit fixes the issue by trying the command with the version
suffix first and falling back to one without if needed.
2019-05-05 17:00:33 +02:00
Ayke van Laethem
1f0595438e main: do not set working directory for Clang invocation
This commit avoids setting the working directory to the TinyGo root when
invocating Clang. This helps to weed out issues before we add support
for bundling Clang in a release.
2019-05-03 11:36:24 +02:00
Ayke van Laethem
1d59a960bc main: allow changing the clang command name 2019-04-30 20:04:04 +02:00
Ayke van Laethem
d155e31b64 all: improve compiler error handling
Most of these errors are actually "todo" or "unimplemented" errors, so
the return type is known. This means that compilation can proceed (with
errors) even though the output will be incorrect. This is useful because
this way, all errors in a compilation unit can be shown together to the
user.
2019-04-26 08:52:10 +02:00
Ayke van Laethem
0fd90c49cc compiler: make panic configurable
Currently defined: abort and trap. -panic=unwind should be implemented
in the future.
2019-04-25 13:56:19 +02:00
Ayke van Laethem
5b34713d41 main: fix linker script includes when running outside TINYGOROOT
This commit adds the TinyGo root directory (`TINYGOROOT`) to the linker
script `-L` search path, so that linker scripts can be found when
running `tinygo` outside of the TinyGo root.

This was already working before when using an external linker by setting
the working directory, but this is not possible when using the internal
linker. However, by adding the root directory to the linker search path
(`-L`), it can now find these linker scripts.

fixes #265
2019-04-17 09:21:15 +02:00
Ayke van Laethem
31d57fd3d1 main: use wasm-ld instead of wasm-ld-8 on macOS
This commit does a few things:
  * remove the -8 suffix on macOS, where it is not necessary
  * add smoke tests for compiling wasm files on Linux and macOS
2019-04-04 12:50:15 +02:00
Ron Evans
d6c2d6e301
main: use OS specific name for llvm-ar-7 tool to ensure that llvm7 toolchain works as expected
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-03-15 12:46:03 +01:00
Ron Evans
2a1dd98661
compiler: support output file using UF2 bootloader format
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-03-06 18:18:23 +01:00
Ayke van Laethem
4f932b6e66 all: use internal objcopy implementation
This lessens the dependency on binutils (e.g. arm-none-eabi-objcopy).
2019-03-04 21:17:56 +01:00
Ron Evans
acaf096586 compiler: extend flash command to support different output file types, based on contents of flash key in target file
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-02-23 11:31:38 +01:00
Ayke van Laethem
0b212cf2f6 all: add macOS support 2019-02-19 15:54:36 +01:00
Ayke van Laethem
92d9b780b5 all: remove init interpretation during IR construction
The interp package does a much better job at interpretation, and is
implemented as a pass on the IR which makes it much easier to compose.
Also, the implementation works much better as it is based on LLVM IR
instead of Go SSA.
2019-02-19 09:08:13 +01:00
Ron Evans
403fee7e06
Add tinygo version subcommand (#172)
* cmd: add tinygo version subcommand to display current software version. Also displayed when usage is displayed
2019-02-08 11:22:47 +01:00
Ayke van Laethem
25cd982263
main: optionally build with LLD
When building statically against LLVM, LLD is also included now. When
included, the built in wasm-ld will automatically be used instead of the
external command.

There is also support for linking ELF files but because lld does not
fully support armv6m this is not yet enabled (it produces a warning).
2019-02-01 13:26:32 +01:00
Ayke van Laethem
9bbb233cf0
main: include prebuilt compiler-rt libraries in release tarball
This avoids depending on clang-7 to build compiler-rt for the most
common ARM microcontrollers.
2019-02-01 13:26:32 +01:00
Ayke van Laethem
5b507593d2
main: give more context when running an external results in an error 2019-02-01 13:26:32 +01:00
Ayke van Laethem
914d383a96
all: update import paths to github.com/tinygo-org/tinygo 2019-01-31 17:43:19 +01:00
Ayke van Laethem
95e18f36d0
main: compile and run a program directly
Do not try to use the ExectutionEngine of Go, instead compile the
program in the conventional way and run the binary.

This fixes some code duplication that causes slight (but problematic)
misbehavior between `tinygo build` and `tinygo run`.
2019-01-16 17:06:34 +01:00
Ayke
107fccb288 all: add support for more architectures and GOOS/GOARCH (#118)
This commit does two things:

  * It adds support for the GOOS and GOARCH environment variables. They
    fall back to runtime.GO* only when not available.
  * It adds support for 3 new architectures: 386, arm, and arm64. For
    now, this is Linux-only.
2019-01-05 11:46:25 +01:00