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

70 коммитов

Автор SHA1 Сообщение Дата
Ayke van Laethem
11567c62d4 cgo: refactor; support multiple cgo files in a single package
This is a big commit that does a few things:

  * It moves CGo processing into a separate package. It never really
    belonged in the loader package, and certainly not now that the
    loader package may be refactored into a driver package.
  * It adds support for multiple CGo files (files that import package
    "C") in a single package. Previously, this led to multiple
    definition errors in the Go typecheck phase because certain C
    symbols were defined multiple times in all the files. Now it
    generates a new fake AST that defines these, to avoid multiple
    definition errors.
  * It improves debug info in a few edge cases that are probably not
    relevant outside of bugs in cgo itself.
2019-05-12 10:49:15 +02:00
Ayke van Laethem
eb0ce8a298 Makefile: avoid libtinfo and libz dependency of LLVM
These two dependencies are optional but enabled by default when
available. Disable them in the Makefile so that the tinygo binary is
portable to systems that don't have them or have a different version
(for example, Arch has a newer version of libcurses and thus libtinfo).
2019-05-11 15:47:15 +02:00
Ayke van Laethem
2f2d62cc0c cgo: support builtin #include headers
Add support for header files bundled with the compiler by copying them
into the release tarball.
2019-04-25 12:55:52 +02:00
Ayke van Laethem
6c63a0d6e7 Makefile: build static binaries only
This replaces the older way which just does the following:

    go install .

and

    go test -v .

Instead, `make` and `make test` will now build TinyGo statically linked
against LLVM, so that `go install` and `go test -v` should be used
manually.
2019-04-17 23:15:37 +02:00
Ayke van Laethem
0d2a3ce532 Makefile: check whether LLVM was build before making a static binary 2019-04-17 19:13:42 +02:00
Ron Evans
f1aea13c51 tools: remove Makefile tasks that are redundant thanks to TinyGo improvements
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-04-16 14:08:31 +02:00
Ayke van Laethem
02ecab833f all: check formatting on CI 2019-04-13 19:58:58 +02:00
Ayke van Laethem
2e926789f5 circleci: do macOS builds here instead of on Travis CI
This provides several advantages. Among others:
  * Much faster and hopefully more reliable.
  * Good caching support to store LLVM builds.
  * Building and testing of release-ready artifacts.
2019-04-08 09:13:16 +02:00
Ayke van Laethem
ebebdd5651 circleci: build LLVM statically 2019-04-05 13:30:38 +02:00
Ayke van Laethem
1778d92858 Makefile: automatically build LLVM when needed 2019-04-05 13:30:38 +02:00
Ayke van Laethem
86f8778748 darwin: use custom syscall pkg that uses libsystem
Go 1.12 switched to using libSystem.dylib for system calls, because
Apple recommends against doing direct system calls that Go 1.11 and
earlier did. For more information, see:
  https://github.com/golang/go/issues/17490
  https://developer.apple.com/library/archive/qa/qa1118/_index.html

While the old syscall package was relatively easy to support in TinyGo
(just implement syscall.Syscall*), this got a whole lot harder with Go
1.12 as all syscalls now go through CGo magic to call the underlying
libSystem functions. Therefore, this commit overrides the stdlib syscall
package with a custom package that performs calls with libc (libSystem).
This may be useful not just for darwin but for other platforms as well
that do not place the stable ABI at the syscall boundary like Linux but
at the libc boundary.

Only a very minimal part of the syscall package has been implemented, to
get the tests to pass. More calls can easily be added in the future.
2019-04-05 09:53:51 +02:00
Ron Evans
2d5bc836f5 build: correct Makefile to build tinygo executable correctly when build directory does not exist, such as after running 'make clean'
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-02-19 12:28:50 +01:00
Ayke van Laethem
709a296150 os: add basic OS functionality 2019-02-05 17:37:55 +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
05d2c14600
all: add static and release Makefile targets 2019-02-01 13:26:32 +01:00
Ayke van Laethem
8aed8d8c56
Makefile: rename tgo to tinygo 2019-02-01 13:26:32 +01:00
Ron Evans
8d1284cfe7
generator: generate device wrappers for Atmel SAM family
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-01-13 18:59:56 +01:00
Ron Evans
8734732d0c
build: Makefile needs to look at changes in all needed sub-directories to decide if rebuild is required
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-11 12:55:03 +01:00
Ayke van Laethem
e10d05c74f
loader: switch to custom program loader 2018-12-10 15:36:23 +01:00
Ron Evans
8325f2a53d
reelboard: support Reel Board (nrf52840 dev board)
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-12-01 18:25:36 +01:00
Ayke van Laethem
9392ef900d
avr: add support for the digispark
Blinking the on-board LED works. Nothing else has been tested yet.
2018-11-20 18:50:24 +01:00
Ayke van Laethem
bb3d05169d
interp: add new compile-time package initialization interpreter
This interpreter currently complements the Go SSA level interpreter. It
may stay complementary or may be the only interpreter in the future.

This interpreter is experimental and not yet finished (there are known
bugs!) so it is disabled by default. It can be enabled by passing the
-initinterp flag.

The goal is to be able to run all initializations at compile time except
for the ones having side effects. This mostly works except perhaps for a
few edge cases.

In the future, this interpeter may be used to actually run regular Go
code, perhaps in a shell.
2018-11-04 18:40:51 +01:00
Ayke van Laethem
a63af97e86
all: add emulation support for Cortex-M3 with QEMU 2018-10-08 17:07:19 +02:00
Ron Evans
269bef5494
microbit: add Makefile entries for target=microbit
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-10-07 19:06:00 +02:00
Ayke van Laethem
bdcac9ae42
Makefile: add gen-device-stm32 to gen-device target 2018-10-02 13:30:49 +02:00
Ayke van Laethem
eac81e5232
Makefile: run verbose 'make test' 2018-09-30 18:01:14 +02:00
Ayke van Laethem
d190bfccf6
Makefile: add 'make test' that runs go test 2018-09-25 13:49:03 +02:00
Ayke van Laethem
dc88948f55
Makefile: go fmt testdata/*.go 2018-09-25 13:45:50 +02:00
Ayke van Laethem
a86739d235
Makefile: add new packages to tgo dependencies 2018-09-23 01:17:46 +02:00
Ayke van Laethem
b2cbfa78ca
compiler: refactor compiler into separate package 2018-09-22 20:32:28 +02:00
Ayke van Laethem
b75a02e66d
compiler: refactor IR parts into separate package 2018-09-22 20:32:07 +02:00
Ayke van Laethem
c8587c7d1e
Makefile: go fmt more packages 2018-09-22 17:44:42 +02:00
Ayke van Laethem
dd5b5a381c
stm32: initial support 2018-09-22 01:51:44 +02:00
Ayke van Laethem
7c16f6c904
tools/gen-device-svd: make source URL configurable 2018-09-22 01:20:34 +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
13633133a5
Makefile: simplify make fmt
There is no C source file anymore `go fmt` will complain about.
2018-09-14 20:57:21 +02:00
Ayke van Laethem
e389d38dec
Makefile: improve gen-device* commands 2018-09-13 00:55:49 +02:00
Ayke van Laethem
18b3e8d156
gen-device: move to new tools directory 2018-09-13 00:55:18 +02:00
Ayke van Laethem
5e9e3bd1a0
Makefile: use the compiler driver directly 2018-09-12 23:55:13 +02:00
Ayke van Laethem
8ce139284a
all: remove last traces of the C runtime
This increases code size on the nrf, but it is a fixed increase and can
hopefully be reduced in the future.
The Makefile gets a lot smaller with this which is a huge advantage
(less build time complexity).
2018-09-12 23:26:30 +02:00
Ayke van Laethem
f7f7d4cbbc
runtime/nrf: translate nrf sleep function from C to Go
This is the last critical part of the C runtime.

Code size is reduced by 4 bytes for examples/blinky2 (probably due to
inlining) and is unchanged for examples/test.
2018-09-12 22:24:17 +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
9101ea11bf
examples: clean up examples and add blinky1 for Arduino
Arduino has trouble supporting anything that's not extremely simple, so
add a simple blinky example for it. Also, it may be useful anyway.
2018-09-05 16:40:46 +02:00
Ayke van Laethem
17b5b6ec5b
all: use less magic in memory-mapped IO
Don't store addresses in the values of registers, this leads to problems
with char arrays (among others). Instead, do it like it's done in C with
raw addresses cast to struct pointers.

This commit also splits gen-device.py, as AVR and ARM have very
different ideas of what a register is. It's easier to just keep them
separate.
2018-09-05 12:18:21 +02:00
Ayke van Laethem
93248c93ed
avr: remove device files, use them from a subrepository
These files don't really belong in this repository. It's better to
generate them automatically from a source, like the one provided by the
avr-rust project. So a new command `make gen-device-avr` has been
provided for this purpose.
2018-09-05 12:13:33 +02:00
Ayke van Laethem
92877f8371
Makefile: some cleanups
Remove $(GCC) and $(LLC) which were not used anymore, and display binary
size even when building for the host.
2018-09-04 21:32:56 +02:00
Ayke van Laethem
0746d61639
compiler: move optimizer into the binary 2018-09-04 19:20:49 +02:00
Ayke van Laethem
d4f5700625
Remove use of CGo in the runtime
CGo depends on syscall, which (in the standard library) depends on sync,
which depends on the runtime. There are also other import cycles. To be
able to use the syscall package from upstream, stop using CGo.
2018-08-29 20:01:33 +02:00
Ayke van Laethem
5f28b07f75
Enable aggressive code size optimizations: -Oz 2018-08-24 03:35:39 +02:00