All users were logged out of Bugzilla on October 13th, 2018

Rust code should be compiled with THUMB2 as Android/arm's default

RESOLVED FIXED in Firefox 58

Status

P2
normal
RESOLVED FIXED
a year ago
8 months ago

People

(Reporter: m_kato, Assigned: m_kato)

Tracking

Trunk
mozilla59
Unspecified
Android
Dependency tree / graph

Firefox Tracking Flags

(firefox-esr52 unaffected, firefox56 unaffected, firefox57 wontfix, firefox58 fixed)

Details

(Assignee)

Description

a year ago
Our official android binary is built by armv7-a + thumb2.  But rust code is generated by arm32' not thumb2 even if MOZ_THUMB2=1.

rustc doesn't generate thumb2 code as default's armv7-linux-androideabi, so we have to pass -C target-feature=+v7,+thumb-mode,+thumb2 to cargo rustc to generate thumb2 code.

(Rust's standard library is still arm32 code...)
(Assignee)

Updated

a year ago
Blocks: 1366049
(Assignee)

Comment 1

a year ago
/(Rust's standard library is still arm32 code...)/(Rust's standard library might be still arm32 code, but I don't know yet)
(Assignee)

Comment 2

a year ago
for rust's library, https://github.com/rust-lang/rust/pull/44589
(Assignee)

Comment 3

a year ago
Reducing 40KB when using thumb2 for rust.

without thumb2 for rust code
APK ... 32948628 (libxul 19393344)
with thumb2 for rust code
APK ... 32908438 (libxul 19353144)
Status: NEW → ASSIGNED

Comment 4

a year ago
What's the status of this task? Is it ready to fix? Is it a blocker for Stylo on Android?
(Assignee)

Comment 5

a year ago
(In reply to Tatsuyuki Ishi from comment #4)
> What's the status of this task? Is it ready to fix? Is it a blocker for
> Stylo on Android?

not blocker.  But I should fix this on 59 if possible.
(In reply to Makoto Kato [:m_kato] from comment #3)
> Reducing 40KB when using thumb2 for rust.
> 
> without thumb2 for rust code
> APK ... 32948628 (libxul 19393344)
> with thumb2 for rust code
> APK ... 32908438 (libxul 19353144)

I guess when Rust's standard library starts using thumb2, the size can be further reduced?
(Assignee)

Comment 7

a year ago
(In reply to Xidorn Quan [:xidorn] UTC+10 (less responsive Nov 5 ~ Dec 16) from comment #6)
> (In reply to Makoto Kato [:m_kato] from comment #3)
> > Reducing 40KB when using thumb2 for rust.
> > 
> > without thumb2 for rust code
> > APK ... 32948628 (libxul 19393344)
> > with thumb2 for rust code
> > APK ... 32908438 (libxul 19353144)
> 
> I guess when Rust's standard library starts using thumb2, the size can be
> further reduced?

Maybe yes. 1.22 will use thumb2 for android/armv7 if no regression.  So I will update data when using 1.22 (if possible)

Updated

11 months ago
Priority: -- → P2
@ Ralph, Firefox's Rust Update Policy wiki [1] says mozilla-central will update to Rust 1.22 on 2017-11-23 (Firefox 59). Is there any prep work we can do now to make sure the update goes smoothly? Stylo for Android needs some ARM fixes in Rust 1.22. We hope to enable and ship Stylo for Android in Firefox 59, so we'd like to require Rust 1.22 as soon as possible.

@ Makoto, once the Firefox build requires Rust 1.22, are there additional build configuration changes necessary to use thumb2 for Stylo? Will Rust 1.22's standard library also use thumb2 instead of arm32? Or will we need a special build of the standard library on Android?

[1] https://wiki.mozilla.org/Rust_Update_Policy_for_Firefox#Schedule
status-firefox56: --- → unaffected
status-firefox57: affected → wontfix
status-firefox58: --- → affected
status-firefox-esr52: --- → unaffected
Flags: needinfo?(m_kato)
Flags: needinfo?(giles)
I've been testing 1.22.0-beta.2. I think there's an issue remaining with win32 support. Let me check again with this week's m-c.

If you just need it for arm, we can bump official android builds to rust 1.22 now while it's still in beta, since those currently work. I assume the two codegen options are compatible, and you just need this for size? Requiring 1.22 isn't something we can do before December.
Flags: needinfo?(giles)
(Assignee)

Comment 10

11 months ago
(In reply to Chris Peterson [:cpeterson] from comment #8)

> @ Makoto, once the Firefox build requires Rust 1.22, are there additional
> build configuration changes necessary to use thumb2 for Stylo? Will Rust
> 1.22's standard library also use thumb2 instead of arm32? Or will we need a
> special build of the standard library on Android?
> 
> [1] https://wiki.mozilla.org/Rust_Update_Policy_for_Firefox#Schedule

Actually, all rust code in Gecko is generated by arm32, not thumb2.  If code is compiled as thumb2 (our default arch on android/arm), it can diet binary size.  Also, even if rust 1.21, we can generate thumb2 code to add "-C target-feature=+v7,+thumb-mode,+thumb2" to RUSTFLAGS.   But rust system library still keeps arm32 on rust 1.21.  When using Rust 1.22 beta, system library for armv7-anroideabi (and default build for armv7-android) is built by thumb2.

comment #3 data is rust 1.21 with "-C target-feature=+v7,+thumb-mode,+thumb2".  It will be small win even if 1.21.
Flags: needinfo?(m_kato)
(In reply to Ralph Giles (:rillian) | needinfo me from comment #9)
> If you just need it for arm, we can bump official android builds to rust
> 1.22 now while it's still in beta, since those currently work. I assume the
> two codegen options are compatible, and you just need this for size?
> Requiring 1.22 isn't something we can do before December.

Stylo doesn't require any new language features from 1.22. We just want our official Android builds to compiled as thumb2.

Makoto can correct me, but I don't think we need to rush to use the 1.22 beta builds. 1.21's arm32 stdlib works correctly and we'll just need to bump the required Rust version again when the 1.22 stable builds are available.
Depends on: 1411361
(Assignee)

Comment 12

11 months ago
Since bug 1411361 is landed, it reduces 50-70KB for APK at least.
(Assignee)

Updated

11 months ago
Status: ASSIGNED → RESOLVED
Last Resolved: 11 months ago
status-firefox58: affected → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla59

Updated

8 months ago
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.