1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/compiler/compiler.gni")
import("nasm_sources.gni")
configs_to_delete = [ "//build/config/compiler:chromium_code" ]
should_remove_default_deps_for_performance = false
# We'd like to disable sanitizers in all cases, but this is not possible with
# MSAN due to its linkage with instrumented libraries. https://crbug.com/928357
if (!is_msan) {
configs_to_delete += [
# Don't enable sanitizers for build tools. They slow down the overall build.
"//build/config/sanitizers:default_sanitizer_flags",
]
# Without no_default_deps, an implicit dependency on libc++ is added.
# libc++ may have been built referencing the debug CRT, but since we're
# explicitly using the release CRT, this would result in undefined symbol
# errors when linking, so we need to remove the implicit libc++ dependency.
# This is also needed to remove some configurations which make nasm's
# performance slow.
should_remove_default_deps_for_performance = true
}
configs_to_add = [ "//build/config/compiler:no_chromium_code" ]
if (is_debug) {
configs_to_delete += [
# Build with full optimizations even on debug configurations, because some
# yasm build steps (highbd_sad4d_sse2.asm) can take ~33 seconds or more in
# debug component builds on Windows. Enabling compiler optimizations saves
# ~5 seconds.
"//build/config/compiler:default_optimization",
# Don't define _DEBUG. Modest savings, but good for consistency.
"//build/config:debug",
]
configs_to_add += [
"//build/config:release",
"//build/config/compiler:optimize_max",
]
if (is_win) {
# This switches to using the release CRT. For yasm debug component builds
# of highbd_sad4d_sse2.asm on Windows this saved about 15 s.
configs_to_delete += [ "//build/config/win:default_crt" ]
configs_to_add += [ "//build/config/win:release_crt" ]
}
}
config("nasm_config") {
include_dirs = [
".",
"asm",
"disasm",
"include",
"output",
"x86",
]
defines = [ "HAVE_CONFIG_H" ]
if (is_clang) {
cflags = [
# The inline functions in NASM's headers flag this.
"-Wno-unused-function",
# NASM writes nasm_assert(!"some string literal").
"-Wno-string-conversion",
# NASM sometimes redefines macros from its config.h.
"-Wno-macro-redefined",
# NASM sometimes compares enums to unsigned integers.
"-Wno-sign-compare",
# NASM sometimes return null from nonnull.
"-Wno-nonnull",
# NASM sometimes uses uninitialized values.
"-Wno-uninitialized",
# NASM sometimes set variables but doesn't use them.
"-Wno-unused-but-set-variable",
# NASM undefines __STRICT_ANSI__
"-Wno-builtin-macro-redefined",
]
} else if (is_win) {
# Please note that's a slightly different set of warnings.
cflags = [
# NASM sometimes redefines macros from its config.h.
"/wd4005", # macro redefinition
# NASM sometimes compares enums to unsigned integers.
"/wd4018", # sign compare
# char VS const char mismatch.
"/wd4028", # formal parameter 1 different from declaration.
# NASM comment: Uninitialized -> all zero by C spec
# Or sometimes one const struct is forward declared for no reason.
"/wd4132", # const object should be initialized
# NASM uses "(-x) & 0xFF" pattern to negate byte.
"/wd4146", # unary minus operator applied to unsigned type
]
}
}
if (current_toolchain == host_toolchain) {
executable("nasm") {
sources = nasmlib_sources + nasm_sources
sources += [
"config/config-linux.h",
"config/config-mac.h",
"config/config.h",
"config/msvc.h",
"config/unconfig.h",
]
configs -= configs_to_delete
configs += configs_to_add
configs += [ ":nasm_config" ]
no_default_deps = should_remove_default_deps_for_performance
}
}
|