Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 1 | # Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
Peter Collingbourne | 8e67eb9 | 2018-01-24 18:42:02 -0800 | [diff] [blame] | 15 | import("//build/config/c++/c++.gni") |
Nicolas Capens | d51e216 | 2017-06-05 13:59:55 -0400 | [diff] [blame] | 16 | import("//build/config/compiler/compiler.gni") |
| 17 | |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 18 | config("swiftshader_config") { |
Alexis Hetu | 0def102 | 2017-08-16 17:15:48 -0400 | [diff] [blame] | 19 | defines = [] |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 20 | |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 21 | if (is_win) { |
| 22 | cflags = [ |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 23 | "/GS", # Detects some buffer overruns |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 24 | "/Zc:wchar_t", |
Reid Kleckner | d19db3d | 2017-11-29 10:45:53 -0800 | [diff] [blame] | 25 | "/EHs-c-", # Disable C++ exceptions |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 26 | "/nologo", |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 27 | "/Gd", # Default calling convention |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 28 | ] |
| 29 | |
Peter Collingbourne | 8e67eb9 | 2018-01-24 18:42:02 -0800 | [diff] [blame] | 30 | if (!use_custom_libcxx) { |
| 31 | # Disable EH usage in STL headers. |
| 32 | # libc++ uses a predefined macro to control whether to use exceptions, so |
| 33 | # defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also |
| 34 | # breaks libc++ because it depends on MSVC headers that only provide |
| 35 | # certain declarations if _HAS_EXCEPTIONS is 1. |
| 36 | defines += [ |
| 37 | "_HAS_EXCEPTIONS=0", |
| 38 | ] |
| 39 | } |
| 40 | |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 41 | defines += [ |
| 42 | "_CRT_SECURE_NO_DEPRECATE", |
| 43 | "NOMINMAX", |
| 44 | "_WINDLL", |
Nicolas Capens | 506cc5e | 2017-07-24 11:30:55 -0400 | [diff] [blame] | 45 | "NO_SANITIZE_FUNCTION=", |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 46 | ] |
Alexis Hetu | c55dd84 | 2017-08-08 08:31:13 -0400 | [diff] [blame] | 47 | |
Robert Liao | e8d42ae | 2017-08-14 10:51:58 -0700 | [diff] [blame] | 48 | if (!is_debug) { |
Alexis Hetu | c55dd84 | 2017-08-08 08:31:13 -0400 | [diff] [blame] | 49 | defines += [ "ANGLE_DISABLE_TRACE" ] |
| 50 | } |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 51 | } else { |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 52 | cflags = [ |
| 53 | "-std=c++11", |
Alexis Hetu | 2c0546d | 2017-05-24 11:16:26 -0400 | [diff] [blame] | 54 | "-fno-exceptions", |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 55 | "-fno-operator-names", |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 56 | ] |
| 57 | |
| 58 | defines += [ |
| 59 | "__STDC_CONSTANT_MACROS", |
| 60 | "__STDC_LIMIT_MACROS", |
Nicolas Capens | 506cc5e | 2017-07-24 11:30:55 -0400 | [diff] [blame] | 61 | "NO_SANITIZE_FUNCTION=__attribute__((no_sanitize(\"function\")))", |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 62 | ] |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 63 | |
Alexis Hetu | c55dd84 | 2017-08-08 08:31:13 -0400 | [diff] [blame] | 64 | if (is_debug) { |
| 65 | cflags += [ |
| 66 | "-g", |
| 67 | "-g3", |
| 68 | ] |
| 69 | } else { # Release |
| 70 | # All Release builds use function/data sections to make the shared libraries smaller |
| 71 | cflags += [ |
| 72 | "-ffunction-sections", |
| 73 | "-fdata-sections", |
| 74 | "-fomit-frame-pointer", |
| 75 | "-Os", |
| 76 | ] |
| 77 | |
| 78 | defines += [ |
| 79 | "ANGLE_DISABLE_TRACE", |
| 80 | "NDEBUG", |
| 81 | ] |
| 82 | } |
| 83 | |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 84 | if (target_cpu == "x64") { # 64 bit version |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 85 | cflags += [ |
| 86 | "-m64", |
| 87 | "-fPIC", |
Nicolas Capens | 0424edc | 2018-01-03 14:06:30 -0500 | [diff] [blame] | 88 | "-march=x86-64", |
| 89 | "-mtune=generic", |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 90 | ] |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 91 | } else { # 32 bit version |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 92 | cflags += [ |
| 93 | "-m32", |
| 94 | "-msse2", |
Nicolas Capens | 0424edc | 2018-01-03 14:06:30 -0500 | [diff] [blame] | 95 | "-mfpmath=sse", |
| 96 | "-march=pentium4", |
| 97 | "-mtune=generic", |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 98 | ] |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 99 | } |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 100 | |
Alexis Hetu | b1031c8 | 2017-01-30 13:46:08 -0500 | [diff] [blame] | 101 | if (is_linux) { |
| 102 | ldflags = [ |
| 103 | "-Wl,--hash-style=both", |
| 104 | "-Wl,--gc-sections", |
| 105 | ] |
Alexis Hetu | 9441b07 | 2017-08-02 08:40:37 -0400 | [diff] [blame] | 106 | |
Nicolas Capens | 0f7d427 | 2017-06-05 13:24:09 -0400 | [diff] [blame] | 107 | # A bug in the gold linker prevents using ICF on 32-bit (crbug.com/729532) |
| 108 | if (use_gold && target_cpu == "x86") { |
Alexis Hetu | 9441b07 | 2017-08-02 08:40:37 -0400 | [diff] [blame] | 109 | ldflags += [ "-Wl,--icf=none" ] |
Nicolas Capens | 0f7d427 | 2017-06-05 13:24:09 -0400 | [diff] [blame] | 110 | } |
Alexis Hetu | b1031c8 | 2017-01-30 13:46:08 -0500 | [diff] [blame] | 111 | } |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 112 | } |
| 113 | } |
| 114 | |
Corentin Wallez | 57eb063 | 2017-10-24 15:17:18 -0400 | [diff] [blame] | 115 | source_set("vertex_routine_fuzzer") { |
| 116 | sources = [ |
| 117 | "tests/fuzzers/VertexRoutineFuzzer.cpp" |
| 118 | ] |
Corentin Wallez | 6e27fea | 2017-10-27 13:40:18 -0400 | [diff] [blame] | 119 | if (is_win) { |
| 120 | cflags = [ |
| 121 | "/wd4201", # nameless struct/union |
| 122 | "/wd4065", # switch statement contains 'default' but no 'case' labels |
| 123 | "/wd5030", # attribute is not recognized |
| 124 | ] |
| 125 | } |
Corentin Wallez | 57eb063 | 2017-10-24 15:17:18 -0400 | [diff] [blame] | 126 | include_dirs = [ |
| 127 | "src/", |
| 128 | ] |
| 129 | deps = [ |
| 130 | "src/OpenGL/libGLESv2:swiftshader_libGLESv2_static", |
| 131 | ] |
| 132 | } |
| 133 | |
Alexis Hetu | 68f564d | 2016-07-06 17:43:22 -0400 | [diff] [blame] | 134 | group("swiftshader") { |
Alexis Hetu | 996663b | 2016-09-21 13:47:42 -0400 | [diff] [blame] | 135 | data_deps = [ |
| 136 | "src/OpenGL/libGLESv2:swiftshader_libGLESv2", |
| 137 | "src/OpenGL/libEGL:swiftshader_libEGL", |
| 138 | ] |
Alexis Hetu | a6e99c0 | 2016-11-16 13:53:57 -0500 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | group("swiftshader_tests") { |
| 142 | testonly = true |
| 143 | |
| 144 | data_deps = [ |
| 145 | "tests/unittests:swiftshader_unittests", |
| 146 | ] |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 147 | } |