Closed Bug 1612797 Opened 2 years ago Closed 1 year ago

Compilation failed with multiple "must be an integral multiple of js::gc::CellAlignBytes" since GCC 10 on armv7

Categories

(Core :: JavaScript Engine, defect)

74 Branch
ARM
Linux
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: fzatlouk, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: regression)

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.16 Safari/537.36

Steps to reproduce:

Compile Firefox 68 ESR (68.4 and 68.4.2 tested) with GCC 10 on armv7hl.

This is a regression only on armv7hl from GCC 10 (GCC 9.2 works just fine). However, I am not really sure if this is a problem in Firefox codebase, or something that should be fixed in GCC.

Actual results:

Entire compile log: https://kojipkgs.fedoraproject.org//work/tasks/1176/41321176/build.log

Multiple static_assert failed:
/builddir/build/BUILD/firefox-68.4.2/js/src/vm/Shape.h: In static member function 'static void js::BaseShape::staticAsserts()':
/builddir/build/BUILD/firefox-68.4.2/js/src/vm/Shape.h:807:58: error: static assertion failed: Things inheriting from gc::Cell must have a size that's a multiple of gc::CellAlignBytes
807 | static_assert(sizeof(BaseShape) % gc::CellAlignBytes == 0,

...

/builddir/build/BUILD/firefox-68.4.2/js/src/vm/JSScript.h: At global scope:
/builddir/build/BUILD/firefox-68.4.2/js/src/vm/JSScript.h:3408:59: error: static assertion failed: Size of LazyScript must be an integral multiple of js::gc::CellAlignBytes
3408 | static_assert(sizeof(LazyScript) % js::gc::CellAlignBytes == 0,

Component: Untriaged → General
Keywords: regression
OS: Unspecified → Linux
Product: Firefox → Firefox Build System
Hardware: Unspecified → ARM64
Hardware: ARM64 → ARM

This issue disappears with "--enable-unaligned-private-values" compilation flag: https://src.fedoraproject.org/rpms/mozjs68/c/688cbe5bc96700ff46c3d42a0f46c1f11585d9b2?branch=master

So, no, adding "--enable-unaligned-private-values" does not help.

Bug still applies for Firefox ESR 68.5.0.

Attached file build.log

This is happening also with Firefox 74.

Version: 68 Branch → 74 Branch
Component: General → JavaScript Engine
Product: Firefox Build System → Core

(In reply to František Zatloukal from comment #0)

Multiple static_assert failed:
/builddir/build/BUILD/firefox-68.4.2/js/src/vm/Shape.h: In static member function 'static void js::BaseShape::staticAsserts()':
/builddir/build/BUILD/firefox-68.4.2/js/src/vm/Shape.h:807:58: error: static assertion failed: Things inheriting from gc::Cell must have a size that's a multiple of gc::CellAlignBytes
807 | static_assert(sizeof(BaseShape) % gc::CellAlignBytes == 0,

This sounds like this this might be an issue with GCC.

BaseShape inherits from gc::TenuredCell. (https://searchfox.org/mozilla-central/rev/c79c0d65a183d9d38676855f455a5c6a7f7dadd3/js/src/vm/Shape.h#666)
gc::TenuredCell inherits from gc::Cell. (https://searchfox.org/mozilla-central/rev/c79c0d65a183d9d38676855f455a5c6a7f7dadd3/js/src/gc/Cell.h#220)
gc::Cell has the alignas(gc::CellAlignBytes) annotation. (https://searchfox.org/mozilla-central/rev/c79c0d65a183d9d38676855f455a5c6a7f7dadd3/js/src/gc/Cell.h#116)

This code is the same on esr68.
It might also be possible that the static assertion is bogus:
https://searchfox.org/mozilla-central/rev/c79c0d65a183d9d38676855f455a5c6a7f7dadd3/js/src/vm/Shape.h#840-842

I do not recall exactly but I am not sure whether sizeof is guaranteed to be a multiple of the aligned size. While I would totally understand if it were to add this limitation based on the number on the quantity of pointer arithmetic code which exists.

I wonder if the following assertion would also fail:
alignof(BaseShape) % gc::CellAlignBytes == 0

and if it succeeds, then a simple work-around would be to add some padding to the BaseShape class until the original assertion passes.

(In reply to Nicolas B. Pierron [:nbp] from comment #5)

(In reply to František Zatloukal from comment #0)

Multiple static_assert failed:
/builddir/build/BUILD/firefox-68.4.2/js/src/vm/Shape.h: In static member function 'static void js::BaseShape::staticAsserts()':
/builddir/build/BUILD/firefox-68.4.2/js/src/vm/Shape.h:807:58: error: static assertion failed: Things inheriting from gc::Cell must have a size that's a multiple of gc::CellAlignBytes
807 | static_assert(sizeof(BaseShape) % gc::CellAlignBytes == 0,

This sounds like this this might be an issue with GCC.

Or not. alignas does not influence sizeof. Thus this seems to suggest that we are missing some padding here.
Then I wonder what cause this assertion to trip after changing to gcc 10.

Yes, it seems gcc devs agree it's gcc regression: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94050

Should I close this BR?

Yeah, please do :)
thanks!

Status: UNCONFIRMED → RESOLVED
Closed: 1 year ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.