Bug 1360497 - Use line numbers from macro definition rather than macro invocation for code expanded from macros.
MozReview-Commit-ID: HWSkJz5myce
--- 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) \