Skip to content

Commit 2a7e072

Browse files
aykevldeadprogram
authored andcommitted
getting-started: add docs for building TinyGo on Windows
This is probably missing something but it's better than nothing. I've also fixed some errors in the macos and linux guide.
1 parent 77a73ee commit 2a7e072

File tree

3 files changed

+76
-6
lines changed

3 files changed

+76
-6
lines changed

content/getting-started/linux.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,10 @@ sudo apt-get install build-essential git cmake ninja
191191
```
192192

193193
The following command takes care of downloading and building LLVM. It places the
194-
source code in `llvm-build/` and the build output in `llvm/`. It only needs to
195-
be done once until the next LLVM release. Note that the `export` lines are
196-
optional, but using Clang during the build speeds up the build significantly.
194+
source code in `llvm-project/` and the build output in `llvm-build/`. It only
195+
needs to be done once until the next LLVM release. Note that the `export` lines
196+
are optional, but using Clang during the build speeds up the build
197+
significantly.
197198

198199
```shell
199200
export CC=clang

content/getting-started/macos.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ brew install cmake ninja
103103
```
104104

105105
The following command takes care of downloading and building LLVM. It places the
106-
source code in `llvm-build/` and the build output in `llvm/`. It only needs to
107-
be done once until the next LLVM release.
106+
source code in `llvm-project/` and the build output in `llvm-build/`. It only
107+
needs to be done once until the next LLVM release.
108108

109109
```shell
110110
make llvm-build

content/getting-started/windows.md

+70-1
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,73 @@ If you want to use TinyGo to compile your own or sample code, you should be able
9999

100100
## Docker Install
101101

102-
The other option is to use the Docker image. This has the benefit of making no changes to your system but has a large download and installation size. For instructions on using the Docker image, please see the page [here](../using-docker).
102+
Another option is to use the Docker image. This has the benefit of making no changes to your system but has a large download and installation size. For instructions on using the Docker image, please see the page [here](../using-docker).
103+
104+
## Source Install
105+
106+
***If you have already followed the "Windows Native Install" instructions above, you do not need to perform a source install. You are now done with the needed installation. The "Source Install" is for when you want to contribute to TinyGo.***
107+
108+
Be warned that building TinyGo on Windows is not tested as well as building TinyGo on other operating systems (such as Linux). If you want to contribute to TinyGo but don't need to run natively on Windows, it may be easier and faster to do development within [WSL](https://docs.microsoft.com/en-us/windows/wsl/install-win10). See the [Linux page](../linux) for how to build TinyGo on Linux.
109+
110+
### Dependencies
111+
112+
You will need to have the following programs installed on your Windows system and configured to be accessible in your PATH variable:
113+
114+
* Git
115+
* Go 1.14
116+
* MinGW-w64
117+
* GNU Make
118+
* CMake
119+
* Ninja
120+
* Python
121+
122+
The easiest way to install all these dependencies is through [Chocolatey](https://chocolatey.org/). Install Chocolatey first, and then run the following command in a command prompt or PowerShell with administrative privileges:
123+
124+
choco install --confirm git golang mingw make cmake ninja python
125+
126+
Now open a Git Bash window for the remaining steps. The Git Bash window provides a Bash shell with some standard Unix utilities for convenience.
127+
128+
The first thing to do is download the source code:
129+
130+
```shell
131+
git clone --recursive https://github.com/tinygo-org/tinygo.git
132+
cd tinygo
133+
```
134+
135+
Unfortunately there is no way to use a binary release of LLVM to build against (like on Linux and MacOS) so we'll have to build LLVM from scratch. This is a long process which takes at least one hour on most machines.
136+
137+
The following command takes care of downloading and building LLVM. It places the
138+
source code in `llvm-project/` and the build output in `llvm-build/`. It only needs to
139+
be done once until the next LLVM release.
140+
141+
```shell
142+
make llvm-build
143+
```
144+
145+
Once this is finished, you can build TinyGo against this manually built LLVM:
146+
147+
```shell
148+
make
149+
```
150+
151+
This results in a `tinygo.exe` binary in the `build` directory:
152+
153+
```text
154+
$ ./build/tinygo version
155+
tinygo version 0.13.1 windows/amd64 (using go version go1.14.1 and LLVM version 10.0.1)
156+
```
157+
158+
### Additional Requirements for Microcontrollers
159+
160+
Before anything can be built for a bare-metal target, you need to generate some
161+
files first:
162+
163+
```shell
164+
make gen-device
165+
```
166+
167+
This will generate register descriptions, interrupt vectors, and linker scripts
168+
for various devices. Also, you may need to re-run this command after updates,
169+
as some updates cause changes to the generated files.
170+
171+
The same additional requirements to compile TinyGo programs that can run on microcontrollers must be fulfilled when installing TinyGo from source. Please follow [these instructions](#additional-requirements-for-microcontrollers) above.

0 commit comments

Comments
 (0)