Backed out changeset 8ed1797a2640 (bug 1821680) dev spotted a bug. CLOSED TREE

This commit is contained in:
Sandor Molnar 2023-05-10 12:26:12 +03:00
Родитель c88f0ab69f
Коммит 2b1a30bb79
2 изменённых файлов: 18 добавлений и 31 удалений

Просмотреть файл

@ -165,7 +165,7 @@ set_config("MOZ_PGO_RUST", moz_pgo_rust)
option(
"--enable-lto",
env="MOZ_LTO",
nargs="*",
nargs="?",
choices=("full", "thin", "cross"),
help="Enable LTO",
)
@ -190,7 +190,7 @@ imply_option("MOZ_LD64_KNOWN_GOOD", depends_if("MOZ_AUTOMATION")(lambda _: True)
)
@imports("multiprocessing")
def lto(
values,
value,
c_compiler,
select_linker,
ld64_known_good,
@ -203,30 +203,26 @@ def lto(
enabled = None
rust_lto = False
if not values:
if not value:
return
# Sanitize LTO modes.
if "full" in values and "thin" in values:
die("incompatible --enable-lto choices 'full' and 'thin'")
# If a value was given to --enable-lto, use that.
# Otherwise, make the lto mode explicit, using
# If a value was given to --enable-lto, use that, otherwise, default to
# thin with clang/clang-cl and full with gcc.
if not values or values == ("cross",):
if c_compiler.type == "gcc":
values += ("full",)
else:
values += ("thin",)
if len(value):
value = value[0]
elif c_compiler.type == "gcc":
value = "full"
else:
value = "thin"
if instrumented_build:
log.warning("Disabling LTO because --enable-profile-generate is specified")
return
if c_compiler.type == "gcc":
if "cross" in values:
if value == "cross":
die("Cross-language LTO is not supported with GCC.")
if "thin" in values:
if value == "thin":
die(
"gcc does not support thin LTO. Use `--enable-lto` "
"to enable full LTO for gcc."
@ -235,7 +231,7 @@ def lto(
if (
target.kernel == "Darwin"
and target.os == "OSX"
and "cross" in values
and value == "cross"
and select_linker.KIND == "ld64"
and not ld64_known_good
):
@ -247,14 +243,14 @@ def lto(
)
if c_compiler.type == "clang":
if "full" in values:
if value == "full":
cflags.append("-flto")
ldflags.append("-flto")
else:
cflags.append("-flto=thin")
ldflags.append("-flto=thin")
if target.os == "Android" and "cross" in values:
if target.os == "Android" and value == "cross":
# Work around https://github.com/rust-lang/rust/issues/90088
# by enabling the highest level of SSE the rust targets default
# to.
@ -265,7 +261,7 @@ def lto(
elif target.cpu == "x86_64":
ldflags.append("-Wl,-plugin-opt=-mattr=+sse4.2")
elif c_compiler.type == "clang-cl":
if "full" in values:
if value == "full":
cflags.append("-flto")
else:
cflags.append("-flto=thin")
@ -331,17 +327,11 @@ def lto(
ldflags.append("-Wl,-plugin-opt=new-pass-manager")
ldflags.append("-Wl,-plugin-opt=-import-hot-multiplier=30")
# Pick Rust LTO mode in case of cross lTO. Thin is the default.
if "cross" in values:
rust_lto = "full" if "full" in values else "thin"
else:
rust_lto = ""
return namespace(
enabled=True,
cflags=cflags,
ldflags=ldflags,
rust_lto=rust_lto,
rust_lto=(value == "cross"),
)

Просмотреть файл

@ -280,10 +280,7 @@ rust_pgo_flags := -C profile-use=$(PGO_PROFILE_PATH)
endif
endif
$(target_rust_ltoable): RUSTFLAGS:=$(rustflags_override) $(rustflags_sancov) $(RUSTFLAGS) $(rust_pgo_flags) \
$(if $(MOZ_LTO_RUST_CROSS),\
-Clinker-plugin-lto \
$(if $(filter full,$(MOZ_LTO_RUST_CROSS)), -Clto=fat,),)
$(target_rust_ltoable): RUSTFLAGS:=$(rustflags_override) $(rustflags_sancov) $(RUSTFLAGS) $(if $(MOZ_LTO_RUST_CROSS),-Clinker-plugin-lto) $(rust_pgo_flags)
$(target_rust_nonltoable): RUSTFLAGS:=$(rustflags_override) $(rustflags_sancov) $(RUSTFLAGS)
TARGET_RECIPES := $(target_rust_ltoable) $(target_rust_nonltoable)