Closed
Bug 1177608
Opened 9 years ago
Closed 9 years ago
Support for compiling optimised Rust code
Categories
(Firefox Build System :: General, defect)
Firefox Build System
General
Tracking
(firefox42 fixed)
RESOLVED
FIXED
mozilla42
Tracking | Status | |
---|---|---|
firefox42 | --- | fixed |
People
(Reporter: ato, Assigned: ato)
References
Details
Attachments
(1 file)
By default Gecko builds are optimised and non-optimised debug builds are only produced when the `ac_add_options --enable-debug` line is in the mozconfig file. We should match this behaviour when we compile Rust code in Gecko by using the `-C opt-level=N` flag on rustc. The -o shorthand flag on rustc seems to default to optimisation level 2, although the highest is 3. Matching the rustc defaults would seem reasonable in this case.
Comment 1•9 years ago
|
||
This may be somewhat unrelated, but another point of configuration in how you drive the compiler is whether debug assertions are on or off by default. Debug assertions are enabled in unoptimized code by default but disabled by default with opt levels > 1, and can also be manually configured with `-C debug-assertions={on,off}` (just FYI!)
Comment 2•9 years ago
|
||
For Gecko builds we have a few options: --enable-optimize (on by default): compile with optimizations. --enable-debug (off by default): compile with debug assertions --enable-debug-symbols (on by default): compile with debugging symbols
Comment 3•9 years ago
|
||
In that case I'd recommend these flags to the Rust compiler for the various configure options: --enable-optimize -O --enable-debug -C debug-assertions=on (not needed if -O isn't present) --enable-debug-symbols -g
Comment 4•9 years ago
|
||
Note that --enable-debug doesn't disable optimizations (it used to, a long time ago)
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → ato
Status: NEW → ASSIGNED
Assignee | ||
Comment 5•9 years ago
|
||
Bug 1177608: Support for compiling optimised Rust code; r=ted Optimised Rust compilation is enabled on passing --enable-optimize to the configure script. This sets the RFLAGS output variable that gets picked up by the compile target RSOBJS and passed to rustc. * build/autoconf/rust.m4: New file, introduces backport of AC_LANG_RUST and RUST_TRY_COMPILE. * aclocal.m4: Include build/autoconf/rust.m4. * config/config.mk (MOZ_OPTIMIZE): Sets RFLAGS. * config/rules.mk (RSOBJS): Include RFLAGS when calling rustc. * configure.in (MOZ_OPTIMIZE): Add rustc -O compile check and add new MOZ_OPTIMIZE_RFLAGS output variable.
Attachment #8636562 -
Flags: review?(mh+mozilla)
Comment 6•9 years ago
|
||
I like having the rust macros, but every version of rustc supports -O, so just assuming it works would also be ok. Up to the build peers whether we want to keep this machinery around in case it's useful later.
Updated•9 years ago
|
Attachment #8636562 -
Flags: review?(mh+mozilla)
Comment 7•9 years ago
|
||
Comment on attachment 8636562 [details] MozReview Request: Bug 1177608: Support for compiling optimised Rust code; r=glandium https://reviewboard.mozilla.org/r/13687/#review12359 ::: configure.in:7096 (Diff revision 1) > + RFLAGS="$RFLAGS $MOZ_OPTIMIZE_RFLAGS" I don't know what the convention is for rust makefiles if there are any, but RFLAGS sounds weird when you know the R language exists. It also seems we went for a RS prefix with RSOBJS and RSSRCS in config/rules.mk, so RSFLAGS would fit the pattern. I also feel like we don't need the complexity of having customizable and verified rust optimization flags. Just hardcode -O and skip the m4.
Comment 8•9 years ago
|
||
FWIW, before the cargo-ification of Servo (when we were autotools-based), we used the `RUSTFLAGS` variable for clarity.
Assignee | ||
Comment 9•9 years ago
|
||
Comment on attachment 8636562 [details] MozReview Request: Bug 1177608: Support for compiling optimised Rust code; r=glandium Bug 1177608: Support for compiling optimised Rust code; r=glandium Optimised Rust compilation is enabled on passing --enable-optimize to the configure script. This sets the RUSTFLAGS output variable that gets picked up by the compile targets RSOBJS and RSSRCS and passed to rustc.
Attachment #8636562 -
Attachment description: MozReview Request: Bug 1177608: Support for compiling optimised Rust code; r=ted → MozReview Request: Bug 1177608: Support for compiling optimised Rust code; r=glandium
Attachment #8636562 -
Flags: review?(mh+mozilla)
Assignee | ||
Comment 10•9 years ago
|
||
https://reviewboard.mozilla.org/r/13687/#review12359 > I don't know what the convention is for rust makefiles if there are any, but RFLAGS sounds weird when you know the R language exists. It also seems we went for a RS prefix with RSOBJS and RSSRCS in config/rules.mk, so RSFLAGS would fit the pattern. > > I also feel like we don't need the complexity of having customizable and verified rust optimization flags. Just hardcode -O and skip the m4. Renamed `RFLAGS` to `RUSTFLAGS` per Lars’s suggestion. Also hardcoded -O optimisation flag. There are already some compilation tests on Mac OS for which the M4 macros would be useful, but will re-add them as part of a separate patch.
Assignee | ||
Comment 11•9 years ago
|
||
Filed bug 1186455 as a follow-up for reintroducing the more generalised Rust autoconf macros and replacing the manual linkage test for Mac OS.
Assignee | ||
Comment 12•9 years ago
|
||
try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=ba68a54c2fd6
Updated•9 years ago
|
Attachment #8636562 -
Flags: review?(mh+mozilla) → review+
Comment 13•9 years ago
|
||
Comment on attachment 8636562 [details] MozReview Request: Bug 1177608: Support for compiling optimised Rust code; r=glandium https://reviewboard.mozilla.org/r/13687/#review12457 Ship It! ::: config/config.mk:352 (Diff revision 2) > +RUSTFLAGS += $(MOZ_OPTIMIZE_RUSTFLAGS) I'm tempted to say to just put -O here and skip the related configure.in changes.
Comment 15•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/9c0560d8c51f
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox42:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
Updated•6 years ago
|
Product: Core → Firefox Build System
You need to log in
before you can comment on or make changes to this bug.
Description
•