Skip to content

Commit ab599ae

Browse files
committed
servo: Merge #18325 - Switch back to pinning Rust by Nightly date instead of commit hash… (from servo:rustup-toolchain); r=nox
… this time using a `rust-toolchain` file compatible with rustup: https://github.com/rust-lang-nursery/rustup.rs/#the-toolchain-file And upgrade to rustc 1.21.0-nightly (c11f689d2 2017-08-29) ---- Now if both `system-rust` and `system-cargo` are set to `true` in `.servobuild`’s `[tools]` section, and the corresponding `rustc` and `cargo` binaries are in fact rustup’s wrappers, then rustup will use the correct version based on `rust-toolchain`. CC servo/servo#11361 Unlike servo/servo#17927, this does not make mach use rustup directly. That should wait until rust-lang/rustup#1099 is fixed. Source-Repo: https://github.com/servo/servo Source-Revision: c4800a6c83e6fdabaf7c4eff70a24487d16f18ff UltraBlame original commit: 5df6f8fe6c50631fe00f47b69d16b8d555d90503
1 parent 64da378 commit ab599ae

File tree

7 files changed

+78
-86
lines changed

7 files changed

+78
-86
lines changed

servo/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Servo's build system automatically downloads a Rust compiler to build itself.
124124
This is normally a specific revision of Rust upstream, but sometimes has a
125125
backported patch or two.
126126
If you'd like to know which nightly build of Rust we use, see
127-
[`rust-commit-hash`](https://github.com/servo/servo/blob/master/rust-commit-hash).
127+
[`rust-toolchain`](https://github.com/servo/servo/blob/master/rust-toolchain).
128128

129129
## Building
130130

servo/appveyor.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ branches:
3636
- master
3737

3838
cache:
39-
- .servo -> rust-commit-hash
40-
- .cargo -> rust-commit-hash
39+
- .servo -> rust-toolchain
40+
- .cargo -> rust-toolchain
4141
- .ccache
4242

4343
# Uncomment these lines to expose RDP access information to the build machine in the build log.

servo/python/servo/bootstrap_commands.py

+36-38
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,10 @@ def bootstrap(self, force=False):
6868
help='Use stable rustc version')
6969
def bootstrap_rustc(self, force=False, target=[], stable=False):
7070
self.set_use_stable_rust(stable)
71-
version = self.rust_version()
72-
rust_path = self.rust_path()
73-
rust_dir = path.join(self.context.sharedir, "rust", rust_path)
74-
install_dir = path.join(self.context.sharedir, "rust", version)
75-
if not self.config["build"]["llvm-assertions"]:
76-
if not self.use_stable_rust():
77-
install_dir += "-alt"
71+
rust_dir = path.join(self.context.sharedir, "rust", self.rust_path())
72+
install_dir = path.join(self.context.sharedir, "rust", self.rust_install_dir())
73+
version = self.rust_stable_version() if stable else "nightly"
74+
static_s3 = "https://static-rust-lang-org.s3.amazonaws.com/dist"
7875

7976
if not force and path.exists(path.join(rust_dir, "rustc", "bin", "rustc" + BIN_SUFFIX)):
8077
print("Rust compiler already downloaded.", end=" ")
@@ -90,16 +87,23 @@ def bootstrap_rustc(self, force=False, target=[], stable=False):
9087

9188

9289
if stable:
93-
tarball = "rustc-%s-%s.tar.gz" % (version, host_triple())
94-
rustc_url = "https://static-rust-lang-org.s3.amazonaws.com/dist/" + tarball
90+
base_url = static_s3
9591
else:
96-
tarball = "%s/rustc-nightly-%s.tar.gz" % (version, host_triple())
92+
import toml
93+
import re
94+
channel = "%s/%s/channel-rust-nightly.toml" % (static_s3, self.rust_nightly_date())
95+
version_string = toml.load(urllib2.urlopen(channel))["pkg"]["rustc"]["version"]
96+
short_commit = re.search("\(([0-9a-f]+) ", version_string).group(1)
97+
commit_api = "https://api.github.com/repos/rust-lang/rust/commits/" + short_commit
98+
nightly_commit_hash = json.load(urllib2.urlopen(commit_api))["sha"]
99+
97100
base_url = "https://s3.amazonaws.com/rust-lang-ci/rustc-builds"
98101
if not self.config["build"]["llvm-assertions"]:
99102
base_url += "-alt"
100-
rustc_url = base_url + "/" + tarball
101-
tgz_file = rust_dir + '-rustc.tar.gz'
103+
base_url += "/" + nightly_commit_hash
102104

105+
rustc_url = base_url + "/rustc-%s-%s.tar.gz" % (version, host_triple())
106+
tgz_file = rust_dir + '-rustc.tar.gz'
103107
download_file("Rust compiler", rustc_url, tgz_file)
104108

105109
print("Extracting Rust compiler...")
@@ -111,10 +115,8 @@ def bootstrap_rustc(self, force=False, target=[], stable=False):
111115

112116

113117

114-
nightly_suffix = "" if stable else "-nightly"
115-
stable_version = "-{}".format(version) if stable else ""
116118
lib_dir = path.join(install_dir,
117-
"rustc{}{}-{}".format(nightly_suffix, stable_version, host_triple()),
119+
"rustc-%s-%s" % (version, host_triple()),
118120
"rustc", "lib", "rustlib")
119121

120122

@@ -130,26 +132,25 @@ def bootstrap_rustc(self, force=False, target=[], stable=False):
130132
print("Use |bootstrap-rust --force| to download again.")
131133
continue
132134

135+
tarball = "rust-std-%s-%s.tar.gz" % (version, target_triple)
136+
tgz_file = path.join(install_dir, tarball)
133137
if self.use_stable_rust():
134-
std_url = ("https://static-rust-lang-org.s3.amazonaws.com/dist/rust-std-%s-%s.tar.gz"
135-
% (version, target_triple))
136-
tgz_file = install_dir + ('rust-std-%s-%s.tar.gz' % (version, target_triple))
138+
std_url = static_s3 + "/" + tarball
137139
else:
138-
std_url = ("https://s3.amazonaws.com/rust-lang-ci/rustc-builds/%s/rust-std-nightly-%s.tar.gz"
139-
% (version, target_triple))
140-
tgz_file = install_dir + ('rust-std-nightly-%s.tar.gz' % target_triple)
140+
std_url = static_s3 + "/" + self.rust_nightly_date() + "/" + tarball
141141

142142
download_file("Host rust library for target %s" % target_triple, std_url, tgz_file)
143143
print("Extracting Rust stdlib for target %s..." % target_triple)
144144
extract(tgz_file, install_dir)
145145
shutil.copytree(path.join(install_dir,
146-
"rust-std%s%s-%s" % (nightly_suffix, stable_version, target_triple),
147-
"rust-std-%s" % target_triple, "lib", "rustlib", target_triple),
146+
"rust-std-%s-%s" % (version, target_triple),
147+
"rust-std-%s" % target_triple,
148+
"lib", "rustlib", target_triple),
148149
path.join(install_dir,
149-
"rustc%s%s-%s" % (nightly_suffix, stable_version, host_triple()),
150-
"rustc", "lib", "rustlib", target_triple))
151-
shutil.rmtree(path.join(install_dir,
152-
"rust-std%s%s-%s" % (nightly_suffix, stable_version, target_triple)))
150+
"rustc-%s-%s" % (version, host_triple()),
151+
"rustc",
152+
"lib", "rustlib", target_triple))
153+
shutil.rmtree(path.join(install_dir, "rust-std-%s-%s" % (version, target_triple)))
153154

154155
print("Rust {} libs ready.".format(target_triple))
155156

@@ -171,8 +172,8 @@ def bootstrap_rustc_docs(self, force=False):
171172
if path.isdir(docs_dir):
172173
shutil.rmtree(docs_dir)
173174
docs_name = self.rust_path().replace("rustc-", "rust-docs-")
174-
docs_url = ("https://static-rust-lang-org.s3.amazonaws.com/dist/rust-docs-nightly-%s.tar.gz"
175-
% host_triple())
175+
docs_url = ("https://static-rust-lang-org.s3.amazonaws.com/dist/%s/rust-docs-nightly-%s.tar.gz"
176+
% (self.rust_nightly_date(), host_triple()))
176177
tgz_file = path.join(rust_root, 'doc.tar.gz')
177178

178179
download_file("Rust docs", docs_url, tgz_file)
@@ -195,8 +196,7 @@ def bootstrap_rustc_docs(self, force=False):
195196
action='store_true',
196197
help='Force download even if cargo already exists')
197198
def bootstrap_cargo(self, force=False):
198-
cargo_dir = path.join(self.context.sharedir, "cargo",
199-
self.cargo_build_id())
199+
cargo_dir = path.join(self.context.sharedir, "cargo", self.rust_nightly_date())
200200
if not force and path.exists(path.join(cargo_dir, "cargo", "bin", "cargo" + BIN_SUFFIX)):
201201
print("Cargo already downloaded.", end=" ")
202202
print("Use |bootstrap-cargo --force| to download again.")
@@ -207,8 +207,8 @@ def bootstrap_cargo(self, force=False):
207207
os.makedirs(cargo_dir)
208208

209209
tgz_file = "cargo-nightly-%s.tar.gz" % host_triple()
210-
nightly_url = "https://s3.amazonaws.com/rust-lang-ci/rustc-builds/%s/%s" % \
211-
(self.cargo_build_id()[len("rust-"):], tgz_file)
210+
nightly_url = "https://static-rust-lang-org.s3.amazonaws.com/dist/%s/%s" % \
211+
(self.rust_nightly_date(), tgz_file)
212212

213213
download_file("Cargo nightly", nightly_url, tgz_file)
214214

@@ -291,10 +291,8 @@ def bootstrap_pub_suffix(self, force=False):
291291
default='1',
292292
help='Keep up to this many most recent nightlies')
293293
def clean_nightlies(self, force=False, keep=None):
294-
self.set_use_stable_rust(False)
295-
rust_current_nightly = self.rust_version()
296-
self.set_use_stable_rust(True)
297-
rust_current_stable = self.rust_version()
294+
rust_current_nightly = self.rust_nightly_date()
295+
rust_current_stable = self.rust_stable_version()
298296
print("Current Rust nightly version: {}".format(rust_current_nightly))
299297
print("Current Rust stable version: {}".format(rust_current_stable))
300298
to_keep = set()
@@ -303,7 +301,7 @@ def clean_nightlies(self, force=False, keep=None):
303301
to_keep.add(rust_current_nightly)
304302
to_keep.add(rust_current_stable)
305303
else:
306-
for version_file in ['rust-commit-hash', 'rust-stable-version']:
304+
for version_file in ['rust-toolchain', 'rust-stable-version']:
307305
cmd = subprocess.Popen(
308306
['git', 'log', '--oneline', '--no-color', '-n', keep, '--patch', version_file],
309307
stdout=subprocess.PIPE,

servo/python/servo/command_base.py

+32-22
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,13 @@ def resolverelative(category, key):
285285
self.set_use_stable_rust(False)
286286

287287
_use_stable_rust = False
288-
_rust_version = None
289-
_rust_version_is_stable = False
290-
_cargo_build_id = None
288+
_rust_stable_version = None
289+
_rust_nightly_date = None
291290

292291
def set_cargo_root(self):
293292
if not self.config["tools"]["system-cargo"]:
294293
self.config["tools"]["cargo-root"] = path.join(
295-
self.context.sharedir, "cargo", self.cargo_build_id())
294+
self.context.sharedir, "cargo", self.rust_nightly_date())
296295

297296
def set_use_stable_rust(self, use_stable_rust=True):
298297
self._use_stable_rust = use_stable_rust
@@ -308,28 +307,39 @@ def set_use_stable_rust(self, use_stable_rust=True):
308307
def use_stable_rust(self):
309308
return self._use_stable_rust
310309

310+
def rust_install_dir(self):
311+
if self._use_stable_rust:
312+
return self.rust_stable_version()
313+
elif not self.config["build"]["llvm-assertions"]:
314+
return self.rust_nightly_date() + "-alt"
315+
else:
316+
return self.rust_nightly_date()
317+
311318
def rust_path(self):
312-
version = self.rust_version()
313319
if self._use_stable_rust:
314-
return os.path.join(version, "rustc-%s-%s" % (version, host_triple()))
315-
if not self.config["build"]["llvm-assertions"]:
316-
version += "-alt"
317-
return os.path.join(version, "rustc-nightly-%s" % (host_triple()))
318-
319-
def rust_version(self):
320-
if self._rust_version is None or self._use_stable_rust != self._rust_version_is_stable:
321-
filename = path.join(self.context.topdir,
322-
"rust-stable-version" if self._use_stable_rust else "rust-commit-hash")
320+
version = self.rust_stable_version()
321+
else:
322+
version = "nightly"
323+
324+
subdir = "rustc-%s-%s" % (version, host_triple())
325+
return os.path.join(self.rust_install_dir(), subdir)
326+
327+
def rust_stable_version(self):
328+
if self._rust_stable_version is None:
329+
filename = path.join("rust-stable-version")
323330
with open(filename) as f:
324-
self._rust_version = f.read().strip()
325-
return self._rust_version
331+
self._rust_stable_version = f.read().strip()
332+
return self._rust_stable_version
326333

327-
def cargo_build_id(self):
328-
if self._cargo_build_id is None:
329-
filename = path.join(self.context.topdir, "rust-commit-hash")
334+
def rust_nightly_date(self):
335+
if self._rust_nightly_date is None:
336+
filename = path.join(self.context.topdir, "rust-toolchain")
330337
with open(filename) as f:
331-
self._cargo_build_id = "rust-" + f.read().strip()
332-
return self._cargo_build_id
338+
toolchain = f.read().strip()
339+
prefix = "nightly-"
340+
assert toolchain.startswith(prefix)
341+
self._rust_nightly_date = toolchain[len(prefix):]
342+
return self._rust_nightly_date
333343

334344
def get_top_dir(self):
335345
return self.context.topdir
@@ -587,7 +597,7 @@ def ensure_bootstrapped(self, target=None):
587597
Registrar.dispatch("bootstrap", context=self.context)
588598

589599
if not (self.config['tools']['system-rust'] or (rustc_binary_exists and target_exists)):
590-
print("looking for rustc at %s" % (rustc_path))
600+
print("Looking for rustc at %s" % (rustc_path))
591601
Registrar.dispatch("bootstrap-rust", context=self.context, target=filter(None, [target]),
592602
stable=self._use_stable_rust)
593603

servo/python/servo/devenv_commands.py

+6-22
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ def update_cargo(self, params=None, package=None, all_packages=None, dry_run=Non
136136

137137
if dry_run:
138138
import toml
139-
import json
140139
import httplib
141140
import colorama
142141

@@ -262,31 +261,16 @@ def grep(self, params):
262261
@Command('rustup',
263262
description='Update the Rust version to latest Nightly',
264263
category='devenv')
265-
@CommandArgument('--master',
266-
action='store_true',
267-
help='Use the latest commit of the "master" branch')
268-
def rustup(self, master=False):
269-
if master:
270-
url = "https://api.github.com/repos/rust-lang/rust/git/refs/heads/master"
271-
commit = json.load(urllib2.urlopen(url))["object"]["sha"]
272-
else:
273-
import toml
274-
import re
275-
url = "https://static.rust-lang.org/dist/channel-rust-nightly.toml"
276-
version = toml.load(urllib2.urlopen(url))["pkg"]["rustc"]["version"]
277-
short_commit = re.search("\(([0-9a-f]+) ", version).group(1)
278-
url = "https://api.github.com/repos/rust-lang/rust/commits/" + short_commit
279-
commit = json.load(urllib2.urlopen(url))["sha"]
280-
filename = path.join(self.context.topdir, "rust-commit-hash")
264+
def rustup(self):
265+
url = "https://static.rust-lang.org/dist/channel-rust-nightly-date.txt"
266+
nightly_date = urllib2.urlopen(url).read()
267+
filename = path.join(self.context.topdir, "rust-toolchain")
281268
with open(filename, "w") as f:
282-
f.write(commit + "\n")
269+
f.write("nightly-%s\n" % nightly_date)
283270

284271

285-
self._rust_version = None
272+
self._rust_nightly_date = None
286273
self.set_use_stable_rust(False)
287-
288-
289-
self._cargo_build_id = None
290274
self.set_cargo_root()
291275

292276
self.fetch()

servo/rust-commit-hash

-1
This file was deleted.

servo/rust-toolchain

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nightly-2017-08-30

0 commit comments

Comments
 (0)