2016-07-21 19:25:45 +00:00
|
|
|
# Copyright 2016 Google Inc.
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
2019-09-25 21:14:35 +00:00
|
|
|
if (is_fuchsia) {
|
2019-11-18 16:01:05 +00:00
|
|
|
import("//build/fuchsia/sdk.gni")
|
2019-09-25 21:14:35 +00:00
|
|
|
}
|
|
|
|
|
2016-07-21 19:25:45 +00:00
|
|
|
declare_args() {
|
2017-03-28 19:45:41 +00:00
|
|
|
extra_asmflags = []
|
2016-10-04 21:09:13 +00:00
|
|
|
extra_cflags = []
|
|
|
|
extra_cflags_c = []
|
|
|
|
extra_cflags_cc = []
|
|
|
|
extra_ldflags = []
|
2016-08-26 20:43:19 +00:00
|
|
|
|
2016-12-09 00:00:40 +00:00
|
|
|
malloc = ""
|
2020-06-19 21:25:12 +00:00
|
|
|
werror = false
|
2019-10-18 18:29:09 +00:00
|
|
|
xcode_sysroot = ""
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
2016-10-24 20:49:15 +00:00
|
|
|
|
2019-10-18 18:29:09 +00:00
|
|
|
if (is_ios && xcode_sysroot == "") {
|
2017-03-14 20:22:32 +00:00
|
|
|
if (is_tvos) {
|
|
|
|
sdk = "appletvos"
|
|
|
|
if (target_cpu == "x86" || target_cpu == "x64") {
|
|
|
|
sdk = "appletvsimulator"
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
sdk = "iphoneos"
|
|
|
|
if (target_cpu == "x86" || target_cpu == "x64") {
|
|
|
|
sdk = "iphonesimulator"
|
|
|
|
}
|
2017-03-13 16:25:33 +00:00
|
|
|
}
|
2019-10-18 18:29:09 +00:00
|
|
|
xcode_sysroot = exec_script("find_xcode_sysroot.py", [ sdk ], "trim string")
|
|
|
|
}
|
|
|
|
|
|
|
|
# If building for mac on a mac then lookup all the system includes so that goma and the clang
|
|
|
|
# shipped with chrome can find them. When the gn_to_bp.py tool is run, then the host_os != mac.
|
|
|
|
# In this case leave the xcode_sysroot empty, and the cc/c++ that come with XCode will be able to
|
|
|
|
# find needed include paths.
|
|
|
|
if (is_mac && host_os == "mac" && xcode_sysroot == "") {
|
|
|
|
xcode_sysroot =
|
|
|
|
exec_script("find_xcode_sysroot.py", [ "macosx" ], "trim string")
|
2016-11-03 18:06:31 +00:00
|
|
|
}
|
|
|
|
|
2016-09-16 21:44:18 +00:00
|
|
|
config("default") {
|
|
|
|
asmflags = []
|
|
|
|
cflags = []
|
|
|
|
cflags_c = []
|
|
|
|
cflags_cc = []
|
|
|
|
defines = []
|
|
|
|
ldflags = []
|
2016-12-09 00:00:40 +00:00
|
|
|
libs = []
|
2016-09-16 21:44:18 +00:00
|
|
|
|
2019-04-23 12:38:07 +00:00
|
|
|
if (werror) {
|
|
|
|
if (is_win) {
|
|
|
|
cflags += [ "/WX" ]
|
|
|
|
} else {
|
|
|
|
cflags += [ "-Werror" ]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-19 15:17:51 +00:00
|
|
|
# Disable warnings about unknown attributes.
|
|
|
|
# (These unknown attribute warnings are on by default, so we don't make
|
|
|
|
# disabling them part of :warnings, as some targets remove :warnings.)
|
|
|
|
if (is_win && !is_clang) {
|
|
|
|
cflags += [ "/wd5030" ]
|
|
|
|
} else {
|
|
|
|
cflags += [ "-Wno-attributes" ]
|
|
|
|
}
|
|
|
|
|
2019-09-25 21:14:35 +00:00
|
|
|
if (is_fuchsia && using_fuchsia_sdk) {
|
2019-11-18 16:01:05 +00:00
|
|
|
ldflags += [
|
|
|
|
"-v",
|
|
|
|
"--sysroot=" + rebase_path("$fuchsia_sdk_path/arch/$target_cpu/sysroot"),
|
|
|
|
]
|
|
|
|
cflags += [ "--sysroot=" +
|
|
|
|
rebase_path("$fuchsia_sdk_path/arch/$target_cpu/sysroot") ]
|
2019-09-25 21:14:35 +00:00
|
|
|
if (target_cpu == "x64") {
|
|
|
|
target_triple = "--target=x86_64-${target_os}"
|
|
|
|
} else if (target_cpu == "arm64") {
|
|
|
|
target_triple = "--target=aarch64-unknown-${target_os}"
|
|
|
|
} else {
|
|
|
|
print("Unknown target CPU for Fuchsia target build.")
|
|
|
|
assert(false)
|
|
|
|
}
|
|
|
|
ldflags += [ target_triple ]
|
|
|
|
cflags += [ target_triple ]
|
|
|
|
asmflags += [ target_triple ]
|
|
|
|
}
|
|
|
|
|
2016-09-16 21:44:18 +00:00
|
|
|
if (is_win) {
|
2019-04-17 13:18:10 +00:00
|
|
|
if (is_clang && target_cpu == "arm64") {
|
|
|
|
cflags += [ "--target=arm64-windows" ]
|
|
|
|
}
|
2016-09-16 21:44:18 +00:00
|
|
|
cflags += [
|
2016-09-16 20:29:57 +00:00
|
|
|
"/bigobj", # Some of our files are bigger than the regular limits.
|
2017-01-03 22:09:59 +00:00
|
|
|
"/utf-8", # Set Source and Executable character sets to UTF-8.
|
2016-09-16 20:29:57 +00:00
|
|
|
]
|
2019-11-07 15:42:41 +00:00
|
|
|
cflags_cc += [ "/std:c++17" ]
|
2016-09-16 21:44:18 +00:00
|
|
|
defines += [
|
2016-10-13 03:58:06 +00:00
|
|
|
"_CRT_SECURE_NO_WARNINGS", # Disables warnings about sscanf().
|
|
|
|
"_HAS_EXCEPTIONS=0", # Disables exceptions in MSVC STL.
|
2016-09-16 21:44:18 +00:00
|
|
|
"WIN32_LEAN_AND_MEAN",
|
|
|
|
"NOMINMAX",
|
2016-09-16 20:29:57 +00:00
|
|
|
]
|
2017-07-31 19:46:47 +00:00
|
|
|
|
2019-07-10 15:24:52 +00:00
|
|
|
_include_dirs = [
|
|
|
|
"$win_vc/Tools/MSVC/$win_toolchain_version/include",
|
2017-12-06 20:21:44 +00:00
|
|
|
"$win_sdk/Include/$win_sdk_version/shared",
|
|
|
|
"$win_sdk/Include/$win_sdk_version/ucrt",
|
|
|
|
"$win_sdk/Include/$win_sdk_version/um",
|
|
|
|
"$win_sdk/Include/$win_sdk_version/winrt",
|
|
|
|
]
|
|
|
|
|
2017-07-31 19:46:47 +00:00
|
|
|
if (is_clang) {
|
|
|
|
foreach(dir, _include_dirs) {
|
|
|
|
cflags += [
|
|
|
|
"-imsvc",
|
|
|
|
dir,
|
|
|
|
]
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
include_dirs = _include_dirs
|
|
|
|
}
|
|
|
|
|
2017-12-06 20:21:44 +00:00
|
|
|
lib_dirs = [
|
|
|
|
"$win_sdk/Lib/$win_sdk_version/ucrt/$target_cpu",
|
|
|
|
"$win_sdk/Lib/$win_sdk_version/um/$target_cpu",
|
2019-07-10 15:24:52 +00:00
|
|
|
"$win_vc/Tools/MSVC/$win_toolchain_version/lib/$target_cpu",
|
2017-12-06 20:21:44 +00:00
|
|
|
]
|
2016-09-16 21:44:18 +00:00
|
|
|
} else {
|
2019-12-16 08:46:52 +00:00
|
|
|
cflags += [
|
|
|
|
"-fstrict-aliasing",
|
|
|
|
"-fPIC",
|
|
|
|
]
|
2019-11-07 15:42:41 +00:00
|
|
|
cflags_cc += [ "-std=c++17" ]
|
2017-03-27 00:11:48 +00:00
|
|
|
|
|
|
|
# The main idea is to slim the exported API, but these flags also improve link time on Mac.
|
|
|
|
# These would make stack traces worse on Linux, so we don't just set them willy-nilly.
|
2017-03-28 18:16:22 +00:00
|
|
|
if (is_component_build || is_ios || is_mac) {
|
2017-03-27 00:11:48 +00:00
|
|
|
cflags += [ "-fvisibility=hidden" ]
|
|
|
|
cflags_cc += [ "-fvisibility-inlines-hidden" ]
|
|
|
|
}
|
2016-09-16 21:44:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (current_cpu == "arm") {
|
|
|
|
cflags += [
|
|
|
|
"-march=armv7-a",
|
|
|
|
"-mfpu=neon",
|
|
|
|
"-mthumb",
|
|
|
|
]
|
2018-03-21 17:07:35 +00:00
|
|
|
} else if (current_cpu == "x86" && !is_win) {
|
2016-09-16 21:44:18 +00:00
|
|
|
asmflags += [ "-m32" ]
|
|
|
|
cflags += [
|
|
|
|
"-m32",
|
|
|
|
"-msse2",
|
|
|
|
"-mfpmath=sse",
|
|
|
|
]
|
|
|
|
ldflags += [ "-m32" ]
|
|
|
|
}
|
|
|
|
|
2016-12-09 00:00:40 +00:00
|
|
|
if (malloc != "" && !is_win) {
|
|
|
|
cflags += [
|
|
|
|
"-fno-builtin-malloc",
|
|
|
|
"-fno-builtin-calloc",
|
|
|
|
"-fno-builtin-realloc",
|
|
|
|
"-fno-builtin-free",
|
|
|
|
]
|
|
|
|
libs += [ malloc ]
|
|
|
|
}
|
|
|
|
|
2018-06-01 20:22:25 +00:00
|
|
|
if (is_android) {
|
2019-07-03 15:44:21 +00:00
|
|
|
cflags += [ "--sysroot=$ndk/sysroot" ]
|
|
|
|
cflags_cc += [ "-isystem$ndk/sources/cxx-stl/llvm-libc++/include" ]
|
|
|
|
ldflags += [ "-static-libstdc++" ]
|
2016-09-16 21:44:18 +00:00
|
|
|
}
|
|
|
|
|
2016-11-03 18:06:31 +00:00
|
|
|
if (is_ios) {
|
2017-01-23 16:58:53 +00:00
|
|
|
_target = target_cpu
|
|
|
|
if (target_cpu == "arm") {
|
|
|
|
_target = "armv7"
|
2017-03-13 16:25:33 +00:00
|
|
|
} else if (target_cpu == "x86") {
|
|
|
|
_target = "i386"
|
|
|
|
} else if (target_cpu == "x64") {
|
|
|
|
_target = "x86_64"
|
2017-01-23 16:58:53 +00:00
|
|
|
}
|
2017-02-17 20:36:01 +00:00
|
|
|
asmflags += [
|
|
|
|
"-isysroot",
|
2019-10-18 18:29:09 +00:00
|
|
|
xcode_sysroot,
|
2017-02-17 20:36:01 +00:00
|
|
|
"-arch",
|
|
|
|
_target,
|
|
|
|
]
|
2016-11-03 18:06:31 +00:00
|
|
|
cflags += [
|
2016-11-07 20:38:48 +00:00
|
|
|
"-isysroot",
|
2019-10-18 18:29:09 +00:00
|
|
|
xcode_sysroot,
|
2016-11-07 20:38:48 +00:00
|
|
|
"-arch",
|
2017-01-23 16:58:53 +00:00
|
|
|
_target,
|
2016-11-03 18:06:31 +00:00
|
|
|
]
|
2019-11-07 15:42:41 +00:00
|
|
|
cflags_cc += [
|
|
|
|
"-stdlib=libc++",
|
|
|
|
"-fno-aligned-allocation",
|
|
|
|
]
|
2016-11-03 18:06:31 +00:00
|
|
|
ldflags += [
|
2016-11-07 20:38:48 +00:00
|
|
|
"-isysroot",
|
2019-10-18 18:29:09 +00:00
|
|
|
xcode_sysroot,
|
2016-11-07 20:38:48 +00:00
|
|
|
"-arch",
|
2017-01-23 16:58:53 +00:00
|
|
|
_target,
|
2016-11-03 18:06:31 +00:00
|
|
|
"-stdlib=libc++",
|
|
|
|
]
|
2016-12-09 00:00:40 +00:00
|
|
|
libs += [ "objc" ]
|
2016-11-03 18:06:31 +00:00
|
|
|
}
|
|
|
|
|
2016-09-16 21:44:18 +00:00
|
|
|
if (is_linux) {
|
2016-12-09 00:00:40 +00:00
|
|
|
libs += [ "pthread" ]
|
2016-09-16 21:44:18 +00:00
|
|
|
}
|
2019-10-18 18:29:09 +00:00
|
|
|
|
2017-12-07 17:48:57 +00:00
|
|
|
if (is_mac) {
|
2019-10-18 18:29:09 +00:00
|
|
|
# If there was a xcode_sysroot set in args or calculated then use it, else don't set anything
|
|
|
|
# because the XCode cc/c++ already know all this stuff.
|
|
|
|
if (xcode_sysroot != "") {
|
|
|
|
asmflags += [
|
|
|
|
"-isysroot",
|
|
|
|
xcode_sysroot,
|
|
|
|
]
|
|
|
|
cflags += [
|
|
|
|
"-isysroot",
|
|
|
|
xcode_sysroot,
|
|
|
|
]
|
|
|
|
ldflags += [
|
|
|
|
"-isysroot",
|
|
|
|
xcode_sysroot,
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2017-12-07 17:48:57 +00:00
|
|
|
# Disable linker warnings. They're usually just annoyances like,
|
|
|
|
# ld: warning: text-based stub file
|
|
|
|
# /System/Library/Frameworks/foo.framework/foo.tbd and library file
|
|
|
|
# /System/Library/Frameworks/foo.framework/foo are out of sync.
|
|
|
|
# Falling back to library file for linking.
|
|
|
|
ldflags += [ "-Wl,-w" ]
|
|
|
|
}
|
2016-08-25 21:50:44 +00:00
|
|
|
|
2019-02-04 15:01:53 +00:00
|
|
|
if (sanitize != "" && sanitize != "MSVC") {
|
2016-09-16 21:44:18 +00:00
|
|
|
# You can either pass the sanitizers directly, e.g. "address,undefined",
|
|
|
|
# or pass one of the couple common aliases used by the bots.
|
|
|
|
sanitizers = sanitize
|
2018-03-20 14:10:58 +00:00
|
|
|
|
2019-12-21 05:53:11 +00:00
|
|
|
if (sanitize == "ASAN") {
|
2018-01-03 16:04:30 +00:00
|
|
|
# ASAN implicitly runs all UBSAN checks also.
|
2019-12-21 05:53:11 +00:00
|
|
|
sanitizers = "undefined,address"
|
2018-03-20 14:10:58 +00:00
|
|
|
|
2018-01-12 19:31:48 +00:00
|
|
|
if (is_android) {
|
2018-08-10 16:25:12 +00:00
|
|
|
# TODO(mtklein): work out UBSAN link errors
|
2018-01-12 19:31:48 +00:00
|
|
|
sanitizers = "address"
|
|
|
|
}
|
2016-09-16 21:44:18 +00:00
|
|
|
} else if (sanitize == "TSAN") {
|
|
|
|
sanitizers = "thread"
|
|
|
|
} else if (sanitize == "MSAN") {
|
|
|
|
sanitizers = "memory"
|
2016-09-08 15:39:34 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 17:16:50 +00:00
|
|
|
_suppressions = rebase_path("../tools/xsan.supp")
|
2018-08-08 14:23:17 +00:00
|
|
|
|
2016-09-16 21:44:18 +00:00
|
|
|
cflags += [
|
2018-08-10 16:25:12 +00:00
|
|
|
"-fsanitize=$sanitizers",
|
2016-09-16 21:44:18 +00:00
|
|
|
"-fno-sanitize-recover=$sanitizers",
|
2020-07-24 17:16:50 +00:00
|
|
|
"-fsanitize-blacklist=$_suppressions",
|
2016-09-16 21:44:18 +00:00
|
|
|
]
|
2019-12-18 20:25:50 +00:00
|
|
|
|
2018-08-09 21:24:45 +00:00
|
|
|
if (is_win) {
|
2019-12-21 05:53:11 +00:00
|
|
|
cflags += [
|
2020-07-24 17:16:50 +00:00
|
|
|
"/FI$_suppressions",
|
2019-12-21 05:53:11 +00:00
|
|
|
|
|
|
|
# On Release builds, we get strange warnings about string literals.
|
|
|
|
"/GF-",
|
|
|
|
]
|
|
|
|
|
|
|
|
assert(clang_win != "")
|
|
|
|
libs += [ "$clang_win/lib/clang/$clang_win_version/lib/windows/clang_rt.asan-x86_64.lib" ]
|
2018-08-09 21:24:45 +00:00
|
|
|
} else {
|
|
|
|
cflags += [
|
2020-07-24 17:16:50 +00:00
|
|
|
"-include$_suppressions",
|
2018-08-09 21:24:45 +00:00
|
|
|
"-fno-omit-frame-pointer",
|
|
|
|
]
|
2019-12-21 05:53:11 +00:00
|
|
|
|
|
|
|
ldflags += [ "-fsanitize=$sanitizers" ]
|
2018-02-15 14:45:58 +00:00
|
|
|
}
|
2018-08-09 21:24:45 +00:00
|
|
|
|
2018-02-15 14:45:58 +00:00
|
|
|
if (is_linux) {
|
2018-02-15 14:03:44 +00:00
|
|
|
cflags_cc += [ "-stdlib=libc++" ]
|
|
|
|
ldflags += [ "-stdlib=libc++" ]
|
2018-02-01 17:09:55 +00:00
|
|
|
}
|
2018-08-10 16:25:12 +00:00
|
|
|
|
2016-09-16 21:44:18 +00:00
|
|
|
if (sanitizers == "memory") {
|
|
|
|
cflags += [ "-fsanitize-memory-track-origins" ]
|
2016-09-16 20:29:57 +00:00
|
|
|
}
|
2019-11-07 15:42:41 +00:00
|
|
|
if (sanitizers == "safe-stack") {
|
|
|
|
cflags_cc += [ "-fno-aligned-allocation" ]
|
|
|
|
}
|
2016-09-16 21:44:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-31 17:07:51 +00:00
|
|
|
# See skia:9731.
|
|
|
|
config("recover_pointer_overflow") {
|
|
|
|
cflags = [ "-fsanitize-recover=pointer-overflow" ]
|
|
|
|
}
|
|
|
|
|
2016-10-26 15:41:47 +00:00
|
|
|
config("no_exceptions") {
|
2017-08-16 13:20:20 +00:00
|
|
|
# Exceptions are disabled by default on Windows. (Use /EHsc to enable them.)
|
2016-10-26 15:41:47 +00:00
|
|
|
if (!is_win) {
|
|
|
|
cflags_cc = [ "-fno-exceptions" ]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-13 03:58:06 +00:00
|
|
|
config("warnings") {
|
|
|
|
cflags = []
|
|
|
|
cflags_cc = []
|
2016-10-20 14:17:47 +00:00
|
|
|
cflags_objc = []
|
2017-07-12 20:21:09 +00:00
|
|
|
cflags_objcc = []
|
2016-10-13 03:58:06 +00:00
|
|
|
if (is_win) {
|
|
|
|
cflags += [
|
|
|
|
"/W3", # Turn on lots of warnings.
|
|
|
|
|
|
|
|
# Disable a bunch of warnings:
|
|
|
|
"/wd4244", # conversion from 'float' to 'int', possible loss of data
|
|
|
|
"/wd4267", # conversion from 'size_t' to 'int', possible loss of data
|
2020-04-01 18:47:34 +00:00
|
|
|
"/wd4800", # forcing value to bool 'true' or 'false' (performance
|
|
|
|
# warning)
|
2016-10-13 03:58:06 +00:00
|
|
|
|
|
|
|
# Probably only triggers when /EHsc is enabled.
|
|
|
|
"/wd4291", # no matching operator delete found;
|
2020-04-01 18:47:34 +00:00
|
|
|
# memory will not be freed if initialization throws an
|
|
|
|
# exception
|
2019-04-10 20:22:15 +00:00
|
|
|
|
|
|
|
# These only show up in shared builds:
|
2020-04-01 18:47:34 +00:00
|
|
|
"/wd4251", # class 'type' needs to have dll-interface to be used by
|
|
|
|
# clients of class 'type2'
|
|
|
|
"/wd4275", # non dll-interface class 'base' used as base for
|
|
|
|
# dll-interface class 'derived'
|
2019-11-07 15:42:41 +00:00
|
|
|
|
|
|
|
# It'd be nice to fix these and turn this on:
|
2020-04-01 18:47:34 +00:00
|
|
|
"/wd5041", # out-of-line definition for constexpr static data member is
|
|
|
|
# not needed and is deprecated in C++17
|
2020-04-30 11:45:25 +00:00
|
|
|
|
|
|
|
# warning C4996: 'std::result_of_t': warning STL4014: std::result_of and std::result_of_t are
|
|
|
|
# deprecated in C++17. They are superseded by std::invoke_result and std::invoke_result_t.
|
|
|
|
"/wd4996",
|
2016-10-13 03:58:06 +00:00
|
|
|
]
|
|
|
|
} else {
|
|
|
|
cflags += [
|
|
|
|
"-Wall",
|
|
|
|
"-Wextra",
|
|
|
|
"-Winit-self",
|
|
|
|
"-Wpointer-arith",
|
|
|
|
"-Wsign-compare",
|
|
|
|
"-Wvla",
|
|
|
|
|
|
|
|
"-Wno-deprecated-declarations",
|
2016-12-13 17:46:05 +00:00
|
|
|
"-Wno-maybe-uninitialized",
|
2016-10-13 03:58:06 +00:00
|
|
|
]
|
2018-03-13 20:56:43 +00:00
|
|
|
cflags_cc += [
|
|
|
|
"-Wnon-virtual-dtor",
|
|
|
|
"-Wno-noexcept-type",
|
2020-03-27 18:29:38 +00:00
|
|
|
"-Wno-redundant-move", #TODO: gcc conflict with return-std-move-in-c++11
|
2018-03-13 20:56:43 +00:00
|
|
|
]
|
2017-12-04 19:01:30 +00:00
|
|
|
}
|
2016-10-13 03:58:06 +00:00
|
|
|
|
2017-12-04 19:01:30 +00:00
|
|
|
if (is_clang) {
|
|
|
|
cflags += [
|
2019-02-28 14:47:44 +00:00
|
|
|
"-fcolor-diagnostics",
|
2017-12-04 19:01:30 +00:00
|
|
|
"-Weverything",
|
2020-04-01 18:47:34 +00:00
|
|
|
"-Wno-unknown-warning-option", # Let older Clangs ignore newer Clangs'
|
|
|
|
# warnings.
|
2017-12-04 19:01:30 +00:00
|
|
|
]
|
2016-10-13 03:58:06 +00:00
|
|
|
|
2017-12-04 19:01:30 +00:00
|
|
|
if (target_cpu == "arm" && is_ios) {
|
|
|
|
# Clang seems to think new/malloc will only be 4-byte aligned on 32-bit iOS.
|
|
|
|
# We're pretty sure it's actually 8-byte alignment.
|
|
|
|
cflags += [ "-Wno-over-aligned" ]
|
2016-10-13 03:58:06 +00:00
|
|
|
}
|
2018-01-08 23:23:32 +00:00
|
|
|
if (target_cpu == "x86" && is_android) {
|
|
|
|
# Clang seems to think new/malloc will only be 4-byte aligned on 32-bit x86 Android builds.
|
|
|
|
# We're pretty sure it's actually 8-byte alignment. See OverAlignedTest.cpp for more info.
|
|
|
|
cflags += [ "-Wno-over-aligned" ]
|
|
|
|
}
|
2017-12-04 19:01:30 +00:00
|
|
|
|
|
|
|
# Shouldn't be necessary for local builds. With distributed Windows builds, files may lose
|
|
|
|
# their case during copy, causing case-sensitivity mismatch on remote machines.
|
|
|
|
cflags += [
|
|
|
|
"-Wno-nonportable-include-path",
|
|
|
|
"-Wno-nonportable-system-include-path",
|
|
|
|
]
|
|
|
|
|
|
|
|
# TODO: These would all be really great warnings to turn on.
|
|
|
|
cflags += [
|
|
|
|
"-Wno-cast-align",
|
|
|
|
"-Wno-cast-qual",
|
|
|
|
"-Wno-conversion",
|
|
|
|
"-Wno-disabled-macro-expansion",
|
|
|
|
"-Wno-documentation",
|
|
|
|
"-Wno-documentation-unknown-command",
|
|
|
|
"-Wno-double-promotion",
|
|
|
|
"-Wno-exit-time-destructors", # TODO: OK outside libskia
|
|
|
|
"-Wno-float-equal",
|
|
|
|
"-Wno-format-nonliteral",
|
|
|
|
"-Wno-global-constructors", # TODO: OK outside libskia
|
|
|
|
"-Wno-missing-prototypes",
|
|
|
|
"-Wno-missing-variable-declarations",
|
|
|
|
"-Wno-pedantic",
|
|
|
|
"-Wno-reserved-id-macro",
|
|
|
|
"-Wno-shadow",
|
|
|
|
"-Wno-shift-sign-overflow",
|
|
|
|
"-Wno-signed-enum-bitfield",
|
|
|
|
"-Wno-switch-enum",
|
|
|
|
"-Wno-undef",
|
|
|
|
"-Wno-unreachable-code",
|
|
|
|
"-Wno-unreachable-code-break",
|
|
|
|
"-Wno-unreachable-code-return",
|
|
|
|
"-Wno-unused-macros",
|
|
|
|
"-Wno-unused-member-function",
|
|
|
|
"-Wno-unused-template",
|
|
|
|
"-Wno-zero-as-null-pointer-constant",
|
2019-05-09 20:59:18 +00:00
|
|
|
"-Wno-thread-safety-negative",
|
2020-06-02 16:41:55 +00:00
|
|
|
"-Wno-non-c-typedef-for-linkage", # Dawn, not Skia per se.
|
2017-12-04 19:01:30 +00:00
|
|
|
]
|
|
|
|
cflags_cc += [
|
|
|
|
"-Wno-abstract-vbase-init",
|
|
|
|
"-Wno-weak-vtables",
|
|
|
|
]
|
|
|
|
|
2020-06-01 20:50:19 +00:00
|
|
|
# Turn back on after -Wno-conversion.
|
|
|
|
# This only affects public headers... see :warnings_except_public_headers.
|
|
|
|
cflags += [ "-Wsign-conversion" ]
|
|
|
|
|
2017-12-04 19:01:30 +00:00
|
|
|
# We are unlikely to want to fix these.
|
|
|
|
cflags += [
|
|
|
|
"-Wno-covered-switch-default",
|
|
|
|
"-Wno-deprecated",
|
|
|
|
"-Wno-missing-noreturn",
|
|
|
|
"-Wno-old-style-cast",
|
|
|
|
"-Wno-padded",
|
2017-12-04 20:31:21 +00:00
|
|
|
"-Wno-newline-eof",
|
2020-07-22 23:28:35 +00:00
|
|
|
"-Wno-psabi",
|
2017-12-04 19:01:30 +00:00
|
|
|
]
|
|
|
|
cflags_cc += [
|
|
|
|
"-Wno-c++98-compat",
|
|
|
|
"-Wno-c++98-compat-pedantic",
|
|
|
|
"-Wno-undefined-func-template",
|
|
|
|
]
|
|
|
|
cflags_objc += [
|
|
|
|
"-Wno-direct-ivar-access",
|
|
|
|
"-Wno-objc-interface-ivars",
|
|
|
|
]
|
|
|
|
cflags_objcc += [
|
|
|
|
"-Wno-direct-ivar-access",
|
|
|
|
"-Wno-objcc-interface-ivars",
|
|
|
|
]
|
2020-03-23 21:22:24 +00:00
|
|
|
|
|
|
|
# Wno-deprecated turns off the whole group, but also has its own warnings like
|
|
|
|
# out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated [-Werror,-Wdeprecated]
|
|
|
|
# but we would like others. Created from clang/include/clang/Basic/DiagnosticGroups.td
|
|
|
|
cflags += [
|
|
|
|
"-Wdeprecated-anon-enum-enum-conversion",
|
|
|
|
"-Wdeprecated-array-compare",
|
|
|
|
"-Wdeprecated-attributes",
|
|
|
|
"-Wdeprecated-comma-subscript",
|
|
|
|
"-Wdeprecated-copy",
|
2020-03-27 15:28:03 +00:00
|
|
|
|
2020-03-31 22:31:46 +00:00
|
|
|
#"-Wdeprecated-copy-dtor",
|
2020-03-23 21:22:24 +00:00
|
|
|
#"-Wdeprecated-declarations",
|
|
|
|
"-Wdeprecated-dynamic-exception-spec",
|
|
|
|
"-Wdeprecated-enum-compare",
|
|
|
|
"-Wdeprecated-enum-compare-conditional",
|
|
|
|
"-Wdeprecated-enum-enum-conversion",
|
|
|
|
"-Wdeprecated-enum-float-conversion",
|
|
|
|
"-Wdeprecated-increment-bool",
|
|
|
|
"-Wdeprecated-register",
|
|
|
|
"-Wdeprecated-this-capture",
|
|
|
|
"-Wdeprecated-volatile",
|
|
|
|
"-Wdeprecated-writable-str",
|
|
|
|
]
|
2016-10-13 03:58:06 +00:00
|
|
|
}
|
|
|
|
}
|
2016-11-16 17:13:44 +00:00
|
|
|
config("warnings_except_public_headers") {
|
2017-12-04 19:01:30 +00:00
|
|
|
if (!is_win || is_clang) {
|
2020-06-01 20:50:19 +00:00
|
|
|
cflags = [
|
|
|
|
"-Wno-sign-conversion",
|
|
|
|
"-Wno-unused-parameter",
|
|
|
|
]
|
2016-11-16 17:13:44 +00:00
|
|
|
}
|
|
|
|
}
|
2016-10-13 03:58:06 +00:00
|
|
|
|
2016-10-04 21:09:13 +00:00
|
|
|
config("extra_flags") {
|
2017-03-28 19:45:41 +00:00
|
|
|
asmflags = extra_asmflags
|
2016-10-04 21:09:13 +00:00
|
|
|
cflags = extra_cflags
|
|
|
|
cflags_c = extra_cflags_c
|
|
|
|
cflags_cc = extra_cflags_cc
|
|
|
|
ldflags = extra_ldflags
|
|
|
|
}
|
|
|
|
|
2016-09-16 21:44:18 +00:00
|
|
|
config("debug_symbols") {
|
|
|
|
# It's annoying to wait for full debug symbols to push over
|
|
|
|
# to Android devices. -gline-tables-only is a lot slimmer.
|
|
|
|
if (is_android) {
|
2017-08-30 14:23:01 +00:00
|
|
|
cflags = [
|
|
|
|
"-gline-tables-only",
|
|
|
|
"-funwind-tables", # Helps make in-process backtraces fuller.
|
|
|
|
]
|
2016-10-12 20:25:27 +00:00
|
|
|
} else if (is_win) {
|
2017-12-15 12:34:27 +00:00
|
|
|
cflags = [ "/Z7" ]
|
2018-12-12 21:32:35 +00:00
|
|
|
if (is_clang) {
|
2019-02-07 18:05:06 +00:00
|
|
|
cflags += [ "-gcodeview-ghash" ]
|
2018-12-23 15:25:44 +00:00
|
|
|
ldflags = [ "/DEBUG:GHASH" ]
|
2018-12-12 21:32:35 +00:00
|
|
|
} else {
|
2018-12-10 13:48:03 +00:00
|
|
|
ldflags = [ "/DEBUG:FASTLINK" ]
|
2018-09-13 19:46:02 +00:00
|
|
|
}
|
2016-10-12 20:25:27 +00:00
|
|
|
} else {
|
2016-09-16 21:44:18 +00:00
|
|
|
cflags = [ "-g" ]
|
|
|
|
}
|
|
|
|
}
|
2016-09-16 20:29:57 +00:00
|
|
|
|
2016-09-16 21:44:18 +00:00
|
|
|
config("no_rtti") {
|
|
|
|
if (sanitize != "ASAN") { # -fsanitize=vptr requires RTTI
|
2016-10-12 20:25:27 +00:00
|
|
|
if (is_win) {
|
|
|
|
cflags_cc = [ "/GR-" ]
|
|
|
|
} else {
|
2016-09-16 21:44:18 +00:00
|
|
|
cflags_cc = [ "-fno-rtti" ]
|
2016-09-08 15:39:34 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-16 21:44:18 +00:00
|
|
|
}
|
2016-07-21 19:25:45 +00:00
|
|
|
|
2018-09-19 17:44:43 +00:00
|
|
|
config("optimize") {
|
2016-10-12 20:25:27 +00:00
|
|
|
if (is_win) {
|
2016-10-20 17:34:18 +00:00
|
|
|
cflags = [
|
|
|
|
"/O2",
|
|
|
|
"/Zc:inline",
|
|
|
|
]
|
2016-10-20 17:52:38 +00:00
|
|
|
ldflags = [
|
|
|
|
"/OPT:ICF",
|
|
|
|
"/OPT:REF",
|
|
|
|
]
|
2016-10-12 20:25:27 +00:00
|
|
|
} else {
|
2019-06-20 15:08:55 +00:00
|
|
|
cflags = [ "-O3" ]
|
2017-02-10 12:59:39 +00:00
|
|
|
if (is_mac || is_ios) {
|
|
|
|
ldflags = [ "-dead_strip" ]
|
|
|
|
} else {
|
2019-06-20 15:08:55 +00:00
|
|
|
cflags += [
|
|
|
|
"-fdata-sections",
|
|
|
|
"-ffunction-sections",
|
|
|
|
]
|
2017-02-10 12:59:39 +00:00
|
|
|
ldflags = [ "-Wl,--gc-sections" ]
|
|
|
|
}
|
2017-09-21 17:45:16 +00:00
|
|
|
if (target_cpu == "wasm") {
|
|
|
|
# The compiler asks us to add an optimization flag to both cflags
|
|
|
|
# and ldflags to cut down on the local variables,
|
|
|
|
# for performance reasons.
|
|
|
|
# The "linking" step is the conversion to javascript.
|
|
|
|
ldflags += [ "-O3" ]
|
|
|
|
}
|
2016-09-16 20:29:57 +00:00
|
|
|
}
|
2018-09-19 17:44:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
config("NDEBUG") {
|
2016-09-16 21:44:18 +00:00
|
|
|
defines = [ "NDEBUG" ]
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
config("executable") {
|
2016-12-06 15:46:02 +00:00
|
|
|
if (is_android) {
|
2017-08-30 14:23:01 +00:00
|
|
|
ldflags = [
|
|
|
|
"-pie",
|
|
|
|
"-rdynamic",
|
|
|
|
]
|
2016-12-06 15:46:02 +00:00
|
|
|
} else if (is_mac) {
|
2016-07-21 19:25:45 +00:00
|
|
|
ldflags = [ "-Wl,-rpath,@loader_path/." ]
|
|
|
|
} else if (is_linux) {
|
2016-09-15 17:44:15 +00:00
|
|
|
ldflags = [
|
|
|
|
"-rdynamic",
|
|
|
|
"-Wl,-rpath,\$ORIGIN",
|
|
|
|
]
|
2016-11-06 16:54:19 +00:00
|
|
|
} else if (is_win) {
|
|
|
|
ldflags = [
|
|
|
|
"/SUBSYSTEM:CONSOLE", # Quiet "no subsystem specified; CONSOLE assumed".
|
2020-04-01 18:47:34 +00:00
|
|
|
"/INCREMENTAL:NO", # Quiet warnings about failing to incrementally link
|
|
|
|
# by never trying to.
|
2016-11-06 16:54:19 +00:00
|
|
|
]
|
2016-07-21 19:25:45 +00:00
|
|
|
}
|
|
|
|
}
|