зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1747533 - Update clang pass manager flags handling. r=firefox-build-system-reviewers,andi
- Avoid the flag selection silently not enabling the new pass manager when --enable-new-pass-manager is passed explicitly. - Avoid adding the -fexperimental-new-pass-manager to clang >= 13, which has it enabled by default. Likewise for the linker flags. - Remove the force-enable of the new pass manager with clang < 12 on automation, since we're using version 13 anyways. - Account for the fact that both lld and ld64 can pass the -import-hot-multiplier flag to the LTO plugin on mac builds, which effectively will set it for the first time on mac, and might improve performance. Differential Revision: https://phabricator.services.mozilla.com/D134860
This commit is contained in:
Родитель
69654fc5e6
Коммит
d179837cf2
|
@ -35,32 +35,68 @@ option(
|
||||||
enable_fuzzing,
|
enable_fuzzing,
|
||||||
ubsan,
|
ubsan,
|
||||||
)
|
)
|
||||||
def new_pass_manager_flags(enabled, compiler, host, target, pgo, enable_fuzzing, ubsan):
|
def pass_manager(enabled, compiler, host, target, pgo, enable_fuzzing, ubsan):
|
||||||
|
if compiler.type not in ("clang", "clang-cl"):
|
||||||
|
return None
|
||||||
|
|
||||||
|
# As of clang 13, the default pass manager is the new one.
|
||||||
|
if compiler.version >= "13.0.0":
|
||||||
|
if enabled:
|
||||||
|
return namespace(flags=None, enabled=True)
|
||||||
|
if compiler.type == "clang":
|
||||||
|
return namespace(flags=["-flegacy-pass-manager"], enabled=False)
|
||||||
|
if compiler.type == "clang-cl":
|
||||||
|
return namespace(flags=["-Xclang", "-flegacy-pass-manager"], enabled=False)
|
||||||
|
|
||||||
|
if not enabled:
|
||||||
|
return None
|
||||||
|
if compiler.version < "9.0.0":
|
||||||
|
if enabled.origin != "default":
|
||||||
|
die("--enable-new-pass-manager is only supported with clang >= 9")
|
||||||
|
return None
|
||||||
|
|
||||||
if host.os == "OSX":
|
if host.os == "OSX":
|
||||||
# Some native Mac builds hang with the new pass manager. Given the
|
# Some native Mac builds hang with the new pass manager. Given the
|
||||||
# inability to test in CI, don't take the risk of further breakage.
|
# inability to test in CI, don't take the risk of further breakage.
|
||||||
|
if enabled.origin != "default":
|
||||||
|
die(
|
||||||
|
"--enable-new-pass-manager causes problems on mac hosts with clang < 13"
|
||||||
|
)
|
||||||
return None
|
return None
|
||||||
if target.os == "OSX" and not pgo:
|
if target.os == "OSX" and not pgo:
|
||||||
# Also disable when cross-compiling to Mac, because plain-ish opt
|
# Also disable when cross-compiling to Mac, because plain-ish opt
|
||||||
# builds hang. Variants like asan and ccov work fine, but it would be
|
# builds hang. Variants like asan and ccov work fine, but it would be
|
||||||
# too tedious to test them all here. PGO is the only thing that matters
|
# too tedious to test them all here. PGO is the only thing that matters
|
||||||
# enough to make an exception for.
|
# enough to make an exception for.
|
||||||
|
if enabled.origin != "default":
|
||||||
|
die(
|
||||||
|
"--enable-new-pass-manager causes problems on mac builds with clang < 13"
|
||||||
|
)
|
||||||
return None
|
return None
|
||||||
if enable_fuzzing and compiler.version < "10.0.0":
|
if enable_fuzzing and compiler.version < "10.0.0":
|
||||||
# Clang 9 does not seem to play well with libFuzzer
|
# Clang 9 does not seem to play well with libFuzzer
|
||||||
|
if enabled.origin != "default":
|
||||||
|
die(
|
||||||
|
"--enable-new-pass-manager causes problems on fuzzing builds with clang < 10"
|
||||||
|
)
|
||||||
return None
|
return None
|
||||||
if ubsan and compiler.version == "10.0.0":
|
if ubsan and compiler.version == "10.0.0":
|
||||||
# Clang 10.0.0 hangs with some ubsan-inserted code constructs.
|
# Clang 10.0.0 hangs with some ubsan-inserted code constructs.
|
||||||
# This was fixed in 10.0.1 (https://llvm.org/pr45835)
|
# This was fixed in 10.0.1 (https://llvm.org/pr45835)
|
||||||
|
if enabled.origin != "default":
|
||||||
|
die(
|
||||||
|
"--enable-new-pass-manager causes problems with ubsan builds with clang 10.0.0"
|
||||||
|
)
|
||||||
return None
|
return None
|
||||||
if enabled and compiler.version >= "9.0.0":
|
|
||||||
if compiler.type == "clang":
|
if compiler.type == "clang":
|
||||||
return ["-fexperimental-new-pass-manager"]
|
return namespace(flags=["-fexperimental-new-pass-manager"], enabled=True)
|
||||||
elif compiler.type == "clang-cl":
|
elif compiler.type == "clang-cl":
|
||||||
return ["-Xclang", "-fexperimental-new-pass-manager"]
|
return namespace(
|
||||||
|
flags=["-Xclang", "-fexperimental-new-pass-manager"], enabled=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
set_config("MOZ_NEW_PASS_MANAGER_FLAGS", new_pass_manager_flags)
|
set_config("MOZ_PASS_MANAGER_FLAGS", pass_manager.flags)
|
||||||
|
|
||||||
|
|
||||||
# Try to make builds more reproducible and allow sharing built artifacts across
|
# Try to make builds more reproducible and allow sharing built artifacts across
|
||||||
|
|
|
@ -183,22 +183,20 @@ imply_option("MOZ_LD64_KNOWN_GOOD", depends_if("MOZ_AUTOMATION")(lambda _: True)
|
||||||
"--enable-lto",
|
"--enable-lto",
|
||||||
c_compiler,
|
c_compiler,
|
||||||
select_linker,
|
select_linker,
|
||||||
"MOZ_AUTOMATION",
|
|
||||||
"MOZ_LD64_KNOWN_GOOD",
|
"MOZ_LD64_KNOWN_GOOD",
|
||||||
target,
|
target,
|
||||||
"--enable-profile-generate",
|
"--enable-profile-generate",
|
||||||
new_pass_manager_flags,
|
pass_manager.enabled,
|
||||||
)
|
)
|
||||||
@imports("multiprocessing")
|
@imports("multiprocessing")
|
||||||
def lto(
|
def lto(
|
||||||
value,
|
value,
|
||||||
c_compiler,
|
c_compiler,
|
||||||
select_linker,
|
select_linker,
|
||||||
automation,
|
|
||||||
ld64_known_good,
|
ld64_known_good,
|
||||||
target,
|
target,
|
||||||
instrumented_build,
|
instrumented_build,
|
||||||
newpm_flags,
|
pass_manager,
|
||||||
):
|
):
|
||||||
cflags = []
|
cflags = []
|
||||||
ldflags = []
|
ldflags = []
|
||||||
|
@ -234,6 +232,7 @@ def lto(
|
||||||
target.kernel == "Darwin"
|
target.kernel == "Darwin"
|
||||||
and target.os == "OSX"
|
and target.os == "OSX"
|
||||||
and value == "cross"
|
and value == "cross"
|
||||||
|
and select_linker.KIND == "ld64"
|
||||||
and not ld64_known_good
|
and not ld64_known_good
|
||||||
):
|
):
|
||||||
die(
|
die(
|
||||||
|
@ -315,14 +314,16 @@ def lto(
|
||||||
# If we're using the new pass manager, we can also enable the new PM
|
# If we're using the new pass manager, we can also enable the new PM
|
||||||
# during LTO. Further we can use the resulting size savings to increase
|
# during LTO. Further we can use the resulting size savings to increase
|
||||||
# the import limit in hot functions.
|
# the import limit in hot functions.
|
||||||
if newpm_flags:
|
if pass_manager:
|
||||||
if target.os == "WINNT":
|
if target.os == "WINNT":
|
||||||
# On Windows, this flag requires a change from clang-12, which
|
if c_compiler.version >= "12.0.0" and c_compiler.version < "13.0.0":
|
||||||
# is applied as a patch to our automation toolchain.
|
|
||||||
if automation or c_compiler.version >= "12.0.0":
|
|
||||||
ldflags.append("-opt:ltonewpassmanager")
|
ldflags.append("-opt:ltonewpassmanager")
|
||||||
|
if c_compiler.version >= "12.0.0":
|
||||||
ldflags.append("-mllvm:-import-hot-multiplier=30")
|
ldflags.append("-mllvm:-import-hot-multiplier=30")
|
||||||
elif select_linker.KIND != "ld64" and c_compiler.type == "clang":
|
elif target.os == "OSX":
|
||||||
|
ldflags.append("-Wl,-mllvm,-import-hot-multiplier=30")
|
||||||
|
else:
|
||||||
|
if c_compiler.version < "13.0.0":
|
||||||
ldflags.append("-Wl,-plugin-opt=new-pass-manager")
|
ldflags.append("-Wl,-plugin-opt=new-pass-manager")
|
||||||
ldflags.append("-Wl,-plugin-opt=-import-hot-multiplier=30")
|
ldflags.append("-Wl,-plugin-opt=-import-hot-multiplier=30")
|
||||||
|
|
||||||
|
|
|
@ -655,8 +655,8 @@ class CompileFlags(TargetCompileFlags):
|
||||||
("CXXFLAGS", "CFLAGS"),
|
("CXXFLAGS", "CFLAGS"),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"NEWPM",
|
"PASS_MANAGER",
|
||||||
context.config.substs.get("MOZ_NEW_PASS_MANAGER_FLAGS"),
|
context.config.substs.get("MOZ_PASS_MANAGER_FLAGS"),
|
||||||
("CXXFLAGS", "CFLAGS"),
|
("CXXFLAGS", "CFLAGS"),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
|
Загрузка…
Ссылка в новой задаче