Bug 1869043 add a main thread record of track audio outputs r=padenot
[gecko.git] / build / moz.configure / flags.configure
blobd5526dc9300248ddb2a367901a16a0d9ca7b1765
1 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
2 # vim: set filetype=python:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 # We support C++14, but we don't want to enable the sized deallocation
8 # facilities in C++14 yet.
9 check_and_add_flag("-fno-sized-deallocation", compiler=cxx_compiler)
10 # Likewise for C++17 and aligned allocation.  It's not immediately obvious
11 # from the clang and GCC documentation, but they both support this.
12 check_and_add_flag("-fno-aligned-new", compiler=cxx_compiler)
14 # Please keep these last in this file.
15 add_old_configure_assignment("_COMPILATION_CFLAGS", compilation_flags.cflags)
16 add_old_configure_assignment("_COMPILATION_CXXFLAGS", compilation_flags.cxxflags)
17 add_old_configure_assignment("_COMPILATION_HOST_CFLAGS", compilation_flags.host_cflags)
18 add_old_configure_assignment(
19     "_COMPILATION_HOST_CXXFLAGS", compilation_flags.host_cxxflags
23 option(
24     "--disable-new-pass-manager",
25     help="Use the legacy LLVM pass manager in clang builds",
29 @depends(
30     "--enable-new-pass-manager",
31     c_compiler,
32     host,
33     target,
34     "MOZ_PGO",
35     enable_fuzzing,
36     ubsan,
38 def pass_manager(enabled, compiler, host, target, pgo, enable_fuzzing, ubsan):
39     if compiler.type not in ("clang", "clang-cl"):
40         return None
42     # As of clang 13, the default pass manager is the new one.
43     if compiler.version >= "13.0.0":
44         if enabled:
45             return namespace(flags=None, enabled=True)
46         if compiler.type == "clang":
47             return namespace(flags=["-flegacy-pass-manager"], enabled=False)
48         if compiler.type == "clang-cl":
49             return namespace(flags=["-Xclang", "-flegacy-pass-manager"], enabled=False)
51     if not enabled:
52         if compiler.version >= "15.0.0":
53             die("--disable-new-pass-manager is only supported with clang < 15")
54         return None
55     if compiler.version < "9.0.0":
56         if enabled.origin != "default":
57             die("--enable-new-pass-manager is only supported with clang >= 9")
58         return None
60     if host.os == "OSX":
61         # Some native Mac builds hang with the new pass manager. Given the
62         # inability to test in CI, don't take the risk of further breakage.
63         if enabled.origin != "default":
64             die(
65                 "--enable-new-pass-manager causes problems on mac hosts with clang < 13"
66             )
67         return None
68     if target.os == "OSX" and not pgo:
69         # Also disable when cross-compiling to Mac, because plain-ish opt
70         # builds hang. Variants like asan and ccov work fine, but it would be
71         # too tedious to test them all here. PGO is the only thing that matters
72         # enough to make an exception for.
73         if enabled.origin != "default":
74             die(
75                 "--enable-new-pass-manager causes problems on mac builds with clang < 13"
76             )
77         return None
78     if enable_fuzzing and compiler.version < "10.0.0":
79         # Clang 9 does not seem to play well with libFuzzer
80         if enabled.origin != "default":
81             die(
82                 "--enable-new-pass-manager causes problems on fuzzing builds with clang < 10"
83             )
84         return None
85     if ubsan and compiler.version == "10.0.0":
86         # Clang 10.0.0 hangs with some ubsan-inserted code constructs.
87         # This was fixed in 10.0.1 (https://llvm.org/pr45835)
88         if enabled.origin != "default":
89             die(
90                 "--enable-new-pass-manager causes problems with ubsan builds with clang 10.0.0"
91             )
92         return None
93     if compiler.type == "clang":
94         return namespace(flags=["-fexperimental-new-pass-manager"], enabled=True)
95     elif compiler.type == "clang-cl":
96         return namespace(
97             flags=["-Xclang", "-fexperimental-new-pass-manager"], enabled=True
98         )
101 set_config("MOZ_PASS_MANAGER_FLAGS", pass_manager.flags)
104 # Try to make builds more reproducible and allow sharing built artifacts across
105 # source and object directories by using -ffile-prefix-map and friends.  To
106 # "unwind" the prefix maps, use:
108 # (gdb) set substitute-path /topsrcdir/ $topsrcdir/
110 # (lldb) settings set target.source-map /topobjdir/ $topobjdir/
112 # See, for example, https://lldb.llvm.org/use/map.html.
113 @depends(
114     path_remapping,
115     path_remappings,
116     c_compiler,
118 @imports(_from="os", _import="sep")
119 def file_prefix_map_flags(path_remapping, path_remappings, compiler):
120     if "c" not in path_remapping:
121         return []
123     if (compiler.type == "gcc" and compiler.version < "8.1") or (
124         compiler.type in ("clang", "clang-cl") and compiler.version < "10.0.0"
125     ):
126         die(
127             f"Compiler of type {compiler.type} and version {compiler.version} "
128             "does not support --enable-path-remapping."
129         )
131     flags = []
132     for old, new in path_remappings:
133         # We would prefer to use just -ffile-prefix-map, but clang-cl doesn't
134         # seem to recognize it.
135         for flag in ("-fdebug-prefix-map", "-fmacro-prefix-map"):
136             flag = f"{flag}={old}={new}"
137             if compiler.type in ("gcc", "clang"):
138                 flags.append(flag)
139             elif compiler.type == "clang-cl":
140                 flags.extend(["-Xclang", flag])
142     return flags
145 set_config("MOZ_FILE_PREFIX_MAP_FLAGS", file_prefix_map_flags)