Compile Servo with the latest version of rust stable (#30831)

This completes the transition to compiling Servo with rust stable. Some
nightly-only features are still used when compiling the `script` and
`crown` crates, as well as for some style unit tests. These will likely
break with newer compiler versions, but `crown` can be disabled for them
conditionally. This is just the first step.

This has some caveats:

1. We need to disable setting up the special linker on Linux. The -Z
   option isn't supported with stable rust so using this is out --
   meanwhile we can't be sure that lld is installed on most systems.
2. `cargo fmt` still uses some unstable options, so we need to rely on
   the unstable toolchain just for running `fmt`. The idea is to fix this
   gradually.
This commit is contained in:
Martin Robinson 2023-12-06 18:36:07 +01:00 committed by GitHub
parent 9c443cf2c1
commit 7e82c5c957
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 76 additions and 78 deletions

View file

@ -524,12 +524,6 @@ class CommandBase(object):
if self.config["build"]["rustflags"]:
env['RUSTFLAGS'] += " " + self.config["build"]["rustflags"]
# Turn on rust's version of lld if we are on x86 Linux.
# TODO(mrobinson): Gradually turn this on for more platforms, when support stabilizes.
# See https://github.com/rust-lang/rust/issues/39915
if not self.cross_compile_target and effective_target == "x86_64-unknown-linux-gnu":
env['RUSTFLAGS'] += " " + servo.platform.get().linker_flag()
if not (self.config["build"]["ccache"] == ""):
env['CCACHE'] = self.config["build"]["ccache"]

View file

@ -66,9 +66,6 @@ class Base:
def library_path_variable_name(self):
raise NotImplementedError("Do not know how to set library path for platform.")
def linker_flag(self) -> str:
return ""
def executable_suffix(self) -> str:
return ""

View file

@ -150,17 +150,6 @@ class Linux(Base):
installed_something |= self._platform_bootstrap_gstreamer(force)
return installed_something
def linker_flag(self) -> str:
# the rust-lld binary downloaded by rustup
# doesn't respect NIX_LDFLAGS and also needs
# other patches to work correctly. Use system
# version of lld for now. See
# https://github.com/NixOS/nixpkgs/issues/220717
if self.distro.lower() == 'nixos':
return '-C link-arg=-fuse-ld=lld'
else:
return '-Zgcc-ld=lld'
def install_non_gstreamer_dependencies(self, force: bool) -> bool:
install = False
pkgs = []

View file

@ -292,7 +292,10 @@ class MachCommands(CommandBase):
else:
manifest_dirty = wpt.manifestupdate.update(check_clean=True)
tidy_failed = tidy.scan(not all_files, not no_progress, stylo=stylo, no_wpt=no_wpt)
rustfmt_failed = call(["cargo", "fmt", "--", "--check"])
call(["rustup", "install", "nightly-2023-03-18"])
call(["rustup", "component", "add", "rustfmt", "--toolchain", "nightly-2023-03-18"])
rustfmt_failed = call(["cargo", "+nightly-2023-03-18", "fmt", "--", "--check"])
if rustfmt_failed:
print("Run `./mach fmt` to fix the formatting")
@ -396,7 +399,10 @@ class MachCommands(CommandBase):
result = format_toml_files_with_taplo(check_only=False)
if result != 0:
return result
return call(["cargo", "fmt"])
call(["rustup", "install", "nightly-2023-03-18"])
call(["rustup", "component", "add", "rustfmt", "--toolchain", "nightly-2023-03-18"])
return call(["cargo", "+nightly-2023-03-18", "fmt"])
@Command('update-wpt',
description='Update the web platform tests',