Bug 1322803 - Allow setting additional rustflags via mozconfig. r=ted
authorMarco Castelluccio <mcastelluccio@mozilla.com>
Tue, 06 Jun 2017 01:05:10 +0100
changeset 410862 06967108134bd25250440c4e7429484856f811be
parent 410861 0d16a08bbcfa181535789a43856ef176cc9829c8
child 410863 68517278b72ef27b1b14c15c5c7155b4386a5257
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1322803
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1322803 - Allow setting additional rustflags via mozconfig. r=ted
build/moz.configure/toolchain.configure
config/rules.mk
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -1022,8 +1022,13 @@ option('--enable-hardening', env='MOZ_SE
 
 @depends('--enable-hardening', c_compiler)
 def security_hardening_cflags(value, c_compiler):
     if value and c_compiler.type in ['gcc', 'clang']:
         return '-fstack-protector-strong'
 
 add_old_configure_assignment('HARDENING_CFLAGS', security_hardening_cflags)
 imply_option('--enable-pie', depends_if('--enable-hardening')(lambda v: v))
+
+option(env='RUSTFLAGS',
+       nargs=1,
+       help='Rust compiler flags')
+set_config('RUSTFLAGS', depends('RUSTFLAGS')(lambda flags: flags))
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -931,25 +931,26 @@ endif
 # Cargo currently supports only two interesting profiles for building:
 # development and release.  Those map (roughly) to --enable-debug and
 # --disable-debug in Gecko, respectively, but there's another axis that we'd
 # like to support: --{disable,enable}-optimize.  Since that would be four
 # choices, and Cargo only supports two, we choose to enable various
 # optimization levels in our Cargo.toml files all the time, and override the
 # optimization level here, if necessary.  (The Cargo.toml files already
 # specify debug-assertions appropriately for --{disable,enable}-debug.)
+default_rustflags =
 ifndef MOZ_OPTIMIZE
-rustflags = -C opt-level=0
+default_rustflags = -C opt-level=0
 # Unfortunately, -C opt-level=0 implies -C debug-assertions, so we need
 # to explicitly disable them when MOZ_DEBUG_RUST is not set.
 ifndef MOZ_DEBUG_RUST
-rustflags += -C debug-assertions=no
+default_rustflags += -C debug-assertions=no
 endif
-rustflags_override = RUSTFLAGS='$(rustflags)'
 endif
+rustflags_override = RUSTFLAGS='$(default_rustflags) $(RUSTFLAGS)'
 
 ifdef MOZ_MSVCBITS
 # If we are building a MozillaBuild shell, we want to clear out the
 # vcvars.bat environment variables for cargo builds. This is because
 # a 32-bit MozillaBuild shell on a 64-bit machine will try to use
 # the 32-bit compiler/linker for everything, while cargo/rustc wants
 # to use the 64-bit linker for build.rs scripts. This conflict results
 # in a build failure (see bug 1350001). So we clear out the environment