Closed Bug 1525402 Opened 5 years ago Closed 5 years ago

Update Webrender to Rust 2018 Edition

Categories

(Core :: Graphics: WebRender, task, P3)

task

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox68 --- fixed

People

(Reporter: Gankra, Assigned: Gankra)

References

Details

Attachments

(6 files, 3 obsolete files)

It appears that Bug 1515512 means that we require 1.31 to build, which is the minimum version for Rust 2018.

Details on 2018: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html

High level: Just run rustfix --edition which will automatically fix all of our issues and upgrade us. Editions are internally compiled down to a common "primal rust" so upgrading webrender to 2018 has no impact on the rest of firefox or the dependency graph.

One nice advantage of the 2018 edition is the ability to use non-lexical lifetimes.

It looks like all of our compatibility issues are three things:

1:

use sibling_module::foo;

is now

use crate::sibling_module::foo;

2:

fn foo(UnusedArgument) { ... }

must be

fn foo(_: UnusedArgument) { ... }

3:

try is a keyword now, so try! should be changed to using ?

I am looking into this as a simple task to warm up back into the idea of working again.

Priority: -- → P3

Bug 1525402 - run cargo fix --edition on windows

Bug 1525402 - remove unnecessary externs

Bug 1525402 - manual fixup of image_loader

Bug 1525402 - manually fix uses for macos/unix fonts

Bug 1525402 - rerun cargo fix on windows

Attachment #9043733 - Attachment is obsolete: true
Keywords: checkin-needed

Failed to land:
Details: We're sorry, Autoland could not rebase your commits for you automatically. Please manually rebase your commits and try again. (255, 'applying /tmp/tmpYRsqGg\npatching file gfx/wr/wrench/src/rawtest.rs\nHunk #1 FAILED at 1\n1 out of 1 hunks FAILED -- saving rejects to file gfx/wr/wrench/src/rawtest.rs.rej\npatching file gfx/wr/webrender_api/src/lib.rs\nHunk #2 FAILED at 32\n1 out of 2 hunks FAILED -- saving rejects to file gfx/wr/webrender_api/src/lib.rs.rej\npatching file gfx/wr/webrender/src/tiling.rs\nHunk #1 FAILED at 4\n1 out of 1 hunks FAILED -- saving rejects to file gfx/wr/webrender/src/tiling.rs.rej\npatching file gfx/wr/webrender/src/renderer.rs\nHunk #1 succeeded at 45 with fuzz 1 (offset 12 lines).\npatching file gfx/wr/webrender/src/render_backend.rs\nHunk #2 succeeded at 59 with fuzz 2 (offset -1 lines).\npatching file gfx/wr/webrender/src/frame_builder.rs\nHunk #1 FAILED at 4\n1 out of 1 hunks FAILED -- saving rejects to file gfx/wr/webrender/src/frame_builder.rs.rej\npatching file gfx/wr/webrender/src/device/gl.rs\nHunk #1 succeeded at 9 with fuzz 1 (offset -2 lines).\npatching file gfx/wr/webrender/src/debug_render.rs\nHunk #1 FAILED at 3\n1 out of 1 hunks FAILED -- saving rejects to file gfx/wr/webrender/src/debug_render.rs.rej\npatching file gfx/wr/webrender/Cargo.toml\nHunk #2 FAILED at 29\n1 out of 3 hunks FAILED -- saving rejects to file gfx/wr/webrender/Cargo.toml.rej\npatching file gfx/wr/Cargo.lock\nHunk #1 succeeded at 1644 with fuzz 1 (offset 0 lines).\nabort: patch failed to apply', '')

Alexis, can you please take a look?

Flags: needinfo?(a.beingessner)
Keywords: checkin-needed

Bug 1525402 - properly move dependency logic to Cargo.toml

Bug 1525402 - run cargo fix --edition on windows

Bug 1525402 - run cargo fix on windows

Bug 1525402 - remove unnecessary extern crates

Bug 1525402 - manually fix imports for non-windows files

Flags: needinfo?(a.beingessner)
Assignee: nobody → a.beingessner
Type: enhancement → task

This version adds support for Rust 2018's new externs

Notably extern crate foo as bar is no longer supported
(must do it in Cargo.toml). Also stopped using euclid through webrender_api,
because it produces worse results in 2018.

cargo fix works by building under a specific config, so we can't hit both
sides of a mutually exclusive pair of cfgs, such as cfg(target_os) or
when cfg(feature) and cfg(not(feature)) both exist in the codebase.

Attachment #9048198 - Attachment is obsolete: true
Attachment #9047276 - Attachment is obsolete: true

NB: this requires https://github.com/eqrion/cbindgen/pull/332 to land, and for a new version of cbindgen to be published. I've locally verified that I can build firefox on macos with this, but can't do a try push to test out other targets until the publish is done. Also obviously can't land until cbindgen is 0.8.5 is released.

You can do a try push, just include the appropriate changes to these lines to pull a version with your PR applied.

0.1.21 mishandles cargo package renames, which are a required
feature for Rust 2018 support. The latest version fixes this.

last few tries have looked good (main concern being that we build and don't immediately crash): https://treeherder.mozilla.org/#/jobs?repo=try&revision=813d30d8103820c5a48cd9bb92dd112c3344a0ac

Will rebase once aosmond's P1 fix lands, and push then

Attachment #9062017 - Attachment description: Bug 1525402 - Bump cbindgen to 0.8.5. → Bug 1525402 - Bump cbindgen to 0.8.6.
Pushed by abeingessner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ddce4ed9bb05
Bump cbindgen to 0.8.6. r=kvark
https://hg.mozilla.org/integration/autoland/rev/0c2296965b7b
Bump cargo-vendor to 0.1.23. r=kats
https://hg.mozilla.org/integration/autoland/rev/8c7d885ae036
Migrate webrender externs to a Rust 2018 compatible form. r=kvark
https://hg.mozilla.org/integration/autoland/rev/16d8a19df813
Manual fixups for configs cargo fix missed. r=kvark
https://hg.mozilla.org/integration/autoland/rev/f072f15ba54e
Run `cargo fix --edition` on webrender on macos. r=kvark
https://hg.mozilla.org/integration/autoland/rev/2371d3a7ab2d
Mark all gfx/wr crates as Rust 2018. r=kvark
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: