1
1
# Building TinyGo
2
2
3
- TinyGo depends on LLVM and libclang, which are both big C++ libraries. There are
4
- two ways these can be linked: dynamically and statically. The default is dynamic
5
- linking because it is fast and works almost out of the box on Debian-based
6
- systems with the right libraries installed.
3
+ TinyGo depends on LLVM and libclang, which are both big C++ libraries. It can
4
+ also optionally use a built-in lld to ease cross compiling. There are two ways
5
+ these can be linked: dynamically and statically. The default is dynamic linking
6
+ because it is fast and works almost out of the box on Debian-based systems with
7
+ the right libraries installed.
7
8
8
- This guide describes how to statically link TinyGo against LLVM and libclang so
9
- that the binary can be easily moved between systems.
9
+ This guide describes how to statically link TinyGo against LLVM, libclang and
10
+ lld so that the binary can be easily moved between systems.
10
11
11
12
## Dependencies
12
13
13
- LLVM and Clang are both quite light on dependencies, requiring only standard
14
+ LLVM, Clang and LLD are quite light on dependencies, requiring only standard
14
15
build tools to be built. Go is of course necessary to build TinyGo itself.
15
16
16
17
* Go (1.11+)
@@ -30,14 +31,15 @@ The first step is to get the source code. Place it in some directory, assuming
30
31
31
32
git clone -b release_70 https://github.com/llvm-mirror/llvm.git $HOME/src/llvm
32
33
git clone -b release_70 https://github.com/llvm-mirror/clang.git $HOME/src/llvm/tools/clang
34
+ git clone -b release_70 https://github.com/llvm-mirror/lld.git $HOME/src/llvm/tools/lld
33
35
go get -d github.com/tinygo-org/tinygo
34
36
cd $HOME/go/src/github.com/tinygo-org/tinygo
35
37
dep ensure -vendor-only # download dependencies
36
38
37
- Note that Clang must be placed inside the tools subdirectory of LLVM to be
38
- automatically built with the rest of the system.
39
+ Note that Clang and LLD must be placed inside the tools subdirectory of LLVM to
40
+ be automatically built with the rest of the system.
39
41
40
- ## Build LLVM and Clang
42
+ ## Build LLVM, Clang, LLD
41
43
42
44
Building LLVM is quite easy compared to some other software packages. However,
43
45
the default configuration is _ not_ optimized for distribution. It is optimized
@@ -86,10 +88,10 @@ This can take over an hour depending on the speed of your system.
86
88
## Build TinyGo
87
89
88
90
Now that you have a working version of LLVM, build TinyGo using it. You need to
89
- specify the directories to the LLVM build directory and to the Clang source.
91
+ specify the directories to the LLVM build directory and to the Clang and LLD source.
90
92
91
93
cd $HOME/go/src/github.com/tinygo-org/tinygo
92
- make static LLVM_BUILDDIR=$HOME/src/llvm-build CLANG_SRC=$HOME/src/llvm/tools/clang
94
+ make static LLVM_BUILDDIR=$HOME/src/llvm-build CLANG_SRC=$HOME/src/llvm/tools/clang LLD_SRC=$HOME/src/llvm/tools/lld
93
95
94
96
## Verify TinyGo
95
97
@@ -98,7 +100,7 @@ Try running TinyGo:
98
100
./build/tinygo help
99
101
100
102
Also, make sure the ` tinygo ` binary really is statically linked. Check this
101
- using ` ldd ` :
103
+ using ` ldd ` (not to be confused with ` lld ` ) :
102
104
103
105
ldd ./build/tinygo
104
106
0 commit comments