diff --git a/build/moz.configure/rust.configure b/build/moz.configure/rust.configure index 3333a3735dae71..2783d4dff108ad 100644 --- a/build/moz.configure/rust.configure +++ b/build/moz.configure/rust.configure @@ -120,6 +120,12 @@ set_config( ) +set_config( + "RUSTC_LLVM_VERSION", + depends(rustc_info)(lambda info: str(info.llvm_version) if info else None), +) + + @depends_if(cargo) @checking("cargo version", lambda info: info.version) @imports("re") diff --git a/config/makefiles/rust.mk b/config/makefiles/rust.mk index 74e3ddaed3ecc3..4dfe6b2b43465e 100644 --- a/config/makefiles/rust.mk +++ b/config/makefiles/rust.mk @@ -239,6 +239,11 @@ ifdef MOZ_PROFILE_GENERATE # because -C panic=unwind (the compiler default) is not compatible with -C profile-generate # (https://github.com/rust-lang/rust/issues/61002). rust_pgo_flags := -C panic=abort -C profile-generate=$(topobjdir) +ifeq (1,$(words $(filter 5.% 6.% 7.% 8.% 9.% 10.% 11.%,$(CC_VERSION) $(RUSTC_LLVM_VERSION)))) +# Disable value profiling when: +# (RUSTC_LLVM_VERSION < 12 and CC_VERSION >= 12) or (RUSTC_LLVM_VERSION >= 12 and CC_VERSION < 12) +rust_pgo_flags += -C llvm-args=--disable-vp=true +endif # The C compiler may be passed extra llvm flags for PGO that we also want to pass to rust as well. # In PROFILE_GEN_CFLAGS, they look like "-mllvm foo", and we want "-C llvm-args=foo", so first turn # "-mllvm foo" into "-mllvm:foo" so that it becomes a unique argument, that we can then filter for,