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 | |
Nicolas Capens | d51e216 | 2017-06-05 13:59:55 -0400 | [diff] [blame] | 15 | import("//build/config/compiler/compiler.gni") |
| 16 | |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 17 | config("swiftshader_config") { |
Alexis Hetu | 0def102 | 2017-08-16 17:15:48 -0400 | [diff] [blame] | 18 | defines = [] |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 19 | |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 20 | if (is_win) { |
| 21 | cflags = [ |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 22 | "/GS", # Detects some buffer overruns |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 23 | "/Zc:wchar_t", |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 24 | "/EHsc", |
| 25 | "/nologo", |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 26 | "/Gd", # Default calling convention |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 27 | ] |
| 28 | |
| 29 | defines += [ |
| 30 | "_CRT_SECURE_NO_DEPRECATE", |
| 31 | "NOMINMAX", |
| 32 | "_WINDLL", |
Nicolas Capens | 506cc5e | 2017-07-24 11:30:55 -0400 | [diff] [blame] | 33 | "NO_SANITIZE_FUNCTION=", |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 34 | ] |
Alexis Hetu | c55dd84 | 2017-08-08 08:31:13 -0400 | [diff] [blame] | 35 | |
Robert Liao | e8d42ae | 2017-08-14 10:51:58 -0700 | [diff] [blame] | 36 | if (!is_debug) { |
Alexis Hetu | c55dd84 | 2017-08-08 08:31:13 -0400 | [diff] [blame] | 37 | defines += [ "ANGLE_DISABLE_TRACE" ] |
| 38 | } |
Alexis Hetu | 03b67af | 2016-08-31 17:25:40 -0400 | [diff] [blame] | 39 | } else { |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 40 | cflags = [ |
| 41 | "-std=c++11", |
Alexis Hetu | 2c0546d | 2017-05-24 11:16:26 -0400 | [diff] [blame] | 42 | "-fno-exceptions", |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 43 | "-fno-operator-names", |
Alexis Hetu | 2ddef88 | 2017-03-14 15:11:15 -0400 | [diff] [blame] | 44 | ] |
| 45 | |
| 46 | defines += [ |
| 47 | "__STDC_CONSTANT_MACROS", |
| 48 | "__STDC_LIMIT_MACROS", |
Nicolas Capens | 506cc5e | 2017-07-24 11:30:55 -0400 | [diff] [blame] | 49 | "NO_SANITIZE_FUNCTION=__attribute__((no_sanitize(\"function\")))", |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 50 | ] |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 51 | |
Alexis Hetu | c55dd84 | 2017-08-08 08:31:13 -0400 | [diff] [blame] | 52 | if (is_debug) { |
| 53 | cflags += [ |
| 54 | "-g", |
| 55 | "-g3", |
| 56 | ] |
| 57 | } else { # Release |
| 58 | # All Release builds use function/data sections to make the shared libraries smaller |
| 59 | cflags += [ |
| 60 | "-ffunction-sections", |
| 61 | "-fdata-sections", |
| 62 | "-fomit-frame-pointer", |
| 63 | "-Os", |
| 64 | ] |
| 65 | |
| 66 | defines += [ |
| 67 | "ANGLE_DISABLE_TRACE", |
| 68 | "NDEBUG", |
| 69 | ] |
| 70 | } |
| 71 | |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 72 | if (target_cpu == "x64") { # 64 bit version |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 73 | cflags += [ |
| 74 | "-m64", |
| 75 | "-fPIC", |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 76 | "-march=core2", |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 77 | ] |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 78 | } else { # 32 bit version |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 79 | cflags += [ |
| 80 | "-m32", |
| 81 | "-msse2", |
| 82 | "-march=i686", |
| 83 | ] |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 84 | } |
Alexis Hetu | a11d03e | 2017-01-27 11:38:59 -0500 | [diff] [blame] | 85 | |
Alexis Hetu | b1031c8 | 2017-01-30 13:46:08 -0500 | [diff] [blame] | 86 | if (is_linux) { |
| 87 | ldflags = [ |
| 88 | "-Wl,--hash-style=both", |
| 89 | "-Wl,--gc-sections", |
| 90 | ] |
Alexis Hetu | 9441b07 | 2017-08-02 08:40:37 -0400 | [diff] [blame] | 91 | |
Nicolas Capens | 0f7d427 | 2017-06-05 13:24:09 -0400 | [diff] [blame] | 92 | # A bug in the gold linker prevents using ICF on 32-bit (crbug.com/729532) |
| 93 | if (use_gold && target_cpu == "x86") { |
Alexis Hetu | 9441b07 | 2017-08-02 08:40:37 -0400 | [diff] [blame] | 94 | ldflags += [ "-Wl,--icf=none" ] |
Nicolas Capens | 0f7d427 | 2017-06-05 13:24:09 -0400 | [diff] [blame] | 95 | } |
Alexis Hetu | b1031c8 | 2017-01-30 13:46:08 -0500 | [diff] [blame] | 96 | } |
Alexis Hetu | 91f10e3 | 2016-06-07 19:53:42 -0400 | [diff] [blame] | 97 | } |
| 98 | } |
| 99 | |
Alexis Hetu | 68f564d | 2016-07-06 17:43:22 -0400 | [diff] [blame] | 100 | group("swiftshader") { |
Alexis Hetu | 996663b | 2016-09-21 13:47:42 -0400 | [diff] [blame] | 101 | data_deps = [ |
| 102 | "src/OpenGL/libGLESv2:swiftshader_libGLESv2", |
| 103 | "src/OpenGL/libEGL:swiftshader_libEGL", |
| 104 | ] |
Alexis Hetu | a6e99c0 | 2016-11-16 13:53:57 -0500 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | group("swiftshader_tests") { |
| 108 | testonly = true |
| 109 | |
| 110 | data_deps = [ |
| 111 | "tests/unittests:swiftshader_unittests", |
| 112 | ] |
Alexis Hetu | d6d10f9 | 2016-11-22 13:47:04 -0500 | [diff] [blame] | 113 | } |