Firefox fails to build with rust rustc 1.58.1 (Fedora 36) error[E0740]: unions may not contain fields that need dropping
Categories
(Firefox Build System :: General, defect)
Tracking
(firefox97 fixed, firefox98 fixed)
People
(Reporter: stransky, Assigned: emilio)
Details
Attachments
(3 files)
|
629.79 KB,
application/pdf
|
Details | |
|
173.33 KB,
text/plain
|
Details | |
|
48 bytes,
text/x-phabricator-request
|
RyanVM
:
approval-mozilla-release+
|
Details | Review |
Firefox 96.0.3 fails to build on Fedora 36 (rust 1.58.1) with
5:34.41 error[E0740]: unions may not contain fields that need dropping
5:34.41 Running CARGO=/usr/bin/cargo CARGO_CRATE_NAME=viaduct CARGO_MANIFEST_DIR=/home/komat/rpmbuild/BUILD/firefox-96.0.3/third_party/rust/viaduct CARGO_PKG_AUTHORS='Thom Chiovoloni <tchiovoloni@mozilla.com>' CARGO_PKG_DESCRIPTION='' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE=MPL-2.0 CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=viaduct CARGO_PKG_REPOSITORY='' CARGO_PKG_VERSION=0.1.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/home/komat/rpmbuild/BUILD/firefox-96.0.3/objdir/release/deps:/usr/lib' /usr/bin/rustc --crate-name viaduct --edition=2018 /home/komat/rpmbuild/BUILD/firefox-96.0.3/third_party/rust/viaduct/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=2 -C panic=abort -C embed-bitcode=no --cfg 'feature="default"' -C metadata=739bfa36e003c8db -C extra-filename=-739bfa36e003c8db --out-dir /home/komat/rpmbuild/BUILD/firefox-96.0.3/objdir/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -C linker=/home/komat/rpmbuild/BUILD/firefox-96.0.3/build/cargo-linker -L dependency=/home/komat/rpmbuild/BUILD/firefox-96.0.3/objdir/x86_64-unknown-linux-gnu/release/deps -L dependency=/home/komat/rpmbuild/BUILD/firefox-96.0.3/objdir/release/deps --extern ffi_support=/home/komat/rpmbuild/BUILD/firefox-96.0.3/objdir/x86_64-unknown-linux-gnu/release/deps/libffi_support-380d86c20e4a9997.rmeta --extern log=/home/komat/rpmbuild/BUILD/firefox-96.0.3/objdir/x86_64-unknown-linux-gnu/release/deps/liblog-6582ada378cf50c4.rmeta --extern once_cell=/home/komat/rpmbuild/BUILD/firefox-96.0.3/objdir/x86_64-unknown-linux-gnu/release/deps/libonce_cell-2f7119dcc8f78c60.rmeta --extern prost=/home/komat/rpmbuild/BUILD/firefox-96.0.3/objdir/x86_64-unknown-linux-gnu/release/deps/libprost-d624e9d5f8584670.rmeta --extern prost_derive=/home/komat/rpmbuild/BUILD/firefox-96.0.3/objdir/release/deps/libprost_derive-e7e354ecd2c2ccf6.so --extern serde=/home/komat/rpmbuild/BUILD/firefox-96.0.3/objdir/x86_64-unknown-linux-gnu/release/deps/libserde-c79671ed8ebc0be5.rmeta --extern serde_json=/home/komat/rpmbuild/BUILD/firefox-96.0.3/objdir/x86_64-unknown-linux-gnu/release/deps/libserde_json-7cc1275ecaf8c471.rmeta --extern thiserror=/home/komat/rpmbuild/BUILD/firefox-96.0.3/objdir/x86_64-unknown-linux-gnu/release/deps/libthiserror-6463aac5a9cb8499.rmeta --extern url=/home/komat/rpmbuild/BUILD/firefox-96.0.3/objdir/x86_64-unknown-linux-gnu/release/deps/liburl-480aee27e43f6f85.rmeta --cap-lints warn -C debuginfo=2 --cap-lints warn -Cembed-bitcode=yes -C codegen-units=1
Comment 1•4 years ago
|
||
Thanks for the report!
I've got a couple questions:
- How does your
mozconfiglook? If you build 96.0.3 without a mozconfig, does it work? - If you run the provided
rustccommand as shown in the error message as a standalone command, does it still fail?
Comment 2•4 years ago
|
||
There is no union in viaduct. I don't think the command in comment 0 is the one that failed. Can you paste more context around the error?
Comment 3•4 years ago
|
||
Can't reproduce, even with --enable-warnings-as-errors.
Comment 4•4 years ago
|
||
i have this too with gcc 9
Comment 5•4 years ago
|
||
my ugly script:
set -e
cat > unstable.chroot/root/run.sh <<GLOBALEOF
set -e
set -v
echo "deb http://deb.debian.org/debian experimental main">/etc/apt/sources.list.d/exp.list
apt-get update
apt-get install -y gcc-9 g++-9 mercurial -t experimental
if test ! -d /root/firefox-gcc-last; then
hg clone https://hg.mozilla.org/mozilla-central/ /root/firefox-gcc-last
fi
cd /root/firefox-gcc-last
cat .mozconfig
cat > .mozconfig << EOF
ac_add_options --enable-debug
ac_add_options --enable-optimize=-O2
ac_add_options --enable-warnings-as-errors
mk_add_options AUTOCLOBBER=1
ac_add_options --enable-bootstrap
ac_add_options --without-sysroot
ac_add_options --without-wasm-sandboxed-libraries
CC=gcc-9
CXX=g++-9
export CXXFLAGS="-O2 -DGLIB_DISABLE_DEPRECATION_WARNINGS"
export CFLAGS="-O2 -DGLIB_DISABLE_DEPRECATION_WARNINGS"
export CXXFLAGS="-O2 -Wno-error=class-memaccess -Wno-error=format-overflow -Wno-error=stringop-truncation -Wno-stringop-overflow -Wno-error=attributes -Wno-error=deprecated-copy -Wno-error=pessimizing-move -Wno-error=type-limits"
export CFLAGS="-O2 -Wno-error=class-memaccess -Wno-error=format-overflow -Wno-error=stringop-truncation -Wno-stringop-overflow -Wno-error=type-limits"
EOF
./mach clobber||true
hg pull -u
hg revert .
hg update -r default
export PATH=/root/.cargo/bin/:$PATH
hg revert .
rustup update
cargo install cbindgen --force
sed -i -e "s|-Wno-unreachable-code-return||g" security/sandbox/linux/moz.build
cat security/sandbox/linux/moz.build
./mach --log-no-times build #-v
rm -rf obj-x86_64-pc-linux-gnu/
hg revert security/sandbox/linux/moz.build
GLOBALEOF
PATH_CHROOT=/var/lib/jenkins/workspace/firefox-gcc-9-last/unstable.chroot
sudo chroot $PATH_CHROOT/ ./root/run.sh
exit 0
Comment 6•4 years ago
|
||
Relevant part of the log:
error[E0740]: unions may not contain fields that need dropping
--> /root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/x86_64-unknown-linux-gnu/debug/build/gecko-profiler-1d5db7af5b183b3f/out/gecko/bindings.rs:5:72010
So this comes from code generated by cbindgen. What version are you using?
Comment 7•4 years ago
|
||
Actually, it comes from rust-bindgen, which is in-tree...
| Reporter | ||
Comment 9•4 years ago
|
||
Yes, the command from 0 doesn't look relevant, sorry for the confusion.
| Reporter | ||
Comment 10•4 years ago
|
||
There's a build log from repeated run....hope it helps.
Comment 11•4 years ago
|
||
Seems to be something in a system libstdc++ header that rust-bindgen doesn't handle properly... the version we're using was released more than 1 year ago. Emilio, do you know if this might have been fixed in a newer version?
| Reporter | ||
Comment 12•4 years ago
•
|
||
This is Fedora 36 system (not released yet) and the build error happened after recent update (unfortunately I can't say which package). Also this is a distro build with system libraries, not with bootstrapped ones.
| Assignee | ||
Comment 13•4 years ago
|
||
Martin, I'm on a Fedora Rawhide machine, I tried to repro with ac_add_options --disable-bootstrap, but couldn't. Do you have a way for me to potentially reproduce?
If not, could you attach the contents of this file? /root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/x86_64-unknown-linux-gnu/debug/build/gecko-profiler-1d5db7af5b183b3f/out/gecko/bindings.rs
| Assignee | ||
Comment 14•4 years ago
|
||
I found the relevant STL code and can reproduce a similar failure with:
template <typename _Tp, typename _Alloc>
struct _Vector_base {
union _Storage {
constexpr _Storage() : _M_byte() {}
~_Storage() {}
_Storage& operator=(const _Storage&) = delete;
unsigned char _M_byte;
_Tp _M_val;
};
};
Which generates some rust code like:
/* automatically generated by rust-bindgen 0.59.2 */
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _Vector_base {
pub _address: u8,
}
#[repr(C)]
pub union _Vector_base__Storage<_Tp> {
pub _M_byte: ::std::os::raw::c_uchar,
pub _M_val: _Tp,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<_Tp>>,
}
| Assignee | ||
Updated•4 years ago
|
| Assignee | ||
Comment 15•4 years ago
|
||
We don't use unions in the bindings, and rust is very picky with what
you can put on untagged unions, so disable them for now.
Updated•4 years ago
|
| Assignee | ||
Comment 16•4 years ago
|
||
Martin, can you confirm the patch above fixes the build for you?
| Assignee | ||
Comment 17•4 years ago
|
||
I filed https://github.com/rust-lang/rust-bindgen/issues/2157 to track this bindgen issue.
Comment 18•4 years ago
|
||
(In reply to Emilio Cobos Álvarez (:emilio) from comment #15)
Created attachment 9262299 [details]
Bug 1753402 - Disable untagged union in Gecko profiler bindings. r=canaltinova,geraldWe don't use unions in the bindings, and rust is very picky with what
you can put on untagged unions, so disable them for now.
Another thing that might be a bindgen bug to file is why are these stl type bindings generated, when what's requested is opaque types for std::string and std::vector?
| Assignee | ||
Comment 19•4 years ago
|
||
Yeah, but the underlying type name here is probably different. Hard to say without being able to reproduce.
Comment 20•4 years ago
|
||
| bugherder | ||
| Reporter | ||
Comment 21•4 years ago
|
||
Thanks, I'll check that with Firefox 97 builds there.
Comment 22•4 years ago
|
||
| Assignee | ||
Comment 23•4 years ago
|
||
Comment on attachment 9262299 [details]
Bug 1753402 - Disable untagged union in Gecko profiler bindings. r=canaltinova,gerald
ESR Uplift Approval Request
- If this is not a sec:{high,crit} bug, please state case for ESR consideration: One-liner build fix
- User impact if declined: none
- Fix Landed on Version:
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): Build-only
Beta/Release Uplift Approval Request
- User impact if declined: One-liner build fix.
- Is this code covered by automated tests?: Yes
- Has the fix been verified in Nightly?: Yes
- Needs manual test from QE?: No
- If yes, steps to reproduce:
- List of other uplifts needed: none
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): Build-only
- String changes made/needed: none
Comment 25•4 years ago
|
||
Comment on attachment 9262299 [details]
Bug 1753402 - Disable untagged union in Gecko profiler bindings. r=canaltinova,gerald
Approved for 97.0.1 and 91.7esr.
Comment 26•4 years ago
|
||
Comment on attachment 9262299 [details]
Bug 1753402 - Disable untagged union in Gecko profiler bindings. r=canaltinova,gerald
Actually, this file doesn't exist on ESR91. Looks like it landed during the Fx92 development cycle. Feel free to attach a branch-specific patch and request approval on it if there's a different spot that needs fixing there.
Comment 27•4 years ago
|
||
| bugherder uplift | ||
Comment 28•4 years ago
|
||
(In reply to Ryan VanderMeulen [:RyanVM] from comment #26)
Comment on attachment 9262299 [details]
Bug 1753402 - Disable untagged union in Gecko profiler bindings. r=canaltinova,geraldActually, this file doesn't exist on ESR91. Looks like it landed during the Fx92 development cycle. Feel free to attach a branch-specific patch and request approval on it if there's a different spot that needs fixing there.
Please, we need support for ESR91 too; Firefox 91ESR and all derived cannot be built against Rust-1.58.1 currently
| Assignee | ||
Comment 29•4 years ago
|
||
(In reply to Antonio T. from comment #28)
(In reply to Ryan VanderMeulen [:RyanVM] from comment #26)
Please, we need support for ESR91 too; Firefox 91ESR and all derived cannot be built against Rust-1.58.1 currently
What is the build failure? It can't be the same bug, please file a separate bug and cc / ni? me please?
Comment 30•4 years ago
|
||
(In reply to Emilio Cobos Álvarez (:emilio) from comment #29)
(In reply to Antonio T. from comment #28)
(In reply to Ryan VanderMeulen [:RyanVM] from comment #26)
Please, we need support for ESR91 too; Firefox 91ESR and all derived cannot be built against Rust-1.58.1 currentlyWhat is the build failure? It can't be the same bug, please file a separate bug and cc / ni? me please?
You're right, it's not a Rust dependent issue. Probably it's related to the bug #1754752
Sorry.
Description
•