blob: e31bcec53624680534361655b198f293f88c2a14 [file] [log] [blame]
Dale Curtis9596cc02018-10-31 14:25:55 -07001# Copyright 2018 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("//build/config/compiler/compiler.gni")
6import("nasm_sources.gni")
7
Dale Curtis4fa54ca2020-04-14 12:55:13 -07008configs_to_delete = [ "//build/config/compiler:chromium_code" ]
Dale Curtisc74336e2020-04-13 15:37:55 -07009
Dale Curtis4fa54ca2020-04-14 12:55:13 -070010# We'd like to disable sanitizers in all cases, but this is not possible with
11# MSAN due to its linkage with instrumented libraries. https://crbug.com/928357
12if (!is_msan) {
13 configs_to_delete += [
14 # Don't enable sanitizers for build tools. They slow down the overall build.
15 "//build/config/sanitizers:default_sanitizer_flags",
16 ]
17}
Dale Curtisc74336e2020-04-13 15:37:55 -070018
Takuto Ikutaae8e4ca2019-02-19 13:59:42 +090019configs_to_add = [ "//build/config/compiler:no_chromium_code" ]
Dale Curtis9596cc02018-10-31 14:25:55 -070020if (is_debug) {
21 configs_to_delete += [
22 # Build with full optimizations even on debug configurations, because some
23 # yasm build steps (highbd_sad4d_sse2.asm) can take ~33 seconds or more in
24 # debug component builds on Windows. Enabling compiler optimizations saves
25 # ~5 seconds.
26 "//build/config/compiler:default_optimization",
27
28 # Don't define _DEBUG. Modest savings, but good for consistency.
29 "//build/config:debug",
30 ]
31
32 configs_to_add += [
33 "//build/config:release",
34 "//build/config/compiler:optimize_max",
35 ]
36 if (is_win) {
37 # This switches to using the release CRT. For yasm debug component builds
38 # of highbd_sad4d_sse2.asm on Windows this saved about 15 s.
39 configs_to_delete += [ "//build/config/win:default_crt" ]
40 configs_to_add += [ "//build/config/win:release_crt" ]
Tom Anderson076332e2019-03-13 15:11:03 -070041
42 # Without no_default_deps, an implicit dependency on libc++ is added.
43 # libc++ may have been built referencing the debug CRT, but since we're
44 # explicitly using the release CRT, this would result in undefined symbol
45 # errors when linking, so we need to remove the implicit libc++ dependency.
46 no_default_deps = true
Dale Curtis9596cc02018-10-31 14:25:55 -070047 }
48}
49
50config("nasm_config") {
51 include_dirs = [
52 ".",
53 "asm",
Dale Curtis9596cc02018-10-31 14:25:55 -070054 "disasm",
55 "include",
56 "output",
57 "x86",
58 ]
59
Dale Curtis9596cc02018-10-31 14:25:55 -070060 defines = [ "HAVE_CONFIG_H" ]
61
62 if (is_clang) {
63 cflags = [
64 # The inline functions in NASM's headers flag this.
65 "-Wno-unused-function",
66
67 # NASM writes nasm_assert(!"some string literal").
68 "-Wno-string-conversion",
69
70 # NASM sometimes redefines macros from its config.h.
71 "-Wno-macro-redefined",
Dale Curtis20920a82018-11-01 17:26:45 -070072
73 # NASM sometimes compares enums to unsigned integers.
74 "-Wno-sign-compare",
Dale Curtise2938142020-06-29 15:29:48 -070075
76 # NASM sometimes return null from nonnull.
77 "-Wno-nonnull",
78
79 # NASM sometimes uses uninitialized values.
80 "-Wno-uninitialized",
Dale Curtis9596cc02018-10-31 14:25:55 -070081 ]
Yves Gereye701d162018-11-09 18:44:47 +010082 } else if (is_win) {
83 # Please note that's a slightly different set of warnings.
84 cflags = [
85 # NASM sometimes redefines macros from its config.h.
86 "/wd4005", # macro redefinition
87
88 # NASM sometimes compares enums to unsigned integers.
89 "/wd4018", # sign compare
90
Yves Gereya0a69512018-11-09 19:35:11 +010091 # char VS const char mismatch.
92 "/wd4028", # formal parameter 1 different from declaration.
93
Yves Gereye701d162018-11-09 18:44:47 +010094 # NASM comment: Uninitialized -> all zero by C spec
95 # Or sometimes one const struct is forward declared for no reason.
96 "/wd4132", # const object should be initialized
97
98 # NASM uses "(-x) & 0xFF" pattern to negate byte.
99 "/wd4146", # unary minus operator applied to unsigned type
100 ]
Dale Curtis9596cc02018-10-31 14:25:55 -0700101 }
102}
103
104if (current_toolchain == host_toolchain) {
105 executable("nasm") {
106 sources = nasmlib_sources + nasm_sources
Dale Curtis3dacc5e2018-11-01 10:48:41 -0700107 sources += [
Dale Curtis3dacc5e2018-11-01 10:48:41 -0700108 "config/config-linux.h",
Takuto Ikutaae8e4ca2019-02-19 13:59:42 +0900109 "config/config-mac.h",
110 "config/config.h",
Takuto Ikuta313e2e82019-02-13 13:52:41 +0900111 "config/msvc.h",
Dale Curtis3dacc5e2018-11-01 10:48:41 -0700112 ]
Dale Curtis9596cc02018-10-31 14:25:55 -0700113
114 configs -= configs_to_delete
115 configs += configs_to_add
116 configs += [ ":nasm_config" ]
117
Dale Curtis9596cc02018-10-31 14:25:55 -0700118 deps = [
119 # Default manifest on Windows (a no-op elsewhere).
120 "//build/win:default_exe_manifest",
121 ]
122 }
123}