blob: fcffd5d064f7193698c066ee3102439d1d11673b [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 += [
herbb6318bf2016-09-16 13:29:57 -070042 "/bigobj", # Some of our files are bigger than the regular limits.
Mike Kleinc7165c22016-10-12 23:58:06 -040043 "/WX", # Treat warnings as errors.
Ben Wagnere6b274e2017-01-03 17:09:59 -050044 "/utf-8", # Set Source and Executable character sets to UTF-8.
herbb6318bf2016-09-16 13:29:57 -070045 ]
Mike Kleina91ec582017-07-31 16:35:17 -040046 if (is_clang) {
47 cflags += [ "-fms-compatibility-version=19" ] # 2015
48 }
mtkleinb9be9792016-09-16 14:44:18 -070049 defines += [
Mike Kleinc7165c22016-10-12 23:58:06 -040050 "_CRT_SECURE_NO_WARNINGS", # Disables warnings about sscanf().
51 "_HAS_EXCEPTIONS=0", # Disables exceptions in MSVC STL.
mtkleinb9be9792016-09-16 14:44:18 -070052 "WIN32_LEAN_AND_MEAN",
53 "NOMINMAX",
herbb6318bf2016-09-16 13:29:57 -070054 ]
Mike Klein98adfa82017-07-31 15:46:47 -040055
Brian Osmand34c4a32017-12-06 13:26:38 -050056 if (msvc == 2015) {
Brian Osman852ca312017-12-07 16:16:21 -050057 _include_dirs = [ "$win_vc/include" ]
Brian Osman5f872622017-12-06 15:21:44 -050058 } else { # 2017
Brian Osman852ca312017-12-07 16:16:21 -050059 _include_dirs = [ "$win_vc/Tools/MSVC/$win_toolchain_version/include" ]
Ravi Mistryf5ab2692017-12-06 21:51:23 +000060 }
Brian Osman5f872622017-12-06 15:21:44 -050061 _include_dirs += [
62 "$win_sdk/Include/$win_sdk_version/shared",
63 "$win_sdk/Include/$win_sdk_version/ucrt",
64 "$win_sdk/Include/$win_sdk_version/um",
65 "$win_sdk/Include/$win_sdk_version/winrt",
66 ]
67
Mike Klein98adfa82017-07-31 15:46:47 -040068 if (is_clang) {
69 foreach(dir, _include_dirs) {
70 cflags += [
71 "-imsvc",
72 dir,
73 ]
74 }
75 } else {
76 include_dirs = _include_dirs
77 }
78
Brian Osman5f872622017-12-06 15:21:44 -050079 lib_dirs = [
80 "$win_sdk/Lib/$win_sdk_version/ucrt/$target_cpu",
81 "$win_sdk/Lib/$win_sdk_version/um/$target_cpu",
82 ]
Brian Osmand34c4a32017-12-06 13:26:38 -050083 if (msvc == 2015) {
Brian Osmand34c4a32017-12-06 13:26:38 -050084 if (target_cpu == "x86") {
Brian Osman852ca312017-12-07 16:16:21 -050085 lib_dirs += [ "$win_vc/lib" ]
Brian Osmand34c4a32017-12-06 13:26:38 -050086 } else {
Brian Osman852ca312017-12-07 16:16:21 -050087 lib_dirs += [ "$win_vc/lib/amd64" ]
Brian Osmand34c4a32017-12-06 13:26:38 -050088 }
Brian Osman5f872622017-12-06 15:21:44 -050089 } else { # 2017
90 lib_dirs +=
Brian Osman852ca312017-12-07 16:16:21 -050091 [ "$win_vc/Tools/MSVC/$win_toolchain_version/lib/$target_cpu" ]
Mike Klein0bc5a762016-10-12 22:42:55 -040092 }
mtkleinb9be9792016-09-16 14:44:18 -070093 } else {
94 cflags += [
herbb6318bf2016-09-16 13:29:57 -070095 "-fstrict-aliasing",
96 "-fPIC",
herbb6318bf2016-09-16 13:29:57 -070097 "-Werror",
mtklein2b3c2a32016-09-08 08:39:34 -070098 ]
Mike Klein28f5b772017-04-06 23:04:42 -040099 cflags_cc += [ "-std=c++11" ]
Mike Kleineec23d12017-03-26 20:11:48 -0400100
101 # The main idea is to slim the exported API, but these flags also improve link time on Mac.
102 # These would make stack traces worse on Linux, so we don't just set them willy-nilly.
Mike Klein8cb66482017-03-28 14:16:22 -0400103 if (is_component_build || is_ios || is_mac) {
Mike Kleineec23d12017-03-26 20:11:48 -0400104 cflags += [ "-fvisibility=hidden" ]
105 cflags_cc += [ "-fvisibility-inlines-hidden" ]
106 }
mtkleinb9be9792016-09-16 14:44:18 -0700107 }
herbb6318bf2016-09-16 13:29:57 -0700108
mtkleinb9be9792016-09-16 14:44:18 -0700109 if (current_cpu == "arm") {
110 cflags += [
111 "-march=armv7-a",
112 "-mfpu=neon",
113 "-mthumb",
114 ]
Mike Klein5d8cf292016-10-12 19:36:09 -0400115 } else if (current_cpu == "x86" && !is_win) {
mtkleinb9be9792016-09-16 14:44:18 -0700116 asmflags += [ "-m32" ]
117 cflags += [
118 "-m32",
119 "-msse2",
120 "-mfpmath=sse",
121 ]
122 ldflags += [ "-m32" ]
123 }
herbb6318bf2016-09-16 13:29:57 -0700124
Herb Derby76073c12016-12-08 19:00:40 -0500125 if (malloc != "" && !is_win) {
126 cflags += [
127 "-fno-builtin-malloc",
128 "-fno-builtin-calloc",
129 "-fno-builtin-realloc",
130 "-fno-builtin-free",
131 ]
132 libs += [ malloc ]
133 }
134
mtkleinb9be9792016-09-16 14:44:18 -0700135 if (is_android) {
Derek Sollenberger19b2a562017-06-27 11:55:05 -0400136 asmflags += [ "--target=$ndk_target" ]
mtkleinb9be9792016-09-16 14:44:18 -0700137 cflags += [
Derek Sollenberger19b2a562017-06-27 11:55:05 -0400138 "--sysroot=$ndk/sysroot",
139 "-isystem$ndk/sysroot/usr/include/$ndk_target",
140 "-D__ANDROID_API__=$ndk_api",
mtkleinb9be9792016-09-16 14:44:18 -0700141 "--target=$ndk_target",
mtkleinb9be9792016-09-16 14:44:18 -0700142 ]
143 cflags_cc += [
Mike Klein21b620c2018-01-08 17:16:00 -0500144 "-isystem$ndk/sources/cxx-stl/llvm-libc++/include",
145 "-isystem$ndk/sources/cxx-stl/llvm-libc++abi/include",
mtkleinb9be9792016-09-16 14:44:18 -0700146 "-isystem$ndk/sources/android/support/include",
mtkleinb9be9792016-09-16 14:44:18 -0700147 ]
148 ldflags += [
149 "--sysroot=$ndk/platforms/$ndk_platform",
150 "--target=$ndk_target",
151 "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
mtkleinb9be9792016-09-16 14:44:18 -0700152 ]
153 lib_dirs = [
Mike Klein21b620c2018-01-08 17:16:00 -0500154 "$ndk/sources/cxx-stl/llvm-libc++/libs/$ndk_stdlib",
mtkleinb9be9792016-09-16 14:44:18 -0700155 "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/lib/gcc/$ndk_target/4.9.x",
156 ]
herbb6318bf2016-09-16 13:29:57 -0700157
Mike Klein21b620c2018-01-08 17:16:00 -0500158 libs += [
159 "c++_static",
160 "c++abi",
161 "android_support",
162 ]
mtklein2b3c2a32016-09-08 08:39:34 -0700163 }
mtklein7fbfbbe2016-07-21 12:25:45 -0700164
Mike Klein7d302882016-11-03 14:06:31 -0400165 if (is_ios) {
Mike Kleinb48fd3c2017-01-23 11:58:53 -0500166 _target = target_cpu
167 if (target_cpu == "arm") {
168 _target = "armv7"
Mike Klein7a5e0f32017-03-13 09:25:33 -0700169 } else if (target_cpu == "x86") {
170 _target = "i386"
171 } else if (target_cpu == "x64") {
172 _target = "x86_64"
Mike Kleinb48fd3c2017-01-23 11:58:53 -0500173 }
Mike Klein4fe2b152017-02-17 15:36:01 -0500174 asmflags += [
175 "-isysroot",
176 ios_sysroot,
177 "-arch",
178 _target,
179 ]
Mike Klein7d302882016-11-03 14:06:31 -0400180 cflags += [
Mike Klein6749af42016-11-07 15:38:48 -0500181 "-isysroot",
182 ios_sysroot,
183 "-arch",
Mike Kleinb48fd3c2017-01-23 11:58:53 -0500184 _target,
Mike Klein7d302882016-11-03 14:06:31 -0400185 ]
186 cflags_cc += [ "-stdlib=libc++" ]
187 ldflags += [
Mike Klein6749af42016-11-07 15:38:48 -0500188 "-isysroot",
189 ios_sysroot,
190 "-arch",
Mike Kleinb48fd3c2017-01-23 11:58:53 -0500191 _target,
Mike Klein7d302882016-11-03 14:06:31 -0400192 "-stdlib=libc++",
193 ]
Herb Derby76073c12016-12-08 19:00:40 -0500194 libs += [ "objc" ]
Mike Klein7d302882016-11-03 14:06:31 -0400195 }
196
mtkleinb9be9792016-09-16 14:44:18 -0700197 if (is_linux) {
Herb Derby76073c12016-12-08 19:00:40 -0500198 libs += [ "pthread" ]
mtkleinb9be9792016-09-16 14:44:18 -0700199 }
Mike Klein15f46c32017-12-07 12:48:57 -0500200 if (is_mac) {
201 # Disable linker warnings. They're usually just annoyances like,
202 # ld: warning: text-based stub file
203 # /System/Library/Frameworks/foo.framework/foo.tbd and library file
204 # /System/Library/Frameworks/foo.framework/foo are out of sync.
205 # Falling back to library file for linking.
206 ldflags += [ "-Wl,-w" ]
207 }
mtkleinb9be9792016-09-16 14:44:18 -0700208
209 if (sanitize != "") {
210 # You can either pass the sanitizers directly, e.g. "address,undefined",
211 # or pass one of the couple common aliases used by the bots.
212 sanitizers = sanitize
Ben Wagner314d7c22018-01-03 11:04:30 -0500213 if (sanitize == "ASAN" || sanitize == "UBSAN") {
214 # ASAN implicitly runs all UBSAN checks also.
215 sanitizers = "bool,float-cast-overflow,integer-divide-by-zero,nonnull-attribute,null,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,vla-bound"
216 if (!is_mac && !is_win) {
217 sanitizers += ",function" # Not supported on Mac or Win.
Mike Klein46d6c682017-10-05 11:22:09 -0400218 }
Ben Wagner314d7c22018-01-03 11:04:30 -0500219 if (!is_win) {
220 sanitizers += ",vptr" # Not supported on Win.
221 }
222 if (!is_debug && !is_win) {
223 # No-op with somewhat annoying warning at -O0.
224 # Seems to be broken on Win.
225 sanitizers += ",object-size"
226 }
227 if (sanitize == "ASAN") {
228 sanitizers += ",address"
Mike Kleine4781e92017-09-28 11:42:28 -0400229 }
Kevin Lubick4f0f9332018-01-12 14:31:48 -0500230 if (is_android) {
231 # Android only easily supports address for now
232 # UBSAN runs into linking errors
233 sanitizers = "address"
234
235 # recommended by
236 # https://github.com/google/sanitizers/wiki/AddressSanitizerOnAndroid
237 cflags += [ "-fno-omit-frame-pointer" ]
238 }
mtkleinb9be9792016-09-16 14:44:18 -0700239 } else if (sanitize == "TSAN") {
240 sanitizers = "thread"
241 } else if (sanitize == "MSAN") {
242 sanitizers = "memory"
243 }
244
245 cflags += [
246 "-fsanitize=$sanitizers",
247 "-fno-sanitize-recover=$sanitizers",
248 "-fsanitize-blacklist=" + rebase_path("../tools/xsan.blacklist"),
249 ]
250 ldflags += [ "-fsanitize=$sanitizers" ]
251 if (sanitizers == "memory") {
252 cflags += [ "-fsanitize-memory-track-origins" ]
253 cflags_cc += [ "-stdlib=libc++" ]
254 ldflags += [ "-stdlib=libc++" ]
255 }
256 }
257}
258
Mike Klein6e55fef2016-10-26 11:41:47 -0400259config("no_exceptions") {
Mike Klein228276d2017-08-16 13:20:20 +0000260 # Exceptions are disabled by default on Windows. (Use /EHsc to enable them.)
Mike Klein6e55fef2016-10-26 11:41:47 -0400261 if (!is_win) {
262 cflags_cc = [ "-fno-exceptions" ]
263 }
264}
265
Mike Kleinc7165c22016-10-12 23:58:06 -0400266config("warnings") {
267 cflags = []
268 cflags_cc = []
Mike Klein43c25262016-10-20 10:17:47 -0400269 cflags_objc = []
Greg Daniel6b7e0e22017-07-12 16:21:09 -0400270 cflags_objcc = []
Mike Kleinc7165c22016-10-12 23:58:06 -0400271 if (is_win) {
272 cflags += [
273 "/W3", # Turn on lots of warnings.
274
275 # Disable a bunch of warnings:
276 "/wd4244", # conversion from 'float' to 'int', possible loss of data
277 "/wd4267", # conversion from 'size_t' to 'int', possible loss of data
278 "/wd4800", # forcing value to bool 'true' or 'false' (performance warning)
279
280 # Probably only triggers when /EHsc is enabled.
281 "/wd4291", # no matching operator delete found;
282 # memory will not be freed if initialization throws an exception
283 ]
284 } else {
285 cflags += [
286 "-Wall",
287 "-Wextra",
288 "-Winit-self",
289 "-Wpointer-arith",
290 "-Wsign-compare",
291 "-Wvla",
292
293 "-Wno-deprecated-declarations",
Mike Kleindb402ca2016-12-13 12:46:05 -0500294 "-Wno-maybe-uninitialized",
Mike Kleinc7165c22016-10-12 23:58:06 -0400295 ]
296 cflags_cc += [ "-Wnon-virtual-dtor" ]
Chris Dalton1ef80942017-12-04 12:01:30 -0700297 }
Mike Kleinc7165c22016-10-12 23:58:06 -0400298
Chris Dalton1ef80942017-12-04 12:01:30 -0700299 if (is_clang) {
300 cflags += [
301 "-Weverything",
302 "-Wno-unknown-warning-option", # Let older Clangs ignore newer Clangs' warnings.
303 ]
Mike Kleinc7165c22016-10-12 23:58:06 -0400304
Chris Dalton1ef80942017-12-04 12:01:30 -0700305 if (target_cpu == "arm" && is_ios) {
306 # Clang seems to think new/malloc will only be 4-byte aligned on 32-bit iOS.
307 # We're pretty sure it's actually 8-byte alignment.
308 cflags += [ "-Wno-over-aligned" ]
Mike Kleinc7165c22016-10-12 23:58:06 -0400309 }
Mike Klein04282792018-01-08 18:23:32 -0500310 if (target_cpu == "x86" && is_android) {
311 # Clang seems to think new/malloc will only be 4-byte aligned on 32-bit x86 Android builds.
312 # We're pretty sure it's actually 8-byte alignment. See OverAlignedTest.cpp for more info.
313 cflags += [ "-Wno-over-aligned" ]
314 }
Chris Dalton1ef80942017-12-04 12:01:30 -0700315
316 # Shouldn't be necessary for local builds. With distributed Windows builds, files may lose
317 # their case during copy, causing case-sensitivity mismatch on remote machines.
318 cflags += [
319 "-Wno-nonportable-include-path",
320 "-Wno-nonportable-system-include-path",
321 ]
322
323 # TODO: These would all be really great warnings to turn on.
324 cflags += [
325 "-Wno-cast-align",
326 "-Wno-cast-qual",
Chris Dalton1ef80942017-12-04 12:01:30 -0700327 "-Wno-conversion",
328 "-Wno-disabled-macro-expansion",
329 "-Wno-documentation",
330 "-Wno-documentation-unknown-command",
331 "-Wno-double-promotion",
332 "-Wno-exit-time-destructors", # TODO: OK outside libskia
Chris Dalton1ef80942017-12-04 12:01:30 -0700333 "-Wno-float-equal",
334 "-Wno-format-nonliteral",
335 "-Wno-global-constructors", # TODO: OK outside libskia
Chris Dalton1ef80942017-12-04 12:01:30 -0700336 "-Wno-missing-prototypes",
337 "-Wno-missing-variable-declarations",
338 "-Wno-pedantic",
339 "-Wno-reserved-id-macro",
340 "-Wno-shadow",
341 "-Wno-shift-sign-overflow",
Chris Dalton1ef80942017-12-04 12:01:30 -0700342 "-Wno-signed-enum-bitfield",
343 "-Wno-switch-enum",
344 "-Wno-undef",
345 "-Wno-unreachable-code",
346 "-Wno-unreachable-code-break",
347 "-Wno-unreachable-code-return",
348 "-Wno-unused-macros",
349 "-Wno-unused-member-function",
350 "-Wno-unused-template",
351 "-Wno-zero-as-null-pointer-constant",
352 ]
353 cflags_cc += [
354 "-Wno-abstract-vbase-init",
355 "-Wno-weak-vtables",
356 ]
357
358 # We are unlikely to want to fix these.
359 cflags += [
360 "-Wno-covered-switch-default",
361 "-Wno-deprecated",
362 "-Wno-implicit-fallthrough",
363 "-Wno-missing-noreturn",
364 "-Wno-old-style-cast",
365 "-Wno-padded",
Chris Daltond1ec4102017-12-04 13:31:21 -0700366 "-Wno-newline-eof",
Chris Dalton1ef80942017-12-04 12:01:30 -0700367 ]
368 cflags_cc += [
369 "-Wno-c++98-compat",
370 "-Wno-c++98-compat-pedantic",
371 "-Wno-undefined-func-template",
372 ]
373 cflags_objc += [
374 "-Wno-direct-ivar-access",
375 "-Wno-objc-interface-ivars",
376 ]
377 cflags_objcc += [
378 "-Wno-direct-ivar-access",
379 "-Wno-objcc-interface-ivars",
380 ]
Mike Kleinc7165c22016-10-12 23:58:06 -0400381 }
382}
Mike Klein50500ad2016-11-16 12:13:44 -0500383config("warnings_except_public_headers") {
Chris Dalton1ef80942017-12-04 12:01:30 -0700384 if (!is_win || is_clang) {
Mike Klein50500ad2016-11-16 12:13:44 -0500385 cflags = [ "-Wno-unused-parameter" ]
386 }
387}
Mike Kleinc7165c22016-10-12 23:58:06 -0400388
Mike Klein121563e2016-10-04 17:09:13 -0400389config("extra_flags") {
Kevin Lubick2677a9a2017-03-28 15:45:41 -0400390 asmflags = extra_asmflags
Mike Klein121563e2016-10-04 17:09:13 -0400391 cflags = extra_cflags
392 cflags_c = extra_cflags_c
393 cflags_cc = extra_cflags_cc
394 ldflags = extra_ldflags
395}
396
mtkleinb9be9792016-09-16 14:44:18 -0700397config("debug_symbols") {
398 # It's annoying to wait for full debug symbols to push over
399 # to Android devices. -gline-tables-only is a lot slimmer.
400 if (is_android) {
Mike Klein1b4602b2017-08-30 10:23:01 -0400401 cflags = [
402 "-gline-tables-only",
403 "-funwind-tables", # Helps make in-process backtraces fuller.
404 ]
Mike Kleincc300a12016-10-12 16:25:27 -0400405 } else if (is_win) {
Mike Klein67a86d52017-12-15 07:34:27 -0500406 cflags = [ "/Z7" ]
Brian Osmana99d9822017-12-28 14:53:10 -0500407 ldflags = [ "/DEBUG:FASTLINK" ]
Mike Kleincc300a12016-10-12 16:25:27 -0400408 } else {
mtkleinb9be9792016-09-16 14:44:18 -0700409 cflags = [ "-g" ]
410 }
411}
412
413config("no_rtti") {
414 if (sanitize != "ASAN") { # -fsanitize=vptr requires RTTI
Mike Kleincc300a12016-10-12 16:25:27 -0400415 if (is_win) {
416 cflags_cc = [ "/GR-" ]
417 } else {
mtkleinb9be9792016-09-16 14:44:18 -0700418 cflags_cc = [ "-fno-rtti" ]
419 }
420 }
421}
422
423config("release") {
Mike Kleincc300a12016-10-12 16:25:27 -0400424 if (is_win) {
Mike Klein916ca1d2016-10-20 13:34:18 -0400425 cflags = [
426 "/O2",
427 "/Zc:inline",
428 ]
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}