1 import("//llvm/utils/gn/build/buildflags.gni")
2 import("//llvm/utils/gn/build/mac_sdk.gni")
3 import("//llvm/utils/gn/build/toolchain/compiler.gni")
4 import("//llvm/utils/gn/build/toolchain/target_flags.gni")
7 # Whether to build everything with coverage information.
8 # After building with this, run tests and then run
9 # llvm/utils/prepare-code-coverage-artifact.py \
10 # .../llvm-profdata .../llvm-cov out/gn/profiles/ report/ \
11 # out/gn/bin/llvm-undname ...`
12 # to generate a HTML report for the binaries passed in the last line.
13 llvm_build_instrumented_coverage = false
16 assert(!llvm_build_instrumented_coverage || is_clang,
17 "llvm_build_instrumented_coverage requires clang as host compiler")
19 config("compiler_defaults") {
22 if (!llvm_enable_assertions) {
23 defines += [ "NDEBUG" ]
26 asmflags = target_flags
28 ldflags = target_flags + target_ldflags
30 if (host_os == "mac" && clang_base_path != "") {
37 if (host_os != "win") {
44 cflags += [ "-fdiagnostics-color" ]
47 "-fvisibility-inlines-hidden",
55 ldflags += [ "/DEBUG" ]
68 "_CRT_SECURE_NO_DEPRECATE",
69 "_CRT_SECURE_NO_WARNINGS",
70 "_CRT_NONSTDC_NO_DEPRECATE",
71 "_CRT_NONSTDC_NO_WARNINGS",
72 "_SCL_SECURE_NO_DEPRECATE",
73 "_SCL_SECURE_NO_WARNINGS",
79 cflags += [ "/EHs-c-" ]
81 # The MSVC default value (1 MB) is not enough for parsing recursive C++
83 ldflags += [ "/STACK:10000000" ]
87 if (host_os == "win" && !is_clang) {
89 # Suppress ''modifier' : used more than once' (__forceinline and inline).
92 # Suppress 'conversion from 'type1' to 'type2', possible loss of data'.
95 # Suppress 'conversion from 'size_t' to 'type', possible loss of data'.
98 # Suppress 'no matching operator delete found'.
101 # Suppress 'noexcept used with no exception handling mode specified'.
104 # Suppress 'destructor was implicitly defined as deleted'.
107 # Suppress 'unsafe mix of type <type> and type <type> in operation'.
111 if (host_os == "win") {
119 cflags += [ "-Wno-unused-parameter" ]
122 "-Wdelete-non-virtual-dtor",
123 "-Wstring-conversion",
127 # GCC's -Wcomment complains about // comments ending with '\' if the
128 # next line is also a // comment.
131 # Disable gcc's potentially uninitialized use analysis as it presents
132 # lots of false positives.
133 "-Wno-maybe-uninitialized",
136 # The LLVM libraries have no stable C++ API, so -Wnoexcept-type is not
138 "-Wno-noexcept-type",
141 if (is_clang && use_goma) {
142 # goma converts all paths to lowercase on the server, breaking this
144 cflags += [ "-Wno-nonportable-include-path" ]
148 # On Windows, the linker is not invoked through the compiler driver.
149 if (use_lld && host_os != "win") {
150 ldflags += [ "-fuse-ld=lld" ]
153 if (llvm_build_instrumented_coverage) {
155 "-fcoverage-mapping",
157 # Using an absolute path here is lame, but it's used at test execution
158 # time to generate the profiles, and lit doesn't specify a fixed folder
159 # for test execution -- so this is the only way to get all profiles into
160 # a single folder like llvm/utils/prepare-code-coverage-artifact.py
162 "-fprofile-instr-generate=" +
163 rebase_path("$root_build_dir/profiles/%4m.profraw"),
165 ldflags += [ "-fprofile-instr-generate" ]
169 config("no_exceptions") {
170 if (host_os != "win") {
171 cflags_cc = [ "-fno-exceptions" ]
176 if (current_os == "win") {
177 cflags_cc = [ "/GR-" ]
179 cflags_cc = [ "-fno-rtti" ]
183 # To make an archive that can be distributed, you need to remove this config and
184 # set complete_static_lib.
185 config("thin_archive") {
186 if (current_os != "win" && current_os != "mac") {
191 config("llvm_code") {
194 "$root_gen_dir/llvm/include",
201 "$root_gen_dir/lld/include",
205 config("clang_code") {
206 if (host_os != "win") {
207 cflags = [ "-fno-strict-aliasing" ]
211 "$root_gen_dir/clang/include",
216 include_dirs = [ "//compiler-rt/lib" ]
220 "-gline-tables-only",
224 config("warn_covered_switch_default") {
226 cflags = [ "-Wcovered-switch-default" ]