blob: 1a61c2846116e6ce4f4c46aa04412478aefcca86 [file] [log] [blame]
mtklein7fbfbbe2016-07-21 12:25:45 -07001# Copyright 2016 Google Inc.
2#
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6declare_args() {
Kevin Lubick2677a9a2017-03-28 15:45:41 -04007 extra_asmflags = []
Mike Klein121563e2016-10-04 17:09:13 -04008 extra_cflags = []
9 extra_cflags_c = []
10 extra_cflags_cc = []
11 extra_ldflags = []
mtkleincab0bb72016-08-26 13:43:19 -070012
Herb Derby76073c12016-12-08 19:00:40 -050013 malloc = ""
mtklein7fbfbbe2016-07-21 12:25:45 -070014}
Mike Klein82364ba2016-10-24 16:49:15 -040015
Mike Klein7d302882016-11-03 14:06:31 -040016if (is_ios) {
Matthew Leibowitz3150ec62017-03-14 16:22:32 -040017 if (is_tvos) {
18 sdk = "appletvos"
19 if (target_cpu == "x86" || target_cpu == "x64") {
20 sdk = "appletvsimulator"
21 }
22 } else {
23 sdk = "iphoneos"
24 if (target_cpu == "x86" || target_cpu == "x64") {
25 sdk = "iphonesimulator"
26 }
Mike Klein7a5e0f32017-03-13 09:25:33 -070027 }
28 ios_sysroot = exec_script("find_ios_sysroot.py", [ sdk ], "trim string")
Mike Klein7d302882016-11-03 14:06:31 -040029}
30
mtkleinb9be9792016-09-16 14:44:18 -070031config("default") {
32 asmflags = []
33 cflags = []
34 cflags_c = []
35 cflags_cc = []
36 defines = []
37 ldflags = []
Herb Derby76073c12016-12-08 19:00:40 -050038 libs = []
mtkleinb9be9792016-09-16 14:44:18 -070039
40 if (is_win) {
41 cflags += [
42 "/FS", # Preserve previous PDB behavior.
herbb6318bf2016-09-16 13:29:57 -070043 "/bigobj", # Some of our files are bigger than the regular limits.
Mike Kleinc7165c22016-10-12 23:58:06 -040044 "/WX", # Treat warnings as errors.
Ben Wagnere6b274e2017-01-03 17:09:59 -050045 "/utf-8", # Set Source and Executable character sets to UTF-8.
herbb6318bf2016-09-16 13:29:57 -070046 ]
Mike Kleina91ec582017-07-31 16:35:17 -040047 if (is_clang) {
48 cflags += [ "-fms-compatibility-version=19" ] # 2015
49 }
mtkleinb9be9792016-09-16 14:44:18 -070050 defines += [
Mike Kleinc7165c22016-10-12 23:58:06 -040051 "_CRT_SECURE_NO_WARNINGS", # Disables warnings about sscanf().
52 "_HAS_EXCEPTIONS=0", # Disables exceptions in MSVC STL.
mtkleinb9be9792016-09-16 14:44:18 -070053 "WIN32_LEAN_AND_MEAN",
54 "NOMINMAX",
herbb6318bf2016-09-16 13:29:57 -070055 ]
Mike Klein98adfa82017-07-31 15:46:47 -040056
57 _include_dirs = [
Ben Wagner4e8472c2017-03-20 16:53:05 -040058 #2017
59 "$windk/VC/Tools/MSVC/14.10.25017/include",
60
61 #2015
Mike Kleind3016832016-10-12 15:52:44 -040062 "$windk/VC/include",
Mike Kleincc300a12016-10-12 16:25:27 -040063
Mike Kleind3016832016-10-12 15:52:44 -040064 # For local builds.
Ben Wagner4e8472c2017-03-20 16:53:05 -040065 # 2017
66 "$windk/../../../Windows Kits/10/Include/10.0.14393.0/shared",
67 "$windk/../../../Windows Kits/10/Include/10.0.14393.0/ucrt",
68 "$windk/../../../Windows Kits/10/Include/10.0.14393.0/um",
69 "$windk/../../../Windows Kits/10/Include/10.0.14393.0/winrt",
70
71 # 2015
Mike Klein0f61faa2016-10-11 16:26:57 -040072 "$windk/../Windows Kits/8.1/Include/shared",
Ben Wagner4e8472c2017-03-20 16:53:05 -040073 "$windk/../Windows Kits/10/Include/10.0.10150.0/ucrt",
Mike Klein3eb71212016-10-11 17:08:53 -040074 "$windk/../Windows Kits/8.1/Include/um",
Brian Osman21d742d2017-01-10 13:31:33 -050075 "$windk/../Windows Kits/8.1/Include/winrt",
Mike Kleincc300a12016-10-12 16:25:27 -040076
Mike Kleind3016832016-10-12 15:52:44 -040077 # For builds using win_toolchain asset.
Brian Osman3f289332017-01-10 10:38:23 -050078 "$windk/win_sdk/Include/10.0.14393.0/shared",
79 "$windk/win_sdk/Include/10.0.14393.0/ucrt",
80 "$windk/win_sdk/Include/10.0.14393.0/um",
Brian Osman21d742d2017-01-10 13:31:33 -050081 "$windk/win_sdk/Include/10.0.14393.0/winrt",
Mike Klein0f61faa2016-10-11 16:26:57 -040082 ]
Mike Klein98adfa82017-07-31 15:46:47 -040083 if (is_clang) {
84 foreach(dir, _include_dirs) {
85 cflags += [
86 "-imsvc",
87 dir,
88 ]
89 }
90 } else {
91 include_dirs = _include_dirs
92 }
93
Mike Klein3eb71212016-10-11 17:08:53 -040094 lib_dirs = [
Mike Kleind3016832016-10-12 15:52:44 -040095 # For local builds.
Ben Wagner4e8472c2017-03-20 16:53:05 -040096 # 2017
97 "$windk/../../../Windows Kits/10/Lib/10.0.14393.0/ucrt/$target_cpu",
98 "$windk/../../../Windows Kits/10/Lib/10.0.14393.0/um/$target_cpu",
99
100 #2015
Mike Klein0bc5a762016-10-12 22:42:55 -0400101 "$windk/../Windows Kits/10/Lib/10.0.10150.0/ucrt/$target_cpu",
102 "$windk/../Windows Kits/8.1/Lib/winv6.3/um/$target_cpu",
Mike Kleincc300a12016-10-12 16:25:27 -0400103
Mike Kleind3016832016-10-12 15:52:44 -0400104 # For builds using win_toolchain asset.
Brian Osman3f289332017-01-10 10:38:23 -0500105 "$windk/win_sdk/Lib/10.0.14393.0/ucrt/$target_cpu",
106 "$windk/win_sdk/Lib/10.0.14393.0/um/$target_cpu",
Mike Klein3eb71212016-10-11 17:08:53 -0400107 ]
Ben Wagner4e8472c2017-03-20 16:53:05 -0400108
109 #2017
110 lib_dirs += [ "$windk/VC/Tools/MSVC/14.10.25017/lib/$target_cpu" ]
111
112 #2015
Mike Klein0bc5a762016-10-12 22:42:55 -0400113 if (target_cpu == "x86") {
114 lib_dirs += [ "$windk/VC/lib" ]
115 } else {
116 lib_dirs += [ "$windk/VC/lib/amd64" ]
117 }
mtkleinb9be9792016-09-16 14:44:18 -0700118 } else {
119 cflags += [
herbb6318bf2016-09-16 13:29:57 -0700120 "-fstrict-aliasing",
121 "-fPIC",
herbb6318bf2016-09-16 13:29:57 -0700122 "-Werror",
mtklein2b3c2a32016-09-08 08:39:34 -0700123 ]
Mike Klein28f5b772017-04-06 23:04:42 -0400124 cflags_cc += [ "-std=c++11" ]
Mike Kleineec23d12017-03-26 20:11:48 -0400125
126 # The main idea is to slim the exported API, but these flags also improve link time on Mac.
127 # These would make stack traces worse on Linux, so we don't just set them willy-nilly.
Mike Klein8cb66482017-03-28 14:16:22 -0400128 if (is_component_build || is_ios || is_mac) {
Mike Kleineec23d12017-03-26 20:11:48 -0400129 cflags += [ "-fvisibility=hidden" ]
130 cflags_cc += [ "-fvisibility-inlines-hidden" ]
131 }
mtkleinb9be9792016-09-16 14:44:18 -0700132 }
herbb6318bf2016-09-16 13:29:57 -0700133
mtkleinb9be9792016-09-16 14:44:18 -0700134 if (current_cpu == "arm") {
135 cflags += [
136 "-march=armv7-a",
137 "-mfpu=neon",
138 "-mthumb",
139 ]
140 } else if (current_cpu == "mipsel") {
Derek Sollenberger19b2a562017-06-27 11:55:05 -0400141 cflags += [ "-march=mips32r2" ]
142 } else if (current_cpu == "mips64el") {
143 asmflags += [ "-integrated-as" ]
144 cflags += [ "-integrated-as" ]
Mike Klein5d8cf292016-10-12 19:36:09 -0400145 } else if (current_cpu == "x86" && !is_win) {
mtkleinb9be9792016-09-16 14:44:18 -0700146 asmflags += [ "-m32" ]
147 cflags += [
148 "-m32",
149 "-msse2",
150 "-mfpmath=sse",
151 ]
152 ldflags += [ "-m32" ]
153 }
herbb6318bf2016-09-16 13:29:57 -0700154
Herb Derby76073c12016-12-08 19:00:40 -0500155 if (malloc != "" && !is_win) {
156 cflags += [
157 "-fno-builtin-malloc",
158 "-fno-builtin-calloc",
159 "-fno-builtin-realloc",
160 "-fno-builtin-free",
161 ]
162 libs += [ malloc ]
163 }
164
mtkleinb9be9792016-09-16 14:44:18 -0700165 if (is_android) {
Derek Sollenberger19b2a562017-06-27 11:55:05 -0400166 asmflags += [ "--target=$ndk_target" ]
mtkleinb9be9792016-09-16 14:44:18 -0700167 cflags += [
Derek Sollenberger19b2a562017-06-27 11:55:05 -0400168 "--sysroot=$ndk/sysroot",
169 "-isystem$ndk/sysroot/usr/include/$ndk_target",
170 "-D__ANDROID_API__=$ndk_api",
mtkleinb9be9792016-09-16 14:44:18 -0700171 "--target=$ndk_target",
mtkleinb9be9792016-09-16 14:44:18 -0700172 ]
173 cflags_cc += [
174 "-isystem$ndk/sources/android/support/include",
Mike Kleinb7ce80b2016-12-14 13:17:53 -0500175 "-isystem$ndk/sources/cxx-stl/gnu-libstdc++/4.9/include",
176 "-isystem$ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/$ndk_stdlib/include",
mtkleinb9be9792016-09-16 14:44:18 -0700177 ]
178 ldflags += [
179 "--sysroot=$ndk/platforms/$ndk_platform",
180 "--target=$ndk_target",
181 "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
mtkleinb9be9792016-09-16 14:44:18 -0700182 ]
183 lib_dirs = [
Mike Kleinb7ce80b2016-12-14 13:17:53 -0500184 "$ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/$ndk_stdlib",
mtkleinb9be9792016-09-16 14:44:18 -0700185 "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/lib/gcc/$ndk_target/4.9.x",
186 ]
herbb6318bf2016-09-16 13:29:57 -0700187
Mike Klein4fdc5432016-10-11 11:21:36 -0400188 if (current_cpu == "mips64el") {
Derek Sollenberger19b2a562017-06-27 11:55:05 -0400189 # The r15b NDK deployed on our bots fails to find /usr/lib64 in the
190 # MIPS64 sysroots, so we must point Clang at /usr/lib64 manually.
Mike Klein4fdc5432016-10-11 11:21:36 -0400191 lib_dirs += [ "$ndk/platforms/$ndk_platform/usr/lib64" ]
Mike Klein978cceb2016-12-08 10:29:27 -0500192 ldflags += [ "-B$ndk/platforms/$ndk_platform/usr/lib64" ]
Mike Klein4fdc5432016-10-11 11:21:36 -0400193 }
194
Mike Kleinb7ce80b2016-12-14 13:17:53 -0500195 libs += [ "gnustl_static" ]
mtklein2b3c2a32016-09-08 08:39:34 -0700196 }
mtklein7fbfbbe2016-07-21 12:25:45 -0700197
Mike Klein7d302882016-11-03 14:06:31 -0400198 if (is_ios) {
Mike Kleinb48fd3c2017-01-23 11:58:53 -0500199 _target = target_cpu
200 if (target_cpu == "arm") {
201 _target = "armv7"
Mike Klein7a5e0f32017-03-13 09:25:33 -0700202 } else if (target_cpu == "x86") {
203 _target = "i386"
204 } else if (target_cpu == "x64") {
205 _target = "x86_64"
Mike Kleinb48fd3c2017-01-23 11:58:53 -0500206 }
Mike Klein4fe2b152017-02-17 15:36:01 -0500207 asmflags += [
208 "-isysroot",
209 ios_sysroot,
210 "-arch",
211 _target,
212 ]
Mike Klein7d302882016-11-03 14:06:31 -0400213 cflags += [
Mike Klein6749af42016-11-07 15:38:48 -0500214 "-isysroot",
215 ios_sysroot,
216 "-arch",
Mike Kleinb48fd3c2017-01-23 11:58:53 -0500217 _target,
Mike Klein7d302882016-11-03 14:06:31 -0400218 ]
219 cflags_cc += [ "-stdlib=libc++" ]
220 ldflags += [
Mike Klein6749af42016-11-07 15:38:48 -0500221 "-isysroot",
222 ios_sysroot,
223 "-arch",
Mike Kleinb48fd3c2017-01-23 11:58:53 -0500224 _target,
Mike Klein7d302882016-11-03 14:06:31 -0400225 "-stdlib=libc++",
226 ]
Herb Derby76073c12016-12-08 19:00:40 -0500227 libs += [ "objc" ]
Mike Klein7d302882016-11-03 14:06:31 -0400228 }
229
mtkleinb9be9792016-09-16 14:44:18 -0700230 if (is_linux) {
Herb Derby76073c12016-12-08 19:00:40 -0500231 libs += [ "pthread" ]
mtkleinb9be9792016-09-16 14:44:18 -0700232 }
233
234 if (sanitize != "") {
235 # You can either pass the sanitizers directly, e.g. "address,undefined",
236 # or pass one of the couple common aliases used by the bots.
237 sanitizers = sanitize
238 if (sanitize == "ASAN") {
Mike Kleine4781e92017-09-28 11:42:28 -0400239 sanitizers = "address,bool,integer-divide-by-zero,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,vla-bound,vptr"
240 if (!is_mac) {
241 sanitizers += ",function"
242 }
mtkleinb9be9792016-09-16 14:44:18 -0700243 } else if (sanitize == "TSAN") {
244 sanitizers = "thread"
245 } else if (sanitize == "MSAN") {
246 sanitizers = "memory"
247 }
248
249 cflags += [
250 "-fsanitize=$sanitizers",
251 "-fno-sanitize-recover=$sanitizers",
252 "-fsanitize-blacklist=" + rebase_path("../tools/xsan.blacklist"),
253 ]
254 ldflags += [ "-fsanitize=$sanitizers" ]
255 if (sanitizers == "memory") {
256 cflags += [ "-fsanitize-memory-track-origins" ]
257 cflags_cc += [ "-stdlib=libc++" ]
258 ldflags += [ "-stdlib=libc++" ]
259 }
260 }
261}
262
Mike Klein6e55fef2016-10-26 11:41:47 -0400263config("no_exceptions") {
Mike Klein228276d2017-08-16 13:20:20 +0000264 # Exceptions are disabled by default on Windows. (Use /EHsc to enable them.)
Mike Klein6e55fef2016-10-26 11:41:47 -0400265 if (!is_win) {
266 cflags_cc = [ "-fno-exceptions" ]
267 }
268}
269
Mike Kleinc7165c22016-10-12 23:58:06 -0400270config("warnings") {
271 cflags = []
272 cflags_cc = []
Mike Klein43c25262016-10-20 10:17:47 -0400273 cflags_objc = []
Greg Daniel6b7e0e22017-07-12 16:21:09 -0400274 cflags_objcc = []
Mike Kleinc7165c22016-10-12 23:58:06 -0400275 if (is_win) {
276 cflags += [
277 "/W3", # Turn on lots of warnings.
278
279 # Disable a bunch of warnings:
280 "/wd4244", # conversion from 'float' to 'int', possible loss of data
281 "/wd4267", # conversion from 'size_t' to 'int', possible loss of data
282 "/wd4800", # forcing value to bool 'true' or 'false' (performance warning)
283
284 # Probably only triggers when /EHsc is enabled.
285 "/wd4291", # no matching operator delete found;
286 # memory will not be freed if initialization throws an exception
287 ]
288 } else {
289 cflags += [
290 "-Wall",
291 "-Wextra",
292 "-Winit-self",
293 "-Wpointer-arith",
294 "-Wsign-compare",
295 "-Wvla",
296
297 "-Wno-deprecated-declarations",
Mike Kleindb402ca2016-12-13 12:46:05 -0500298 "-Wno-maybe-uninitialized",
Mike Kleinc7165c22016-10-12 23:58:06 -0400299 ]
300 cflags_cc += [ "-Wnon-virtual-dtor" ]
301
302 if (is_clang) {
303 cflags += [
304 "-Weverything",
305 "-Wno-unknown-warning-option", # Let older Clangs ignore newer Clangs' warnings.
306 ]
307
Mike Kleinb48fd3c2017-01-23 11:58:53 -0500308 if ((target_cpu == "x86" && is_android) ||
309 (target_cpu == "arm" && is_ios)) {
310 # Clang seems to think new/malloc will only be 4-byte aligned on x86 Android and 32-bit iOS.
Mike Kleinc7165c22016-10-12 23:58:06 -0400311 # We're pretty sure it's actually 8-byte alignment.
312 cflags += [ "-Wno-over-aligned" ]
313 }
314
Mike Kleinbc7b1ea2017-09-08 20:26:36 +0000315 # TODO: fix after we're building with Clang 5
316 cflags += [
317 "-Wno-cast-qual",
318 "-Wno-unused-template",
319 "-Wno-zero-as-null-pointer-constant",
320 ]
321
Mike Kleinc7165c22016-10-12 23:58:06 -0400322 cflags += [
323 "-Wno-cast-align",
324 "-Wno-conditional-uninitialized",
325 "-Wno-conversion",
326 "-Wno-disabled-macro-expansion",
327 "-Wno-documentation",
328 "-Wno-documentation-unknown-command",
329 "-Wno-double-promotion",
330 "-Wno-exit-time-destructors", # TODO: OK outside libskia
331 "-Wno-float-conversion",
332 "-Wno-float-equal",
333 "-Wno-format-nonliteral",
334 "-Wno-global-constructors", # TODO: OK outside libskia
335 "-Wno-gnu-zero-variadic-macro-arguments",
336 "-Wno-missing-prototypes",
337 "-Wno-missing-variable-declarations",
338 "-Wno-pedantic",
339 "-Wno-reserved-id-macro",
340 "-Wno-shadow",
341 "-Wno-shift-sign-overflow",
342 "-Wno-sign-conversion",
Matt Sarettd3ed4022017-01-04 17:13:44 -0500343 "-Wno-signed-enum-bitfield",
Mike Kleinc7165c22016-10-12 23:58:06 -0400344 "-Wno-switch-enum",
345 "-Wno-undef",
346 "-Wno-unreachable-code",
347 "-Wno-unreachable-code-break",
348 "-Wno-unreachable-code-return",
349 "-Wno-unused-macros",
350 "-Wno-unused-member-function",
351 ]
352 cflags_cc += [
353 "-Wno-abstract-vbase-init",
Mike Kleinc7165c22016-10-12 23:58:06 -0400354 "-Wno-weak-vtables",
355 ]
356
357 # We are unlikely to want to fix these.
358 cflags += [
359 "-Wno-covered-switch-default",
360 "-Wno-deprecated",
361 "-Wno-implicit-fallthrough",
362 "-Wno-missing-noreturn",
363 "-Wno-old-style-cast",
364 "-Wno-padded",
365 ]
366 cflags_cc += [
367 "-Wno-c++98-compat",
368 "-Wno-c++98-compat-pedantic",
369 "-Wno-undefined-func-template",
370 ]
Mike Klein43c25262016-10-20 10:17:47 -0400371 cflags_objc += [
372 "-Wno-direct-ivar-access",
373 "-Wno-objc-interface-ivars",
374 ]
Greg Daniel6b7e0e22017-07-12 16:21:09 -0400375 cflags_objcc += [
376 "-Wno-direct-ivar-access",
377 "-Wno-objcc-interface-ivars",
378 ]
Mike Kleinc7165c22016-10-12 23:58:06 -0400379 }
380 }
381}
Mike Klein50500ad2016-11-16 12:13:44 -0500382config("warnings_except_public_headers") {
383 if (!is_win) {
384 cflags = [ "-Wno-unused-parameter" ]
385 }
386}
Mike Kleinc7165c22016-10-12 23:58:06 -0400387
Mike Klein121563e2016-10-04 17:09:13 -0400388config("extra_flags") {
Kevin Lubick2677a9a2017-03-28 15:45:41 -0400389 asmflags = extra_asmflags
Mike Klein121563e2016-10-04 17:09:13 -0400390 cflags = extra_cflags
391 cflags_c = extra_cflags_c
392 cflags_cc = extra_cflags_cc
393 ldflags = extra_ldflags
394}
395
mtkleinb9be9792016-09-16 14:44:18 -0700396config("debug_symbols") {
397 # It's annoying to wait for full debug symbols to push over
398 # to Android devices. -gline-tables-only is a lot slimmer.
399 if (is_android) {
Mike Klein1b4602b2017-08-30 10:23:01 -0400400 cflags = [
401 "-gline-tables-only",
402 "-funwind-tables", # Helps make in-process backtraces fuller.
403 ]
Mike Kleincc300a12016-10-12 16:25:27 -0400404 } else if (is_win) {
405 cflags = [ "/Zi" ]
Mike Klein5286d6c2016-10-13 13:19:25 -0400406 ldflags = [ "/DEBUG" ]
Mike Kleincc300a12016-10-12 16:25:27 -0400407 } else {
mtkleinb9be9792016-09-16 14:44:18 -0700408 cflags = [ "-g" ]
409 }
410}
411
412config("no_rtti") {
413 if (sanitize != "ASAN") { # -fsanitize=vptr requires RTTI
Mike Kleincc300a12016-10-12 16:25:27 -0400414 if (is_win) {
415 cflags_cc = [ "/GR-" ]
416 } else {
mtkleinb9be9792016-09-16 14:44:18 -0700417 cflags_cc = [ "-fno-rtti" ]
418 }
419 }
420}
421
422config("release") {
Mike Kleincc300a12016-10-12 16:25:27 -0400423 if (is_win) {
Mike Klein916ca1d2016-10-20 13:34:18 -0400424 cflags = [
425 "/O2",
426 "/Zc:inline",
Mike Klein8ffb2602016-10-20 15:45:02 -0400427 "/GS-",
Mike Klein916ca1d2016-10-20 13:34:18 -0400428 ]
Mike Klein90a381f2016-10-20 13:52:38 -0400429 ldflags = [
430 "/OPT:ICF",
431 "/OPT:REF",
432 ]
Mike Kleincc300a12016-10-12 16:25:27 -0400433 } else {
Mike Klein0bcfeac2016-10-19 22:24:10 -0400434 cflags = [
435 "-O3",
Mike Kleinbd9be4d2017-02-10 07:59:39 -0500436 "-fdata-sections",
437 "-ffunction-sections",
Mike Klein0bcfeac2016-10-19 22:24:10 -0400438 ]
Mike Kleinbd9be4d2017-02-10 07:59:39 -0500439 if (is_mac || is_ios) {
440 ldflags = [ "-dead_strip" ]
441 } else {
442 ldflags = [ "-Wl,--gc-sections" ]
443 }
Kevin Lubickebf648e2017-09-21 13:45:16 -0400444 if (target_cpu == "wasm") {
445 # The compiler asks us to add an optimization flag to both cflags
446 # and ldflags to cut down on the local variables,
447 # for performance reasons.
448 # The "linking" step is the conversion to javascript.
449 ldflags += [ "-O3" ]
450 }
herbb6318bf2016-09-16 13:29:57 -0700451 }
mtkleinb9be9792016-09-16 14:44:18 -0700452 defines = [ "NDEBUG" ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700453}
454
455config("executable") {
Mike Kleinc5875fb2016-12-06 10:46:02 -0500456 if (is_android) {
Mike Klein1b4602b2017-08-30 10:23:01 -0400457 ldflags = [
458 "-pie",
459 "-rdynamic",
460 ]
Mike Kleinc5875fb2016-12-06 10:46:02 -0500461 } else if (is_mac) {
mtklein7fbfbbe2016-07-21 12:25:45 -0700462 ldflags = [ "-Wl,-rpath,@loader_path/." ]
463 } else if (is_linux) {
mtkleina846c722016-09-15 10:44:15 -0700464 ldflags = [
465 "-rdynamic",
466 "-Wl,-rpath,\$ORIGIN",
467 ]
Mike Klein4b6b5032016-11-06 11:54:19 -0500468 } else if (is_win) {
469 ldflags = [
470 "/SUBSYSTEM:CONSOLE", # Quiet "no subsystem specified; CONSOLE assumed".
471 "/INCREMENTAL:NO", # Quiet warnings about failing to incrementally link by never trying to.
472 ]
mtklein7fbfbbe2016-07-21 12:25:45 -0700473 }
474}