Closed Bug 1982003 Opened 1 year ago Closed 1 year ago

Build failure on allocator-api2 crate with rust 1.89

Categories

(Core :: Graphics: WebRender, defect)

defect

Tracking

()

RESOLVED FIXED
144 Branch
Tracking Status
firefox-esr140 --- fixed
firefox143 --- fixed
firefox144 --- fixed

People

(Reporter: gaston, Assigned: glandium)

References

Details

Attachments

(6 external files, 2 obsolete files)

With rust 1.89, i'm hitting the same failure as in bug #1966563, but thunderbird 140.1.1 contains https://hg-edge.mozilla.org/mozilla-central/rev/9718326ac449 so i don't understand .. firefox esr 140.1.0 builds fine with rust 1.89

error: implicit autoref creates a reference to the dereference of a raw pointer                                                        
    --> /usr/obj/ports/thunderbird-140.1.1/thunderbird-140.1.1/third_party/rust/allocator-api2/src/stable/vec/mod.rs:1902:30
     |
1902 |         let count = unsafe { (*other).len() };
     |                              ^^-----^^^^^^^
     |                                |
     |                                this raw pointer has type `*const [T]`
     |
     = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements
note: autoref is being applied to this expression, resulting in: `&[T]`
    --> /usr/obj/ports/thunderbird-140.1.1/thunderbird-140.1.1/third_party/rust/allocator-api2/src/stable/vec/mod.rs:1902:30
     |
1902 |         let count = unsafe { (*other).len() };
     |                              ^^^^^^^^
note: method calls to `len` require a reference
    --> /usr/obj/ports/rust-1.89.0/rustc-1.89.0-src/library/core/src/slice/mod.rs:116:5
     = note: `#[deny(dangerous_implicit_autorefs)]` on by default
help: try using a raw pointer method instead; or if this reference is intentional, make it explicit
     |
1902 |         let count = unsafe { (&(*other)).len() };
     |                              ++        +

error: could not compile `allocator-api2` (lib) due to 1 previous error

Caused by:
  process didn't exit successfully: `CARGO=/usr/local/bin/cargo CARGO_CRATE_NAME=allocator_api2 CARGO_MANIFEST_DIR=/usr/obj/ports/thunderbird-140.1.1/thunderbird-140.1.1/third_party/rust/allocator-api2 CARGO_MANIFEST_PATH=/usr/obj/ports/thunderbird-140.1.1/thunderbird-140.1.1/third_party/rust/allocator-api2/Cargo.toml CARGO_PKG_AUTHORS='Zakarum <zaq.dev@icloud.com>' CARGO_PKG_DESCRIPTION='Mirror of Rust'\''s allocator API' CARGO_PKG_HOMEPAGE='https://github.com/zakarumych/allocator-api2' CARGO_PKG_LICENSE='MIT OR Apache-2.0' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=allocator-api2 CARGO_PKG_README=README.md CARGO_PKG_REPOSITORY='https://github.com/zakarumych/allocator-api2' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.2.999 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=2 CARGO_PKG_VERSION_PATCH=999 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH=/usr/obj/ports/thunderbird-140.1.1/build-amd64/release/deps /usr/local/bin/rustc --crate-name allocator_api2 --edition=2018 /usr/obj/ports/thunderbird-140.1.1/thunderbird-140.1.1/third_party/rust/allocator-api2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=137 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no --warn=unexpected_cfgs --check-cfg 'cfg(no_global_oom_handling)' -C debug-assertions=off --cfg 'feature="alloc"' --cfg 'feature="default"' --cfg 'feature="serde"' --cfg 'feature="std"' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("alloc", "default", "nightly", "serde", "std"))' -C metadata=e2958333c44b045c -C extra-filename=-aec6782937318449 --out-dir /usr/obj/ports/thunderbird-140.1.1/build-amd64/release/deps -C linker=/usr/obj/ports/thunderbird-140.1.1/thunderbird-140.1.1/build/cargo-linker -C strip=debuginfo -L dependency=/usr/obj/ports/thunderbird-140.1.1/build-amd64/release/deps --extern serde=/usr/obj/ports/thunderbird-140.1.1/build-amd64/release/deps/libserde-54c2f6bd939263d0.rmeta` (exit status: 1)
See Also: → 1966563

mike, since you fixed bug 1966563, any idea what could be different in the way thunderbird builds that crate ?

Flags: needinfo?(mh+mozilla)

comparing the build options used between esr 140.1 and thunderbird, firefox-esr uses:
-C opt-level=2
-C panic=abort
-C debuginfo=2
--cap-lints warn
-Cembed-bitcode=yes
-C codegen-units=1

thunderbird uses:

  • --diagnostic-width=137
  • -C debug-assertions=off
  • -C embed-bitcode=no

since i have no idea what those do.. when building firefox-esr, it seems the crate is built 3 times, and apparently not with the same options, eg once with -C linker-plugin-lto and once with -Cembed-bitcode=yes (and the third time without both those options)

ok seems i'll have to try --cap-lints warn according to semarie.. but it's apparently already in the flags:

/usr/obj/ports/thunderbird-140.1.1/build-amd64/config.status:    'MOZ_RUST_DEFAULT_FLAGS': ['-C', 'debuginfo=2', '--cap-lints', 'warn'],

but skipped/unused as i dont see them in the build logs.

adding #![warn(dangerous_implicit_autorefs)] at the top of third_party/rust/allocator-api2/src/stable/vec/mod.rs apparently allows the build with rust 1.89 to go further, and even complete. I hadnt realized that bug #1966563 had only touched lib.rs and not mod.rs.. so maybe a combination of different build flags for tb ?

i suppose comm-central and comm-beta are also broken with rust 1.89 ?

fwiw, here's the workaround i've used in OpenBSD's ports tree to unblock the rust 1.89 update.

https://github.com/openbsd/ports/commit/3ef8a2538893109bea8211ef13a870822264e096

taking any better suggestion from people fluent in rust build systems/options :)

Duplicate of this bug: 1982569

https://github.com/zakarumych/allocator-api2/pull/36 seems a much better fix, if the rust code behaves the same this way..

The same happens on Firefox with ac_add_options --enable-warnings-as-errors

I tried looking into this more, but still am not sure what's going on (I likely don't understand the build system well enough). The problem is definitely that --cap-lints warn isn't getting passed where it should, I just don't see why that's happening. I can see alllocator-api2 is successfully being built once with a warning (because it's being built with --cap-lints), then fails with an error when built again later in the build (because --cap-lints isn't passed). This is all happening in force-cargo-library-build in rust.mk, specifically while building gkrust, and still happens even if I add --cap-lints=warn to the cargo/rustc invocation there.

I don't think this should be solved by patching the vendored copy in m-c, since this presumably will be a problem every time there's a new lint error in any m-c vendored library. Cargo is supposed to be passing --cap-lints allow to dependencies anyway, and it doesn't seem sustainable to work around the fact it's not.

1.88.0 is not affected. The rustup override set 1.88.0 workaround fixes the build.

Duplicate of this bug: 1986634

(In reply to Yury Delendik (:yury) from comment #11)

1.88.0 is not affected. The rustup override set 1.88.0 workaround fixes the build.

Hi. Could you please let me know where to make this change? I'm new to building Thunderbird in order to contribute, and this bug is my first hurdle. Sorry if I should ask this elsewhere.

(In reply to Mark Daniel Osborne from comment #13)

(In reply to Yury Delendik (:yury) from comment #11)

1.88.0 is not affected. The rustup override set 1.88.0 workaround fixes the build.

Hi. Could you please let me know where to make this change? I'm new to building Thunderbird in order to contribute, and this bug is my first hurdle. Sorry if I should ask this elsewhere.

It is Rust installer functions:

$ cd work-directory/mozilla-unified
$ rustup install 1.88.0 # if not installed already
$ rustup override set 1.88.0

ideally, the code should build with the latest version of the compiler. pining to an older version is gross...

Some time between the fix for bug 1966563 and the release of rustc 1.89,
dangerous_implicit_autorefs was made deny-by-default, so allow(warnings)
doesn't make it allowed again.

Assignee: nobody → mh+mozilla
Status: NEW → ASSIGNED
Pushed by chorotan@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/07aad1c58121 https://hg.mozilla.org/integration/autoland/rev/f5f68cfdccc5 Revert "Bug 1982003 - Allow the specific problem that rustc 1.89 has with allocator-api2. r=emilio" for causing build bustages

Backed out for causing build bustage

Backout link

Push with failures

Failure log

It looks like a fix landed in https://github.com/zakarumych/allocator-api2/pull/42 today

Thanks a lot to Davi!

Flags: needinfo?(mh+mozilla)

The issue that made us fork the crate locally was actually fixed
upstream in 0.2.21.

Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 144 Branch

:mkmelin, should/can this be backported (or parts of it) to comm-140esr ?

Flags: needinfo?(mkmelin+mozilla)

IMHO, that would be good.

Flags: needinfo?(mkmelin+mozilla) → needinfo?(mh+mozilla)
Attachment #9511581 - Attachment is obsolete: true

firefox-beta Uplift Approval Request

  • User impact if declined: Downstream build failures with rustc 1.89
  • Code covered by automated testing: yes
  • Fix verified in Nightly: yes
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: N/A
  • Risk associated with taking this patch: low
  • Explanation of risk level: The changes to the crate that is being upgraded and fixed here are in largely in parts we haven't been using so wouldn't affect older versions of Firefox.
  • String changes made/needed: N/A
  • Is Android affected?: no
Attachment #9512769 - Flags: approval-mozilla-beta?

The issue that made us fork the crate locally was actually fixed
upstream in 0.2.21.

Original Revision: https://phabricator.services.mozilla.com/D264361

The issue that made us fork the crate locally was actually fixed
upstream in 0.2.21.

Original Revision: https://phabricator.services.mozilla.com/D264361

Attachment #9512770 - Flags: approval-mozilla-beta?

firefox-beta Uplift Approval Request

  • User impact if declined: Downstream build failures with rustc 1.89
  • Code covered by automated testing: yes
  • Fix verified in Nightly: yes
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: N/A
  • Risk associated with taking this patch: low
  • Explanation of risk level: The changes to the crate that is being upgraded and fixed here are in largely in parts we haven't been using so wouldn't affect older versions of Firefox.
  • String changes made/needed: N/A
  • Is Android affected?: no
Attachment #9512771 - Flags: approval-mozilla-beta?
Attachment #9512769 - Attachment is obsolete: true
Attachment #9512769 - Flags: approval-mozilla-beta?

The issue that made us fork the crate locally was actually fixed
upstream in 0.2.21.

Original Revision: https://phabricator.services.mozilla.com/D264361

Attachment #9512772 - Flags: approval-mozilla-esr140?

firefox-esr140 Uplift Approval Request

  • User impact if declined: Downstream build failures with rustc 1.89
  • Code covered by automated testing: yes
  • Fix verified in Nightly: yes
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: N/A
  • Risk associated with taking this patch: low
  • Explanation of risk level: The changes to the crate that is being upgraded and fixed here are in largely in parts we haven't been using so wouldn't affect older versions of Firefox.
  • String changes made/needed: N/A
  • Is Android affected?: no
Attachment #9512773 - Flags: approval-mozilla-esr140?

While this issue seems gone now, there seems to be others.

I usually have ac_add_options --enable-warnings-as-errors in my mozconfig (as CI has it anyway). That's still not compiling on Ubuntu 25.04 with rustc 1.89.

error: hiding a lifetime that's elided elsewhere is confusing
 0:34.73     --> /home/magnus/Code/tb/mozilla/xpcom/rust/nsstring/src/lib.rs:644:38
 0:34.73      |
 0:34.73 644  |               pub unsafe fn bulk_write(&mut self,
 0:34.74      |                                        ^^^^^^^^^ the lifetime is elided here
 0:34.74 ...


... and many others.

I would not advise to use --enable-warnings-as-errors if you're not using the same version of compilers are the one Mozilla's CI. You're hitting a completely different bug in a completely different crate.

Flags: needinfo?(mh+mozilla)
Attachment #9512771 - Flags: approval-mozilla-beta? → approval-mozilla-release?
Attachment #9512770 - Flags: approval-mozilla-beta? → approval-mozilla-release?

Filed bug 1988171 to track the remaining warnings.

Attachment #9512772 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
Attachment #9512773 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
Attachment #9512770 - Attachment description: Bug 1982003 - Upgrade allocator-api2 to 0.2.21. → Bug 1982003 - Upgrade allocator-api2 to 0.2.21. r=supply-chain-reviewers
Attachment #9512771 - Attachment description: Bug 1982003 - Apply allocator-api2 upstream fix to build with rust 1.89. → Bug 1982003 - Apply allocator-api2 upstream fix to build with rust 1.89. r=nika,supply-chain-reviewers
Attachment #9512770 - Flags: approval-mozilla-release? → approval-mozilla-release+
Attachment #9512771 - Flags: approval-mozilla-release? → approval-mozilla-release+
Component: Build Config → Graphics: WebRender
Product: Thunderbird → Core
Summary: Build failure on alllocator-api2 crate with rust 1.89 → Build failure on allocator-api2 crate with rust 1.89
QA Whiteboard: [qa-triage-done-c145/b144]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: