Skip to content

Commit 46bdbc8

Browse files
soypatdeadprogram
authored andcommitted
apply more of @gen2thomas suggestions
1 parent 1150f78 commit 46bdbc8

File tree

2 files changed

+38
-13
lines changed

2 files changed

+38
-13
lines changed

content/docs/guides/selfbuild/bring-your-own-llvm.md

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,16 @@ description: >
1414
| You are using Windows. |
1515
| Your Linux distribution (if you use Linux) does not ship the right LLVM version. |
1616

17+
## System installed LLVM instructions
18+
19+
### Installing LLVM
20+
21+
See [troubleshooting](#troubleshooting) if running into issues during the instructions.
1722

1823
Using a system-installed version of LLVM depends on your system, of course.
1924

25+
#### Debian or Ubuntu
26+
2027
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*.
2128

2229
| Distro | Version | Codename |
@@ -42,46 +49,64 @@ sudo apt-get update
4249
sudo apt-get install clang-16 llvm-16-dev lld-16 libclang-16-dev
4350
```
4451

52+
#### MacOS
53+
4554
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.
4655

4756
```shell
4857
brew install llvm
4958
```
59+
#### Fedora
5060

5161
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.
5262

5363
```shell
5464
sudo dnf install llvm-devel lld-libs lld
5565
```
5666

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](./..)):
5871

5972
```shell
6073
go install
6174
```
6275

6376
You should now have a working TinyGo installation!
6477

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+
6587
If you have gotten this far, please refer to [Additional requirements](./additional-requirements) to further set up TinyGo.
6688

67-
## Final notes
89+
## Troubleshooting
6890

6991
### `go install` command inner workings
7092
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:
7193

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`):
81100
```
82-
export PATH=$PATH:$HOME/local/bin
101+
export PATH=$PATH:$HOME/go/bin
83102
```
84103
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.
107+
```shell
108+
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
109+
```
85110

86111
### GCC errors
87112
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.

content/docs/guides/selfbuild/manual-llvm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ This results in a `tinygo` binary in the `build` directory:
7575

7676
```shell
7777
$ ./build/tinygo version
78-
tinygo version 0.30.0 linux/amd64 (using go version go1.21 and LLVM version 16.0.0)
78+
tinygo version 0.31.0-dev-d4189fec linux/amd64 (using go version go1.21.4 and LLVM version 16.0.1)
7979
```
8080

8181
You have successfully built TinyGo from source. Congratulations!

0 commit comments

Comments
 (0)