Commit Graph

189 Commits

Author SHA1 Message Date
Ayke van Laethem 980dceb192 main: refactor build option passing
The list of options passed to build/run/gdb/etc commands was getting
unwieldly and hard to add extra options to. Put all common build options
in a single build config struct so that these options are more
centralized.
2018-10-24 23:53:44 +02:00
Ayke van Laethem e5e09747f0 all: add WebAssembly backend 2018-10-21 19:47:47 +02:00
Ayke van Laethem 9406a4d74a main: add -opt= flag for the optimization level 2018-10-10 14:14:45 +02:00
Ayke van Laethem a63af97e86 all: add emulation support for Cortex-M3 with QEMU 2018-10-08 17:07:19 +02:00
Ayke van Laethem e50c6f1af1 main: generate binary files when compiling to .bin 2018-10-07 22:48:33 +02:00
Ayke van Laethem 22da104530 all: use compiler-rt for builtins 2018-10-07 19:04:29 +02:00
Ayke van Laethem 9d408b7cbc main: hide OCD output by default in gdb subcommand
In most cases, it's useless. But in some cases it may be critical if the
OCD server (like openocd) has a problem.

It would be nice if openocd would differentiate between stdout and
stderr, and only write errors to stderr. But sadly it doesn't.
2018-10-03 19:33:36 +02:00
Ayke van Laethem b08c8a0cf0 all: implement gdb sub-command for easy debugging 2018-10-03 19:03:22 +02:00
Ayke van Laethem f107a24b72 all: use LLVM library provided by the system 2018-09-30 15:10:04 +02:00
Ayke van Laethem 802350f8da main: helpful error message for flash cmd without -target 2018-09-29 22:39:44 +02:00
Ayke van Laethem b6db84e916 main: use GOPATH from the environment
Be more compatible with the Go toolchain by setting GOPATH in the same
way. This makes it possible to flash and run examples from the standard
GOPATH instead of only from the source tree.
2018-09-29 22:30:45 +02:00
Ayke van Laethem 0e813c4cb7 main: add -no-debug flag to avoid DWARF debug info 2018-09-25 20:17:46 +02:00
Ayke van Laethem ed227b8fd3 all: fix errors reported by go vet 2018-09-24 17:22:59 +02:00
Ayke van Laethem a2eaaa42a0 main: optimize 'tinygo run'
Apparently -Oz without inliner is the fastest, probably because it
removes code that would otherwise need to be emitted.

TODO: does this mean that the ExecutionEngine compiles the module before
running it? Can we control this?
2018-09-24 16:22:09 +02:00
Ayke van Laethem 6191d4e1ac compiler: rename .Parse() to .Compiler()
The fact it was called Parse() is more of a historical accident, as the
compiler started out using the Go AST directly instead of Go SSA.
2018-09-24 15:55:38 +02:00
Ayke van Laethem 8a468786df compiler: use config struct for options 2018-09-24 15:46:05 +02:00
Ayke van Laethem fd6dda5e4f main: run the compiler from any path 2018-09-24 12:25:33 +02:00
Ayke van Laethem b2cbfa78ca compiler: refactor compiler into separate package 2018-09-22 20:32:28 +02:00
Ayke van Laethem 895d109fc4 compiler: run flash command in a shell 2018-09-22 01:40:46 +02:00
Ayke van Laethem 87963d3d5b compiler: add -size flag to replace size utility
The size flag has two modes:
  -size=short: prints data basically equivalent to the `size` program.
  -size=full:  tries to determine sizes per package (not entirely
               accurate).
2018-09-18 00:04:21 +02:00
Ayke van Laethem e04f0868ed compiler: fix constant globals on AVR
Turn const globals into non-const globals, at least until pointers have
the correct address space attribute.
2018-09-16 16:31:38 +02:00
Ayke van Laethem a25e598463 compiler: truncate output files before writing 2018-09-16 13:41:56 +02:00
Ayke van Laethem 112f6dc01a all: implement tinygo flash command
This will now just work:

    tinygo flash -target=arduino examples/blinky1
2018-09-14 20:59:28 +02:00
Ayke van Laethem 09cbd223c3 compiler: remove -runtime flag
It is not necessary anymore.
2018-09-14 20:56:48 +02:00
Ayke van Laethem c763e9f1a6 compiler: produce .hex files directly 2018-09-14 20:27:04 +02:00
Ayke van Laethem 914cd56ca5 all: support Arduino in the compiler driver
This makes sure the compiler itself can build/link an ELF file that
works on an Arduino.
2018-09-12 20:55:50 +02:00
Ayke van Laethem 865520b571 compiler: act as a compiler driver (on unix systems)
As a final step, link the object file with the system compiler/linker.
TODO: cross compiling.
2018-09-12 19:59:13 +02:00
Ayke van Laethem 6ab2b30984 compiler: move output file type selection to main.go 2018-09-12 19:11:50 +02:00
Ayke van Laethem 9bec479041 all: make targets configurable with a JSON file
This is intentionally similar to the target specifications in Rust:
https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/spec/struct.TargetOptions.html
2018-09-12 18:28:39 +02:00
Ayke van Laethem 20c2552f8a compiler: add 'run' command for bytecode interpretation 2018-09-12 17:26:56 +02:00
Ayke van Laethem 8362751590 compiler: use runtime.GOOS/GOARCH instead of hardcoding build tags 2018-09-12 17:25:43 +02:00
Ayke van Laethem e9b0a7d2ae compiler: improve command line errors 2018-09-12 17:25:14 +02:00
Ayke van Laethem 0779ee6088 compiler: improve command line argument parsing
To get more compatibility with the go command, implement a similar
command line interface (with "tinygo build <package>" etc.).
Other than that, an all-round cleanup of command parsing.
2018-09-12 17:23:36 +02:00
Ayke van Laethem 83ad0b6137 all: move bootstrapping IR to Go runtime
This has the benefit of not requiring a 'runtime' IR file, so that
complete relocatable files can be built without requiring input IR.
This makes the compiler a lot easier to use without the Makefile.

Code size is not affected.
2018-09-04 21:18:26 +02:00
Ayke van Laethem 0746d61639 compiler: move optimizer into the binary 2018-09-04 19:20:49 +02:00
Ayke van Laethem bf160d096b Move lenType definition to runtime (partially) 2018-08-29 20:48:56 +02:00
Ayke van Laethem a30ffa5c1e Revert "Move coroutine passes from Makefile to compiler itself"
This reverts commit d9ca5f97fb.

There is a problem with coroutines that I haven't solved yet. Reverting
makes it work, for now.

Also, use a better coroutines flag for the LLVM opt tool.
2018-08-20 20:24:54 +02:00
Ayke van Laethem d9ca5f97fb Move coroutine passes from Makefile to compiler itself
This is much more convenient.
2018-08-20 04:31:01 +02:00
Ayke van Laethem 4af2bcb6a9 Split up tgo.go 2018-08-18 01:11:25 +02:00