Build failure on allocator-api2 crate with rust 1.89
Categories
(Core :: Graphics: WebRender, defect)
Tracking
()
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)
| Reporter | ||
Comment 1•1 year ago
|
||
mike, since you fixed bug 1966563, any idea what could be different in the way thunderbird builds that crate ?
| Reporter | ||
Comment 2•1 year ago
|
||
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)
| Reporter | ||
Comment 3•1 year ago
|
||
the upstream code is still the same at https://github.com/zakarumych/allocator-api2/blob/main/src/vec/mod.rs#L1983
| Reporter | ||
Comment 4•1 year ago
•
|
||
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.
| Reporter | ||
Comment 5•1 year ago
|
||
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 ?
| Reporter | ||
Comment 6•1 year ago
|
||
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 :)
| Reporter | ||
Comment 8•1 year ago
|
||
https://github.com/zakarumych/allocator-api2/pull/36 seems a much better fix, if the rust code behaves the same this way..
Comment 9•1 year ago
|
||
The same happens on Firefox with ac_add_options --enable-warnings-as-errors
Comment 10•1 year ago
|
||
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.
Comment 11•1 year ago
|
||
1.88.0 is not affected. The rustup override set 1.88.0 workaround fixes the build.
Comment 13•1 year ago
|
||
(In reply to Yury Delendik (:yury) from comment #11)
1.88.0 is not affected. The
rustup override set 1.88.0workaround 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.
Comment 14•1 year ago
|
||
(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.0workaround 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
| Reporter | ||
Comment 15•1 year ago
|
||
ideally, the code should build with the latest version of the compiler. pining to an older version is gross...
| Assignee | ||
Comment 16•1 year ago
|
||
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.
Updated•1 year ago
|
Updated•1 year ago
|
Comment 17•1 year ago
|
||
Comment 18•1 year ago
|
||
Comment 19•1 year ago
|
||
Comment 20•1 year ago
|
||
It looks like a fix landed in https://github.com/zakarumych/allocator-api2/pull/42 today
Comment 21•1 year ago
|
||
Thanks a lot to Davi!
| Assignee | ||
Updated•1 year ago
|
| Assignee | ||
Comment 22•1 year ago
|
||
The issue that made us fork the crate locally was actually fixed
upstream in 0.2.21.
| Assignee | ||
Comment 23•1 year ago
|
||
Comment 24•1 year ago
|
||
Comment 25•1 year ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/02a8576f01ea
https://hg.mozilla.org/mozilla-central/rev/33e63df4612d
| Reporter | ||
Comment 26•1 year ago
|
||
:mkmelin, should/can this be backported (or parts of it) to comm-140esr ?
Comment 27•1 year ago
|
||
IMHO, that would be good.
Updated•1 year ago
|
Comment 28•1 year ago
|
||
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
| Assignee | ||
Comment 29•1 year ago
|
||
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
| Assignee | ||
Comment 30•1 year ago
|
||
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
Updated•1 year ago
|
Comment 31•1 year ago
|
||
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
| Assignee | ||
Comment 32•1 year ago
|
||
Original Revision: https://phabricator.services.mozilla.com/D264362
Updated•1 year ago
|
| Assignee | ||
Comment 33•1 year ago
|
||
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
Updated•1 year ago
|
Comment 34•1 year ago
|
||
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
| Assignee | ||
Comment 35•1 year ago
|
||
Original Revision: https://phabricator.services.mozilla.com/D264362
Comment 36•1 year ago
|
||
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.
| Assignee | ||
Comment 37•1 year ago
|
||
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.
Updated•1 year ago
|
Updated•1 year ago
|
Comment 38•1 year ago
|
||
Filed bug 1988171 to track the remaining warnings.
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Comment 39•1 year ago
|
||
| uplift | ||
Comment 40•1 year ago
|
||
| uplift | ||
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Description
•