2017-11-15 21:53:16 +03:00
|
|
|
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
|
|
|
|
# vim: set filetype=python:
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
# We support C++14, but we don't want to enable the sized deallocation
|
|
|
|
# facilities in C++14 yet.
|
2022-04-26 01:21:31 +03:00
|
|
|
check_and_add_flag("-fno-sized-deallocation", compiler=cxx_compiler)
|
2019-08-14 04:37:34 +03:00
|
|
|
# Likewise for C++17 and aligned allocation. It's not immediately obvious
|
|
|
|
# from the clang and GCC documentation, but they both support this.
|
2022-04-26 01:21:31 +03:00
|
|
|
check_and_add_flag("-fno-aligned-new", compiler=cxx_compiler)
|
2017-11-15 21:53:16 +03:00
|
|
|
|
|
|
|
# Please keep these last in this file.
|
2017-12-21 05:11:22 +03:00
|
|
|
add_old_configure_assignment("_COMPILATION_CFLAGS", compilation_flags.cflags)
|
|
|
|
add_old_configure_assignment("_COMPILATION_CXXFLAGS", compilation_flags.cxxflags)
|
|
|
|
add_old_configure_assignment("_COMPILATION_HOST_CFLAGS", compilation_flags.host_cflags)
|
|
|
|
add_old_configure_assignment(
|
|
|
|
"_COMPILATION_HOST_CXXFLAGS", compilation_flags.host_cxxflags
|
|
|
|
)
|
2018-12-14 14:34:15 +03:00
|
|
|
|
|
|
|
|
2020-10-08 07:07:46 +03:00
|
|
|
option(
|
|
|
|
"--disable-new-pass-manager",
|
|
|
|
help="Use the legacy LLVM pass manager in clang builds",
|
|
|
|
)
|
2020-03-11 05:08:37 +03:00
|
|
|
|
2020-10-26 21:34:53 +03:00
|
|
|
|
2020-05-12 21:01:48 +03:00
|
|
|
@depends(
|
|
|
|
"--enable-new-pass-manager",
|
|
|
|
c_compiler,
|
|
|
|
host,
|
|
|
|
target,
|
|
|
|
"MOZ_PGO",
|
|
|
|
enable_fuzzing,
|
|
|
|
ubsan,
|
|
|
|
)
|
2021-12-31 11:41:16 +03:00
|
|
|
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:
|
2022-05-24 11:21:42 +03:00
|
|
|
if compiler.version >= "15.0.0":
|
|
|
|
die("--disable-new-pass-manager is only supported with clang < 15")
|
2021-12-31 11:41:16 +03:00
|
|
|
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
|
|
|
|
|
2020-03-11 05:08:37 +03:00
|
|
|
if host.os == "OSX":
|
2020-03-16 20:57:41 +03:00
|
|
|
# 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.
|
2021-12-31 11:41:16 +03:00
|
|
|
if enabled.origin != "default":
|
|
|
|
die(
|
|
|
|
"--enable-new-pass-manager causes problems on mac hosts with clang < 13"
|
|
|
|
)
|
2020-03-16 20:57:41 +03:00
|
|
|
return None
|
2020-03-25 17:24:08 +03:00
|
|
|
if target.os == "OSX" and not pgo:
|
|
|
|
# Also disable when cross-compiling to Mac, because plain-ish opt
|
|
|
|
# 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
|
|
|
|
# enough to make an exception for.
|
2021-12-31 11:41:16 +03:00
|
|
|
if enabled.origin != "default":
|
|
|
|
die(
|
|
|
|
"--enable-new-pass-manager causes problems on mac builds with clang < 13"
|
|
|
|
)
|
2020-03-25 17:24:08 +03:00
|
|
|
return None
|
2020-03-27 16:32:06 +03:00
|
|
|
if enable_fuzzing and compiler.version < "10.0.0":
|
|
|
|
# Clang 9 does not seem to play well with libFuzzer
|
2021-12-31 11:41:16 +03:00
|
|
|
if enabled.origin != "default":
|
|
|
|
die(
|
|
|
|
"--enable-new-pass-manager causes problems on fuzzing builds with clang < 10"
|
|
|
|
)
|
2020-03-27 16:32:06 +03:00
|
|
|
return None
|
2021-02-11 20:13:09 +03:00
|
|
|
if ubsan and compiler.version == "10.0.0":
|
|
|
|
# Clang 10.0.0 hangs with some ubsan-inserted code constructs.
|
|
|
|
# This was fixed in 10.0.1 (https://llvm.org/pr45835)
|
2021-12-31 11:41:16 +03:00
|
|
|
if enabled.origin != "default":
|
|
|
|
die(
|
|
|
|
"--enable-new-pass-manager causes problems with ubsan builds with clang 10.0.0"
|
|
|
|
)
|
2020-05-12 21:01:48 +03:00
|
|
|
return None
|
2021-12-31 11:41:16 +03:00
|
|
|
if compiler.type == "clang":
|
|
|
|
return namespace(flags=["-fexperimental-new-pass-manager"], enabled=True)
|
|
|
|
elif compiler.type == "clang-cl":
|
|
|
|
return namespace(
|
|
|
|
flags=["-Xclang", "-fexperimental-new-pass-manager"], enabled=True
|
|
|
|
)
|
2020-10-26 21:34:53 +03:00
|
|
|
|
2020-03-11 05:08:37 +03:00
|
|
|
|
2021-12-31 11:41:16 +03:00
|
|
|
set_config("MOZ_PASS_MANAGER_FLAGS", pass_manager.flags)
|
2021-06-10 20:08:06 +03:00
|
|
|
|
|
|
|
|
|
|
|
# Try to make builds more reproducible and allow sharing built artifacts across
|
|
|
|
# source and object directories by using -ffile-prefix-map and friends. To
|
|
|
|
# "unwind" the prefix maps, use:
|
|
|
|
#
|
|
|
|
# (gdb) set substitute-path /topsrcdir/ $topsrcdir/
|
|
|
|
#
|
|
|
|
# (lldb) settings set target.source-map /topobjdir/ $topobjdir/
|
|
|
|
#
|
|
|
|
# See, for example, https://lldb.llvm.org/use/map.html.
|
|
|
|
@depends(
|
|
|
|
path_remapping,
|
|
|
|
path_remappings,
|
|
|
|
c_compiler,
|
|
|
|
)
|
|
|
|
@imports(_from="os", _import="sep")
|
|
|
|
def file_prefix_map_flags(path_remapping, path_remappings, compiler):
|
|
|
|
if "c" not in path_remapping:
|
|
|
|
return []
|
|
|
|
|
|
|
|
if (compiler.type == "gcc" and compiler.version < "8.1") or (
|
|
|
|
compiler.type in ("clang", "clang-cl") and compiler.version < "10.0.0"
|
|
|
|
):
|
|
|
|
die(
|
|
|
|
f"Compiler of type {compiler.type} and version {compiler.version} "
|
|
|
|
"does not support --enable-path-remapping."
|
|
|
|
)
|
|
|
|
|
|
|
|
flags = []
|
|
|
|
for old, new in path_remappings:
|
|
|
|
# We would prefer to use just -ffile-prefix-map, but clang-cl doesn't
|
|
|
|
# seem to recognize it.
|
|
|
|
for flag in ("-fdebug-prefix-map", "-fmacro-prefix-map"):
|
|
|
|
flag = f"{flag}={old}={new}"
|
|
|
|
if compiler.type in ("gcc", "clang"):
|
|
|
|
flags.append(flag)
|
|
|
|
elif compiler.type == "clang-cl":
|
|
|
|
flags.extend(["-Xclang", flag])
|
|
|
|
|
|
|
|
return flags
|
|
|
|
|
|
|
|
|
|
|
|
set_config("MOZ_FILE_PREFIX_MAP_FLAGS", file_prefix_map_flags)
|