You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/guides/build/_index.md
+45-2Lines changed: 45 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,9 @@ You'll need [Go](https://go.dev) installed on your machine to build TinyGo. The
11
11
12
12
A major dependency of TinyGo is [LLVM](https://llvm.org/). You can either use a version of LLVM already on your system or build LLVM manually. Building manually takes a long time (around an hour depending on how fast your system is) so it is recommended to use a version of LLVM already on your system if that's possible. The links provided below show how to install LLVM one way or the other.
13
13
14
-
### Repository cloning (before build)
14
+
15
+
16
+
## Repository cloning (before build)
15
17
Start with getting the source code. On Windows, you might want to install the [build dependencies](#build-dependencies) first.
16
18
17
19
```shell
@@ -31,4 +33,45 @@ Once the branch is selected, pull submodules:
31
33
git submodule update --init --recursive
32
34
```
33
35
34
-
Now you are ready to build TinyGo- but you must choose whether to build with a [manual LLVM install](./manual-llvm) or with a [system installed LLVM](./bring-your-own-llvm). After building you should also read [additional requirements](./additional-requirements) to make sure you've fulfilled all the requirements for the features of TinyGo you'll be using.
36
+
Now you are ready to build TinyGo- but you must choose whether to build with a [manual LLVM install](./manual-llvm) or with a [system installed LLVM](./bring-your-own-llvm). After building you should also read [additional requirements](./additional-requirements) to make sure you've fulfilled all the requirements for the features of TinyGo you'll be using.
37
+
38
+
## Uninstalling TinyGo
39
+
It's highly suggested you uninstall an existing installation of TinyGo before proceeding.
40
+
41
+
***If you installed TinyGo via a package manager the command will depend on your operating system.***
42
+
43
+
**Linux Debian and Ubuntu** users may run the following command to uninstall TinyGo:
44
+
```shell
45
+
sudo apt remove tinygo
46
+
```
47
+
48
+
---
49
+
50
+
**Linux Fedora** users may uninstall TinyGo with:
51
+
```shell
52
+
sudo dnf remove tinygo
53
+
```
54
+
55
+
---
56
+
57
+
**MacOS** users may uninstall TinyGo with the following command:
58
+
```shell
59
+
brew uninstall tinygo
60
+
```
61
+
62
+
---
63
+
64
+
**Windows** users who installed with Scoop may run the following command to uninstall TinyGo:
65
+
```shell
66
+
scoop uninstall tinygo
67
+
```
68
+
69
+
---
70
+
71
+
**Any OS with a manually installed TinyGo**: Remove the cloned repository. This will remove LLVM along with the TinyGo root.
72
+
73
+
You should also check if there's a remaining `tinygo` executable in your path and remove it too.
74
+
75
+
**Linux and MacOS** run `echo $(which tinygo)` to print the path to the existing TinyGo executable.
76
+
77
+
**Windows** users may run `where tinygo` to see the where any remaining TinyGo executable is located at.
**Fedora** users may install all required tools with:
26
29
```shell
27
30
sudo dnf groupinstall "Development Tools"
28
31
sudo dnf install cmake ninja-build
29
32
```
30
33
31
-
On MacOS you can install these tools using [Homebrew](https://brew.sh/):
34
+
---
35
+
36
+
**MacOS** users may install these tools using [Homebrew](https://brew.sh/):
32
37
33
38
```shell
34
39
brew install cmake ninja
35
40
```
36
41
37
-
On Windows you can install them using [Chocolatey](https://chocolatey.org/). Install Chocolatey first, then run the following in a command prompt or PowerShell with administrative privileges:
42
+
---
43
+
44
+
**Windows** users may install build dependencies using [Chocolatey](https://chocolatey.org/). Install Chocolatey first, then run the following in a command prompt or PowerShell with administrative privileges:
38
45
39
46
```shell
40
47
choco install --confirm git golang mingw make cmake ninja python
41
48
```
42
-
43
-
Use *Git Bash* (installed above) to run all the build commands like `make`. The TinyGo build system expects a Unix-like environment that is not normally provided by Windows but is included already in *Git Bash*.
49
+
**Windows** users should also use *Git Bash* (installed above) to run all the build commands like `make`. The TinyGo build system expects a Unix-like environment that is not normally provided by Windows but is included already in *Git Bash*.
44
50
45
51
Choco doesn't seem to add CMake automatically to the `$PATH` variable. You can do this manually if needed, in Git bash:
46
52
47
53
```shell
48
54
export PATH="$PATH:/c/Program Files/CMake/bin"
49
55
```
50
56
51
-
#### Building LLVM
57
+
## Building LLVM
58
+
***The following instructions are common to all operating systems.***
59
+
60
+
Background: *[LLVM](https://llvm.org/) is used by TinyGo to create smaller programs than can be compiled with normal Go distribution. It is commonly referred to as a *compiler infrastructure* since it provides several tools to build, link and optimize programs which adhere to its framework.*
61
+
52
62
We build LLVM from inside the TinyGo repository we cloned in the [previous step](../). The following command when run inside the TinyGo repo will take care of first downloading the LLVM source code to later build it in the next step. It places the source code in `llvm-project/` and the build output in `llvm-build/`. It only needs to be done once until the next LLVM release (every half year).
53
63
54
64
Note that the build step may take some time- feel free to grab a drink meanwhile. Warnings emitted through the compilation in this part are normal as of LLVM 17.
@@ -64,7 +74,7 @@ make llvm-source llvm-build CCACHE=OFF
64
74
```
65
75
66
76
67
-
####Building TinyGo
77
+
## Building TinyGo
68
78
69
79
Once this is finished, you can build TinyGo against this manually built LLVM:
70
80
@@ -81,7 +91,8 @@ tinygo version 0.31.0-dev-d4189fec linux/amd64 (using go version go1.21.4 and LL
81
91
82
92
You have successfully built TinyGo from source. Congratulations!
83
93
84
-
To run TinyGo from any directory you may want to move the built binary to a location on your path
94
+
95
+
**Linux** users may choose to run TinyGo from any directory you may want to move the built binary to a location on your path
85
96
or add the `./build` directory to your path. The following shell command moves the TinyGo binary to `/user/bin`. You may need root privileges to complete this step.
0 commit comments