Bug 1360497 - Use line numbers from macro definition rather than macro invocation for code expanded from macros. draft
authorHenri Sivonen <hsivonen@hsivonen.fi>
Fri, 28 Apr 2017 13:00:27 +0300
changeset 570640 5e3ac29ee0c744e87ab80aa35508fd6722047bd9
parent 569997 c116ee0e69da3c17688017e4a46a10fe48b5bcc7
child 570641 766ee629a1fa7be5c5a2ab5e5d9e7869f48d956f
child 571256 a9fd1dbbb9002e062fbea5f35720bd91500d80d1
child 571945 268937c3642567eaac0c6a8e55edd8af5e2b8062
child 574067 34d8555663355f4a6fccc0764972fbe04e3a44a1
child 575362 9e7d7c2b35806ff9958c3dd6a5b6e9c47e320ecf
child 579541 24faa30238dbbbe93d5eb4a863f2b2caf93ff728
push id56539
push userbmo:hsivonen@hsivonen.fi
push dateSat, 29 Apr 2017 16:15:32 +0000
bugs1360497
milestone55.0a1
Bug 1360497 - Use line numbers from macro definition rather than macro invocation for code expanded from macros. MozReview-Commit-ID: HWSkJz5myce
config/rules.mk
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -899,16 +899,26 @@ endif
 endif
 
 $(foreach file,$(DUMP_SYMS_TARGETS),$(eval $(call syms_template,$(file),$(file)_syms.track)))
 
 ifdef MOZ_RUST
 cargo_host_flag := --target=$(RUST_HOST_TARGET)
 cargo_target_flag := --target=$(RUST_TARGET)
 
+# Permit users to pass flags to rustc from their mozconfigs
+rustflags = '$(RUSTFLAGS)'
+
+# By default, rustc annotates lines expanded from a macro with the
+# location of the macro invocation rather than the location of the line
+# in the macro definition. To make panic stacks useful on try and in the
+# crash reporter and to get correct attribution in profiling, let's
+# override the default behavior.
+rustflags += -Zdebug-macros
+
 # Permit users to pass flags to cargo from their mozconfigs (e.g. --color=always).
 cargo_build_flags = $(CARGOFLAGS)
 ifndef MOZ_DEBUG_RUST
 cargo_build_flags += --release
 endif
 cargo_build_flags += --frozen
 
 cargo_build_flags += --manifest-path $(CARGO_FILE)
@@ -933,23 +943,22 @@ endif
 # 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.)
 ifndef MOZ_OPTIMIZE
-rustflags = -C opt-level=0
+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
 endif
-rustflags_override = RUSTFLAGS='$(rustflags)'
 endif
 
 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
@@ -958,17 +967,17 @@ ifdef MOZ_MSVCBITS
 environment_cleaner = PATH='' LIB='' LIBPATH=''
 # The servo build needs to know where python is, and we're removing the PATH
 # so we tell it explicitly via the PYTHON env var.
 environment_cleaner += PYTHON='$(shell which $(PYTHON))'
 else
 environment_cleaner =
 endif
 
-CARGO_BUILD = env $(environment_cleaner) $(rustflags_override) \
+CARGO_BUILD = env $(environment_cleaner) RUSTFLAGS='$(rustflags)' \
 	CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) \
 	RUSTC=$(RUSTC) \
 	MOZ_DIST=$(ABS_DIST) \
 	LIBCLANG_PATH=$(MOZ_LIBCLANG_PATH) \
 	CLANG_PATH=$(MOZ_CLANG_PATH) \
 	PKG_CONFIG_ALLOW_CROSS=1 \
 	RUST_BACKTRACE=1 \
 	MOZ_TOPOBJDIR=$(topobjdir) \