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/selfbuild/bring-your-own-llvm.md
+37-12Lines changed: 37 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,9 +14,16 @@ description: >
14
14
| You are using Windows. |
15
15
| Your Linux distribution (if you use Linux) does not ship the right LLVM version. |
16
16
17
+
## System installed LLVM instructions
18
+
19
+
### Installing LLVM
20
+
21
+
See [troubleshooting](#troubleshooting) if running into issues during the instructions.
17
22
18
23
Using a system-installed version of LLVM depends on your system, of course.
19
24
25
+
#### Debian or Ubuntu
26
+
20
27
For **Debian** or **Ubuntu** you can install LLVM by adding a new apt repository. For more information about this method, see [apt.llvm.org](https://apt.llvm.org/). *Before copying the command below, please replace `xxxxx` with your distribution's codename*.
For **MacOS**, you can install LLVM through [Homebrew](https://formulae.brew.sh/formula/llvm). The Clang/LLVM version from Apple is not supported by TinyGo.
46
55
47
56
```shell
48
57
brew install llvm
49
58
```
59
+
#### Fedora
50
60
51
61
For **Fedora** users you can install LLVM from the repository. Note that the version of LLVM [varies by Fedora version](https://packages.fedoraproject.org/pkgs/llvm/llvm-libs/), for example Fedora 37 has LLVM 15.
52
62
53
63
```shell
54
64
sudo dnf install llvm-devel lld-libs lld
55
65
```
56
66
57
-
After LLVM has been installed, installing TinyGo should be as easy as running the following command:
67
+
68
+
### Build TinyGo
69
+
70
+
After LLVM has been installed, installing TinyGo should be as easy as running the following command from within the cloned `tinygo` repository (see [instructions on how to clone](./..)):
58
71
59
72
```shell
60
73
go install
61
74
```
62
75
63
76
You should now have a working TinyGo installation!
64
77
78
+
Below is an example of running `tinygo version` and example output to check that
79
+
TinyGo was installed correctly (copy only what's in front of the `$` sign to your terminal!):
80
+
```shell
81
+
$ tinygo version
82
+
tinygo version 0.31.0-dev-d4189fec linux/amd64 (using go version go1.21.4 and LLVM version 16.0.1)
83
+
```
84
+
85
+
If not see the [troubleshooting](#troubleshooting) section.
86
+
65
87
If you have gotten this far, please refer to [Additional requirements](./additional-requirements) to further set up TinyGo.
66
88
67
-
## Final notes
89
+
## Troubleshooting
68
90
69
91
### `go install` command inner workings
70
92
The `go install` command will build the `tinygo` executable and store it to your currently set `$GOBIN` directory. A couple environment variables must be set for TinyGo to work after running this:
71
93
72
-
* Your `GOBIN` should be set to where you want go binaries to be stored to. Below is an example (for linux systems)
73
-
```shell
74
-
go env -w GOBIN=$HOME/local/bin
75
-
```
76
-
* The directory should exist! Below is a way to create the directory on linux.
77
-
```shell
78
-
mkdir -p $HOME/local/bin
79
-
```
80
-
* Your $PATH environment variable should contain the directory so that you can run `tinygo` from the command line! A reliable way to achieve this can be found at the [Go install page](https://go.dev/doc/install#). For linux it consists of adding the line below to the bottom of your `/etc/profile` file (before the `exit 0`):
94
+
* Your go environment variable `GOBIN` points to where executables are installed with the
95
+
`go install` command. An empty `GOBIN` variable will default to `$HOME/go/bin` path on Linux and MacOS (same as `~/go/bin` with bash).
96
+
You can check Go's environment variables with `go env`. `go env GOBIN` will print
97
+
only `GOBIN`'s value.
98
+
99
+
* Your $PATH environment variable should contain the `GOBIN` directory so that you can run `tinygo` from the command line! A reliable way to achieve this can be found at the [Go install page](https://go.dev/doc/install#). For linux it consists of adding the line below to the bottom of your `/etc/profile` file (before the `exit 0`):
81
100
```
82
-
export PATH=$PATH:$HOME/local/bin
101
+
export PATH=$PATH:$HOME/go/bin
83
102
```
84
103
104
+
### Debian LLVM repository manual addition
105
+
If `sudo apt-get install clang-16 llvm-16-dev lld-16 libclang-16-dev` does not work you
106
+
can try manually adding the repository. Run the following command and try the steps above again.
If you are getting an `gcc` or `g++ not found` error you most likely do not have a working C++ build environment. You'll need the `build-essential` package on Debian or `sudo dnf install make automake gcc gcc-c++` for Fedora based systems.
0 commit comments