Skip to content

Commit 4463c3f

Browse files
committed
Automatically download up-to-date Clang from Chromium project.
1 parent 93bcd2f commit 4463c3f

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@
1919
[submodule "deps/boringssl"]
2020
path = deps/boringssl
2121
url = https://boringssl.googlesource.com/boringssl
22+
[submodule "deps/clang"]
23+
path = deps/clang
24+
url = https://chromium.googlesource.com/chromium/src/tools/clang.git

Makefile

+25-7
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
# You may override the following vars on the command line to suit
1818
# your config.
19-
CC=clang-5.0
20-
CXX=clang++-5.0
19+
CC=$(shell pwd)/deps/llvm-build/Release+Asserts/bin/clang
20+
CXX=$(shell pwd)/deps/llvm-build/Release+Asserts/bin/clang++
2121
CFLAGS=-O2 -Wall
2222
CXXFLAGS=$(CFLAGS)
2323
BUILD=0
@@ -167,7 +167,7 @@ stylecheck:
167167
# ====================================================================
168168
# Dependencies
169169

170-
DEPS=capnproto ekam libseccomp libsodium node-capnp node boringssl
170+
DEPS=capnproto ekam libseccomp libsodium node-capnp node boringssl clang
171171

172172
# We list remotes so that if projects move hosts, we can pull from their new
173173
# canonical location.
@@ -178,6 +178,7 @@ REMOTE_libsodium=https://github.com/jedisct1/libsodium.git stable
178178
REMOTE_node-capnp=https://github.com/kentonv/node-capnp.git node8
179179
REMOTE_node=https://github.com/sandstorm-io/node sandstorm
180180
REMOTE_boringssl=https://boringssl.googlesource.com/boringssl master
181+
REMOTE_clang=https://chromium.googlesource.com/chromium/src/tools/clang.git master
181182

182183
deps/capnproto/.git:
183184
@# Probably user forgot to checkout submodules. Do it for them.
@@ -199,10 +200,27 @@ update-deps:
199200
git rebase FETCH_HEAD && \
200201
cd ../..;)
201202

203+
# ====================================================================
204+
# Get Clang
205+
#
206+
# We use the prebuilt Clang binaries from the Chromium project. We do this because I've observed
207+
# Sandstorm contributors have a very hard time installing up-to-date versions of Clang on typcial
208+
# Linux distros. Ubuntu and Debian ship with outdated versions of Clang, which means people have
209+
# to install Clang from the LLVM apt repo. However, people struggle to set that up, and the repo
210+
# has been known to randomly break from time to time. OTOH, the Chromium project maintains a very
211+
# up-to-date version of Clang which is used to build Chrome, conveniently maintained as a git repo
212+
# (which we can pin to a commit) containing a nice script that will download precompiled binaries.
213+
214+
deps/llvm-build: | tmp/.deps
215+
@$(call color,downloading Clang binaries from Chromium project)
216+
@deps/clang/scripts/update.py
217+
@mv third_party/llvm-build deps
218+
@rmdir third_party
219+
202220
# ====================================================================
203221
# build BoringSSL
204222

205-
deps/boringssl/build/Makefile: | tmp/.deps
223+
deps/boringssl/build/Makefile: | tmp/.deps deps/llvm-build
206224
@$(call color,configuring BoringSSL)
207225
@mkdir -p deps/boringssl/build
208226
cd deps/boringssl/build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(CC)" -DCMAKE_CXX_COMPILER="$(CXX)" -DCMAKE_C_FLAGS="-fPIE" -DCMAKE_CXX_FLAGS="-fPIE" ..
@@ -214,7 +232,7 @@ deps/boringssl/build/ssl/libssl.a: deps/boringssl/build/Makefile
214232
# ====================================================================
215233
# build libsodium
216234

217-
deps/libsodium/build/Makefile: | tmp/.deps
235+
deps/libsodium/build/Makefile: | tmp/.deps deps/llvm-build
218236
@$(call color,configuring libsodium)
219237
@mkdir -p deps/libsodium/build
220238
cd deps/libsodium/build && ../configure --disable-shared CC="$(CC)"
@@ -233,13 +251,13 @@ tmp/ekam-bin: tmp/.deps
233251
(cd deps/ekam && $(MAKE) bin/ekam-bootstrap && \
234252
cd ../.. && ln -s ../deps/ekam/bin/ekam-bootstrap tmp/ekam-bin)
235253

236-
tmp/.ekam-run: tmp/ekam-bin src/sandstorm/* tmp/.deps deps/boringssl/build/ssl/libssl.a deps/libsodium/build/src/libsodium/.libs/libsodium.a
254+
tmp/.ekam-run: tmp/ekam-bin src/sandstorm/* tmp/.deps deps/boringssl/build/ssl/libssl.a deps/libsodium/build/src/libsodium/.libs/libsodium.a | deps/llvm-build
237255
@$(call color,building sandstorm with ekam)
238256
@CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS2)" CXXFLAGS="$(CXXFLAGS2)" \
239257
LIBS="$(LIBS2)" NODEJS=$(NODEJS) tmp/ekam-bin -j$(PARALLEL)
240258
@touch tmp/.ekam-run
241259

242-
continuous: tmp/.deps deps/boringssl/build/ssl/libssl.a deps/libsodium/build/src/libsodium/.libs/libsodium.a
260+
continuous: tmp/.deps deps/boringssl/build/ssl/libssl.a deps/libsodium/build/src/libsodium/.libs/libsodium.a | deps/llvm-build
243261
@CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS2)" CXXFLAGS="$(CXXFLAGS2)" \
244262
LIBS="$(LIBS2)" NODEJS=$(NODEJS) ekam -j$(PARALLEL) -c -n :41315 || \
245263
($(call color,You probably need to install ekam and put it on your path; see github.com/sandstorm-io/ekam) && false)

deps/clang

Submodule clang added at 0a9737b

docs/install.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,22 @@ Please install the following:
142142
* `golang-go`
143143
* `cmake`
144144
* discount (markdown parser)
145-
* [Clang compiler](http://clang.llvm.org/) version 3.4 or better
146145
* [Meteor](http://meteor.com)
147146

148147
On Debian or Ubuntu, you should be able to get all these with:
149148

150149
sudo apt-get install build-essential libcap-dev xz-utils zip \
151-
unzip strace curl clang discount git python zlib1g-dev \
152-
golang-go
150+
unzip strace curl discount git python zlib1g-dev \
151+
golang-go cmake
153152
curl https://install.meteor.com/ | sh
154153

154+
If you have trouble getting the build to work on your distro, we recommend trying in a virtual
155+
machine running the latest stable Debian release. This is easy to set up using Vagrant, like:
156+
157+
vagrant init debian/contrib-stretch64
158+
vagrant up
159+
vagrant ssh
160+
155161
### Get the source code
156162

157163
Get the source code from the git repository:

0 commit comments

Comments
 (0)