docs: update installation instructions
* Update to system-installed LLVM. * Avoid the use of make.
Этот коммит содержится в:
родитель
f107a24b72
коммит
a2e57b40f9
1 изменённых файлов: 31 добавлений и 33 удалений
|
@ -11,8 +11,7 @@ Requirements
|
||||||
These are the base requirements and enough for most (desktop) use.
|
These are the base requirements and enough for most (desktop) use.
|
||||||
|
|
||||||
* Go 1.11+
|
* Go 1.11+
|
||||||
* LLVM dependencies, see the Software section in the `LLVM build guide
|
* LLVM 7 (for example, from `apt.llvm.org <http://apt.llvm.org/>`_)
|
||||||
<https://llvm.org/docs/GettingStarted.html#software>`_.
|
|
||||||
|
|
||||||
Linking a binary needs an installed C compiler (``cc``). At the moment it
|
Linking a binary needs an installed C compiler (``cc``). At the moment it
|
||||||
expects GCC or a recent Clang.
|
expects GCC or a recent Clang.
|
||||||
|
@ -45,52 +44,51 @@ needs the following tools:
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
First download the sources. This may take a few minutes. ::
|
First download the sources. This may take a while. ::
|
||||||
|
|
||||||
go get -u github.com/aykevl/tinygo
|
go get -u github.com/aykevl/tinygo
|
||||||
|
|
||||||
You'll get an error like the following, this is expected::
|
If you get an error like this::
|
||||||
|
|
||||||
src/github.com/aykevl/llvm/bindings/go/llvm/analysis.go:17:10: fatal error: 'llvm-c/Analysis.h' file not found
|
/usr/local/go/pkg/tool/linux_amd64/link: running g++ failed: exit status 1
|
||||||
#include "llvm-c/Analysis.h" // If you are getting an error here read bindings/go/README.txt
|
/usr/bin/ld: error: cannot find -lLLVM-7
|
||||||
^~~~~~~~~~~~~~~~~~~
|
cgo-gcc-prolog:58: error: undefined reference to 'LLVMVerifyFunction'
|
||||||
1 error generated.
|
cgo-gcc-prolog:80: error: undefined reference to 'LLVMVerifyModule'
|
||||||
|
[...etc...]
|
||||||
|
|
||||||
To continue, you'll need to build LLVM. As a first step, modify
|
It means something is wrong with your LLVM installation. Make sure LLVM 7 is
|
||||||
github.com/aykevl/llvm/bindings/go/build.sh::
|
installed (Debian package ``llvm-7-dev``). If it still doesn't work, you can
|
||||||
|
try running::
|
||||||
|
|
||||||
cmake_flags="../../../../.. $@ -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AVR -DLLVM_LINK_LLVM_DYLIB=ON"
|
cd $GOPATH/github.com/aykevl/go-llvm
|
||||||
|
make config
|
||||||
|
|
||||||
This will enable the experimental AVR backend (for Arduino support) and will
|
And retry::
|
||||||
make sure ``tinygo`` links to a shared library instead of a static library,
|
|
||||||
greatly improving link time on every rebuild. This is especially useful during
|
|
||||||
development.
|
|
||||||
|
|
||||||
The next step is actually building LLVM. This is done by running this command
|
go install github.com/aykevl/tinygo
|
||||||
inside github.com/aykevl/llvm/bindings/go::
|
|
||||||
|
|
||||||
$ ./build.sh
|
Usage
|
||||||
|
-----
|
||||||
|
|
||||||
This will take about an hour and require a fair bit of RAM. In fact, I would
|
TinyGo should now be installed. Test it by running a test program::
|
||||||
recommend setting your ``ld`` binary to ``gold`` to speed up linking, especially
|
|
||||||
on systems with less than 16GB RAM.
|
|
||||||
|
|
||||||
After LLVM has been built, you can run an example with::
|
tinygo run examples/test
|
||||||
|
|
||||||
make run-test
|
Before anything can be built for a bare-metal target, you need to generate some
|
||||||
|
files first::
|
||||||
|
|
||||||
For a blinky example on the PCA10040 development board, do this::
|
make gen-device
|
||||||
|
|
||||||
make flash-blinky2 TARGET=pca10040
|
This will generate register descriptions, interrupt vectors, and linker scripts
|
||||||
|
for various devices. Also, you may need to re-run this command after updates,
|
||||||
|
as some updates cause changes to the generated files.
|
||||||
|
|
||||||
Note that you will have to execute the following commands before the blinky
|
Now you can run a blinky example. For the `PCA10040
|
||||||
example will work::
|
<https://www.nordicsemi.com/eng/Products/Bluetooth-low-energy/nRF52-DK>`_
|
||||||
|
development board::
|
||||||
|
|
||||||
git submodule update --init
|
tinygo flash -target=pca10040 examples/blinky2
|
||||||
make gen-device-nrf
|
|
||||||
|
|
||||||
You can also run a simpler blinky example (blinky1) on the Arduino::
|
Or for an `Arduino Uno <https://store.arduino.cc/arduino-uno-rev3>`_::
|
||||||
|
|
||||||
git submodule update --init # only required the first time
|
tinygo flash -target=arduino examples/blinky1
|
||||||
make gen-device-avr # only required the first time
|
|
||||||
make flash-blinky1 TARGET=arduino
|
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче