Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 1 | # 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 | |
| 5 | import("//build/config/compiler/compiler.gni") |
| 6 | import("nasm_sources.gni") |
| 7 | |
Dale Curtis | 4fa54ca | 2020-04-14 12:55:13 -0700 | [diff] [blame] | 8 | configs_to_delete = [ "//build/config/compiler:chromium_code" ] |
Dale Curtis | c74336e | 2020-04-13 15:37:55 -0700 | [diff] [blame] | 9 | |
Dale Curtis | 4fa54ca | 2020-04-14 12:55:13 -0700 | [diff] [blame] | 10 | # 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 |
| 12 | if (!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 Curtis | c74336e | 2020-04-13 15:37:55 -0700 | [diff] [blame] | 18 | |
Takuto Ikuta | ae8e4ca | 2019-02-19 13:59:42 +0900 | [diff] [blame] | 19 | configs_to_add = [ "//build/config/compiler:no_chromium_code" ] |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 20 | if (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 Anderson | 076332e | 2019-03-13 15:11:03 -0700 | [diff] [blame] | 41 | |
| 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 Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 47 | } |
| 48 | } |
| 49 | |
| 50 | config("nasm_config") { |
| 51 | include_dirs = [ |
| 52 | ".", |
| 53 | "asm", |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 54 | "disasm", |
| 55 | "include", |
| 56 | "output", |
| 57 | "x86", |
| 58 | ] |
| 59 | |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 60 | 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 Curtis | 20920a8 | 2018-11-01 17:26:45 -0700 | [diff] [blame] | 72 | |
| 73 | # NASM sometimes compares enums to unsigned integers. |
| 74 | "-Wno-sign-compare", |
Dale Curtis | e293814 | 2020-06-29 15:29:48 -0700 | [diff] [blame] | 75 | |
| 76 | # NASM sometimes return null from nonnull. |
| 77 | "-Wno-nonnull", |
| 78 | |
| 79 | # NASM sometimes uses uninitialized values. |
| 80 | "-Wno-uninitialized", |
Alan Screen | 2fda35e | 2021-06-14 13:46:57 -0700 | [diff] [blame^] | 81 | |
| 82 | # NASM sometimes set variables but doesn't use them. |
| 83 | "-Wno-unused-but-set-variable", |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 84 | ] |
Yves Gerey | e701d16 | 2018-11-09 18:44:47 +0100 | [diff] [blame] | 85 | } else if (is_win) { |
| 86 | # Please note that's a slightly different set of warnings. |
| 87 | cflags = [ |
| 88 | # NASM sometimes redefines macros from its config.h. |
| 89 | "/wd4005", # macro redefinition |
| 90 | |
| 91 | # NASM sometimes compares enums to unsigned integers. |
| 92 | "/wd4018", # sign compare |
| 93 | |
Yves Gerey | a0a6951 | 2018-11-09 19:35:11 +0100 | [diff] [blame] | 94 | # char VS const char mismatch. |
| 95 | "/wd4028", # formal parameter 1 different from declaration. |
| 96 | |
Yves Gerey | e701d16 | 2018-11-09 18:44:47 +0100 | [diff] [blame] | 97 | # NASM comment: Uninitialized -> all zero by C spec |
| 98 | # Or sometimes one const struct is forward declared for no reason. |
| 99 | "/wd4132", # const object should be initialized |
| 100 | |
| 101 | # NASM uses "(-x) & 0xFF" pattern to negate byte. |
| 102 | "/wd4146", # unary minus operator applied to unsigned type |
| 103 | ] |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 104 | } |
| 105 | } |
| 106 | |
| 107 | if (current_toolchain == host_toolchain) { |
| 108 | executable("nasm") { |
| 109 | sources = nasmlib_sources + nasm_sources |
Dale Curtis | 3dacc5e | 2018-11-01 10:48:41 -0700 | [diff] [blame] | 110 | sources += [ |
Dale Curtis | 3dacc5e | 2018-11-01 10:48:41 -0700 | [diff] [blame] | 111 | "config/config-linux.h", |
Takuto Ikuta | ae8e4ca | 2019-02-19 13:59:42 +0900 | [diff] [blame] | 112 | "config/config-mac.h", |
| 113 | "config/config.h", |
Dale Curtis | 19f3fad | 2020-07-15 11:22:01 -0700 | [diff] [blame] | 114 | "config/msvc.h", |
| 115 | "config/unconfig.h", |
Dale Curtis | 3dacc5e | 2018-11-01 10:48:41 -0700 | [diff] [blame] | 116 | ] |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 117 | |
| 118 | configs -= configs_to_delete |
| 119 | configs += configs_to_add |
| 120 | configs += [ ":nasm_config" ] |
| 121 | |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 122 | deps = [ |
| 123 | # Default manifest on Windows (a no-op elsewhere). |
| 124 | "//build/win:default_exe_manifest", |
| 125 | ] |
| 126 | } |
| 127 | } |