Debian Codegraph @

gn/skia/BUILD.gn

raw ◀ ▶
Source reconstructed at patch state 0 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
1 # 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
6 if (is_wasm) {
7 import("../toolchain/wasm.gni")
8 }
9
10 import("../skia.gni")
11
12 declare_args() {
13 extra_asmflags = []
14 extra_cflags = []
15 extra_cflags_c = []
16 extra_cflags_cc = []
17 extra_ldflags = []
18
19 malloc = ""
20 werror = false
21 xcode_sysroot = ""
22 }
23
24 if (is_ios && xcode_sysroot == "") {
25 if (is_tvos) {
26 sdk = "appletvos"
27 if (ios_use_simulator) {
28 sdk = "appletvsimulator"
29 }
30 } else {
31 sdk = "iphoneos"
32 if (ios_use_simulator) {
33 sdk = "iphonesimulator"
34 }
35 }
36 xcode_sysroot =
37 exec_script("../find_xcode_sysroot.py", [ sdk ], "trim string")
38 }
39
40 # If building for mac on a mac then lookup all the system includes so that goma and the clang
41 # shipped with chrome can find them. When the gn_to_bp.py tool is run, then the host_os != mac.
42 # In this case leave the xcode_sysroot empty, and the cc/c++ that come with XCode will be able to
43 # find needed include paths.
44 if (is_mac && host_os == "mac" && xcode_sysroot == "") {
45 xcode_sysroot =
46 exec_script("../find_xcode_sysroot.py", [ "macosx" ], "trim string")
47 }
48
49 config("default") {
50 asmflags = []
51 cflags = []
52 cflags_c = []
53 cflags_cc = []
54 cflags_objcc = []
55 defines = []
56 ldflags = []
57 libs = []
58
59 # Disable warnings about unknown attributes.
60 # (These unknown attribute warnings are on by default, so we don't make
61 # disabling them part of :warnings, as some targets remove :warnings.)
62 if (is_win && !is_clang) {
63 cflags += [
64 "/wd5030",
65 "/wd5051",
66 ]
67 } else {
68 cflags += [ "-Wno-attributes" ]
69 }
70
71 if (is_clang && !is_win) {
72 # In Clang 14, this default was changed. We turn this off to (hopefully) make our
73 # GMs more consistent in the transition.
74 cflags += [ "-ffp-contract=off" ]
75 }
76
77 if (is_win) {
78 if (is_clang && current_cpu == "arm64") {
79 cflags += [ "--target=arm64-windows" ]
80 }
81 cflags += [
82 "/bigobj", # Some of our files are bigger than the regular limits.
83 "/utf-8", # Set Source and Executable character sets to UTF-8.
84 ]
85 cflags_cc += [ "/std:c++20" ]
86
87 if (!is_clang) {
88 # https://developercommunity.visualstudio.com/t/Incorrect-C4573-when-taking-address-of-m/10662923
89 cflags_cc += [ "/Zc:lambda" ]
90 }
91 defines += [
92 "_CRT_SECURE_NO_WARNINGS", # Disables warnings about sscanf().
93 "_HAS_EXCEPTIONS=0", # Disables exceptions in MSVC STL.
94 "WIN32_LEAN_AND_MEAN",
95 "NOMINMAX",
96 ]
97
98 _include_dirs = [
99 "$win_vc/Tools/MSVC/$win_toolchain_version/include",
100 "$win_sdk/Include/$win_sdk_version/shared",
101 "$win_sdk/Include/$win_sdk_version/ucrt",
102 "$win_sdk/Include/$win_sdk_version/um",
103 "$win_sdk/Include/$win_sdk_version/winrt",
104 ]
105
106 if (is_clang) {
107 foreach(dir, _include_dirs) {
108 cflags += [
109 "-imsvc",
110 dir,
111 ]
112 }
113 } else {
114 include_dirs = _include_dirs
115 }
116
117 lib_dirs = [
118 "$win_sdk/Lib/$win_sdk_version/ucrt/$current_cpu",
119 "$win_sdk/Lib/$win_sdk_version/um/$current_cpu",
120 "$win_vc/Tools/MSVC/$win_toolchain_version/lib/$current_cpu",
121 ]
122 } else {
123 if (!skia_no_pic) {
124 cflags += [ "-fPIC" ]
125 }
126 cflags += [
127 "-fvisibility=hidden",
128 ]
129 cflags_cc += [ "-fvisibility-inlines-hidden" ]
130 cflags_cc += [ "-std=c++20" ]
131 }
132
133 if (current_cpu == "arm") {
134 cflags += [
135 "-march=armv7-a",
136 "-mfpu=neon",
137 "-mthumb",
138 ]
139 } else if (current_cpu == "x86" && !is_win) {
140 asmflags += [ "-m32" ]
141 cflags += [
142 "-m32",
143 "-msse2",
144 "-mfpmath=sse",
145 ]
146 ldflags += [ "-m32" ]
147 } else if (current_cpu == "loong64") {
148 cflags += [
149 "-mlsx",
150 "-Wno-switch-default",
151 ]
152 if (!is_clang && !is_win) {
153 cflags += [ "-flax-vector-conversions" ]
154 }
155 }
156
157 if (malloc != "" && !is_win) {
158 cflags += [
159 "-fno-builtin-malloc",
160 "-fno-builtin-calloc",
161 "-fno-builtin-realloc",
162 "-fno-builtin-free",
163 ]
164 libs += [ malloc ]
165 }
166
167 if (is_android) {
168 cflags += [ "--sysroot=$ndk/toolchains/llvm/prebuilt/$ndk_host/sysroot" ]
169 ldflags += [ "-static-libstdc++" ]
170 }
171
172 if (show_includes) {
173 assert(is_clang, "show_includes requires clang to build.")
174 if (is_win) {
175 cflags += [
176 "/clang:-H",
177 "/clang:-fshow-skipped-includes",
178 ]
179 } else {
180 cflags += [
181 "-H",
182 "-fshow-skipped-includes",
183 ]
184 }
185 }
186
187 if (is_ios) {
188 if (current_cpu == "arm") {
189 _arch_flags = [
190 "-arch",
191 "armv7",
192 ]
193 } else if (current_cpu == "arm64") {
194 _arch_flags = [
195 "-arch",
196 "arm64",
197 "-arch",
198 "arm64e",
199 ]
200 } else if (current_cpu == "x86") {
201 _arch_flags = [
202 "-arch",
203 "i386",
204 ]
205 } else if (current_cpu == "x64") {
206 _arch_flags = [
207 "-arch",
208 "x86_64",
209 ]
210 } else {
211 _arch_flags = [
212 "-arch",
213 current_cpu,
214 ]
215 }
216
217 asmflags += [
218 "-isysroot",
219 xcode_sysroot,
220 ] + _arch_flags
221 cflags += [
222 "-isysroot",
223 xcode_sysroot,
224 ] + _arch_flags
225 cflags_cc += [
226 "-stdlib=libc++",
227 "-fno-aligned-allocation",
228 ]
229 ldflags += [
230 "-isysroot",
231 xcode_sysroot,
232 "-stdlib=libc++",
233 ] + _arch_flags
234 libs += [ "objc" ]
235 if (ios_min_target != "") {
236 if (ios_use_simulator) {
237 cflags += [ "-miphonesimulator-version-min=$ios_min_target" ]
238 asmflags += [ "-miphonesimulator-version-min=$ios_min_target" ]
239 ldflags += [ "-miphonesimulator-version-min=$ios_min_target" ]
240 } else {
241 cflags += [ "-miphoneos-version-min=$ios_min_target" ]
242 asmflags += [ "-miphoneos-version-min=$ios_min_target" ]
243 ldflags += [ "-miphoneos-version-min=$ios_min_target" ]
244 }
245 }
246 }
247
248 if (is_linux) {
249 libs += [ "pthread" ]
250 }
251
252 if (is_mac) {
253 # If there was a xcode_sysroot set in args or calculated then use it, else don't set anything
254 # because the XCode cc/c++ already know all this stuff.
255 if (xcode_sysroot != "") {
256 asmflags += [
257 "-isysroot",
258 xcode_sysroot,
259 ]
260 cflags += [
261 "-isysroot",
262 xcode_sysroot,
263 ]
264 ldflags += [
265 "-isysroot",
266 xcode_sysroot,
267 ]
268 }
269
270 # Disable linker warnings. They're usually just annoyances like,
271 # ld: warning: text-based stub file
272 # /System/Library/Frameworks/foo.framework/foo.tbd and library file
273 # /System/Library/Frameworks/foo.framework/foo are out of sync.
274 # Falling back to library file for linking.
275 ldflags += [ "-Wl,-w" ]
276
277 # As of 11/2020, gn is an x86 binary and defaults the host_cpu to x86_64.
278 # This allows you to build arm64 mac binaries by setting target_cpu = "arm64"
279 if (current_cpu == "arm64") {
280 asmflags += [
281 "-target",
282 "arm64-apple-macos11",
283 ]
284 cflags += [
285 "-target",
286 "arm64-apple-macos11",
287 ]
288 ldflags += [
289 "-target",
290 "arm64-apple-macos11",
291 ]
292 } else {
293 asmflags += [
294 "-target",
295 "x86_64-apple-macos11",
296 ]
297 cflags += [
298 "-target",
299 "x86_64-apple-macos11",
300 ]
301 ldflags += [
302 "-target",
303 "x86_64-apple-macos11",
304 ]
305 }
306 }
307
308 if (is_wasm) {
309 cflags += [ "--sysroot=$skia_emsdk_dir/upstream/emscripten/cache/sysroot" ]
310 ldflags += [ "--sysroot=$skia_emsdk_dir/upstream/emscripten/cache/sysroot" ]
311 }
312
313 # sanitize only applies to the default toolchain (usually the target).
314 if (current_toolchain != default_toolchain) {
315 sanitize = ""
316 }
317
318 if (is_win && !is_clang && sanitize == "ASAN") {
319 sanitizers = "address"
320 cflags += [ "/fsanitize=$sanitizers" ]
321 } else if (sanitize != "" && sanitize != "MSVC") {
322 # You can either pass the sanitizers directly, e.g. "address,undefined",
323 # or pass one of the couple common aliases used by the bots.
324 sanitizers = sanitize
325
326 if (sanitize == "ASAN") {
327 # ASAN implicitly runs all UBSAN checks also.
328 sanitizers = "undefined,address,float-divide-by-zero"
329
330 if (is_android) {
331 # TODO(skbug.com/40044427): work out UBSAN link errors
332 sanitizers = "address"
333 }
334 } else if (sanitize == "HWASAN") {
335 sanitizers = "hwaddress"
336 } else if (sanitize == "TSAN") {
337 sanitizers = "thread"
338 } else if (sanitize == "MSAN") {
339 sanitizers = "memory"
340 }
341
342 _suppressions = rebase_path("../../tools/xsan.supp")
343
344 cflags += [
345 "-fsanitize=$sanitizers",
346 "-fno-sanitize-recover=$sanitizers",
347 "-fsanitize-blacklist=$_suppressions",
348 ]
349 if (is_mac) {
350 # https://github.com/llvm/llvm-project/issues/109074
351 cflags += [ "-fno-sanitize=function" ]
352 }
353
354 if (is_win) {
355 cflags += [
356 # On Release builds, we get strange warnings about string literals.
357 "/GF-",
358 ]
359
360 assert(clang_win != "")
361 libs += [ "$clang_win/lib/clang/$clang_win_version/lib/windows/clang_rt.asan-x86_64.lib" ]
362 } else {
363 cflags += [ "-fno-omit-frame-pointer" ]
364
365 ldflags += [ "-fsanitize=$sanitizers" ]
366 }
367
368 if (is_linux) {
369 cflags_cc += [ "-stdlib=libc++" ]
370 ldflags += [ "-stdlib=libc++" ]
371 }
372
373 if (sanitizers == "memory") {
374 cflags += [ "-fsanitize-memory-track-origins" ]
375 }
376 if (sanitizers == "safe-stack") {
377 cflags_cc += [ "-fno-aligned-allocation" ]
378 }
379 }
380
381 cflags_objcc += cflags_cc
382 }
383
384 # See skbug.com/40041063.
385 config("recover_pointer_overflow") {
386 if (sanitize == "ASAN" && !(is_win && !is_clang)) {
387 cflags = [ "-fsanitize-recover=pointer-overflow" ]
388 }
389 }
390
391 config("no_exceptions") {
392 # Exceptions are disabled by default on Windows. (Use /EHsc to enable them.)
393 if (!is_win) {
394 cflags_cc = [ "-fno-exceptions" ]
395 cflags_objcc = cflags_cc
396 }
397 }
398
399 config("warnings") {
400 cflags = []
401 cflags_cc = []
402 cflags_objc = []
403 cflags_objcc = []
404
405 if (werror) {
406 if (is_win) {
407 cflags += [ "/WX" ]
408 } else {
409 cflags += [ "-Werror" ]
410 }
411 }
412
413 if (is_win) {
414 cflags += [
415 "/W3", # Turn on lots of warnings.
416
417 # Disable a bunch of warnings:
418 "/wd4244", # conversion from 'float' to 'int', possible loss of data
419 "/wd4267", # conversion from 'size_t' to 'int', possible loss of data
420 "/wd4800", # forcing value to bool 'true' or 'false' (performance
421 # warning)
422
423 # Probably only triggers when /EHsc is enabled.
424 "/wd4291", # no matching operator delete found;
425 # memory will not be freed if initialization throws an
426 # exception
427
428 # These only show up in shared builds:
429 "/wd4251", # class 'type' needs to have dll-interface to be used by
430 # clients of class 'type2'
431 "/wd4275", # non dll-interface class 'base' used as base for
432 # dll-interface class 'derived'
433
434 # This triggers incorrectly in SkColor.h. See also:
435 # https://developercommunity.visualstudio.com/t/incorrect-divide-by-0-warning-c4723/1703482
436 "/wd4723", # potential divide by 0
437
438 # It'd be nice to fix these and turn this on:
439 "/wd5041", # out-of-line definition for constexpr static data member is
440 # not needed and is deprecated in C++17
441 ]
442 if (is_clang) {
443 cflags += [
444 "-Wno-unused-parameter", # Re-enabled for header sources
445 "-Wno-switch-default", # Warns even when all enum values are covered
446 ]
447 }
448 } else {
449 cflags += [
450 "-Wall",
451 "-Wextra",
452 "-Winit-self",
453 "-Wpointer-arith",
454 "-Wsign-compare",
455 "-Wvla",
456
457 "-Wno-deprecated-declarations",
458 "-Wno-maybe-uninitialized",
459 "-Wno-psabi",
460 "-Wno-switch-default", # Warns even when all enum values are covered
461 "-Wno-unused-parameter", # Re-enabled for header sources
462 ]
463 cflags_cc += [
464 "-Wnon-virtual-dtor",
465 "-Wno-noexcept-type",
466 ]
467 }
468
469 if (is_clang) {
470 cflags += [
471 "-fcolor-diagnostics",
472 "-Weverything",
473 "-Wno-unknown-warning-option", # Let older Clangs ignore newer Clangs'
474 # warnings.
475
476 # This was deprecated in Clang 14 and removed in Clang 15. It might still
477 # fire with older Clangs, so disable it explicitly.
478 "-Wno-weak-template-vtables",
479 ]
480
481 # See https://crbug.com/1042470: This flag prevents implicit conversions among vector types.
482 # This also gives behavior closer to GCC's default. However:
483 # - clang-cl doesn't recognize the flag
484 # - The (old) Mac/iOS SDK used on the bots breaks this rule in various headers
485 # TODO: Re-enable on Apple when we update XCode
486 if (!is_win && !is_apple && current_cpu != "loong64") {
487 cflags += [ "-fno-lax-vector-conversions" ]
488 }
489
490 if (current_cpu == "arm" && is_ios) {
491 # Clang seems to think new/malloc will only be 4-byte aligned on 32-bit iOS.
492 # We're pretty sure it's actually 8-byte alignment.
493 cflags += [ "-Wno-over-aligned" ]
494 }
495 if (current_cpu == "x86" && is_android) {
496 # Clang seems to think new/malloc will only be 4-byte aligned on 32-bit x86 Android builds.
497 # We're pretty sure it's actually 8-byte alignment. See OverAlignedTest.cpp for more info.
498 cflags += [ "-Wno-over-aligned" ]
499 }
500
501 # Shouldn't be necessary for local builds. With distributed Windows builds, files may lose
502 # their case during copy, causing case-sensitivity mismatch on remote machines.
503 cflags += [
504 "-Wno-nonportable-include-path",
505 "-Wno-nonportable-system-include-path",
506 ]
507
508 # TODO: These would all be really great warnings to turn on.
509 cflags += [
510 "-Wno-cast-align",
511 "-Wno-conversion", # -Wsign-conversion and -Wshorten-64-to-32,
512 # are re-enabled for header sources
513 "-Wno-disabled-macro-expansion",
514 "-Wno-documentation",
515 "-Wno-documentation-unknown-command",
516 "-Wno-double-promotion",
517 "-Wno-exit-time-destructors", # TODO: OK outside libskia
518 "-Wno-float-equal",
519 "-Wno-global-constructors", # TODO: OK outside libskia
520 "-Wno-missing-prototypes",
521 "-Wno-missing-variable-declarations",
522 "-Wno-pedantic",
523 "-Wno-reserved-id-macro",
524 "-Wno-reserved-identifier",
525 "-Wno-signed-enum-bitfield",
526 "-Wno-switch-enum",
527 "-Wno-thread-safety-negative",
528 "-Wno-undef",
529 "-Wno-unreachable-code-break",
530 "-Wno-unreachable-code-return",
531 "-Wno-unused-macros",
532 "-Wno-unused-member-function",
533 "-Wno-non-c-typedef-for-linkage", # Dawn, not Skia per se.
534
535 # We would like to fix this, otherwise it could cause runtime issues
536 # when compiled for WASM.
537 # https://github.com/emscripten-core/emscripten/issues/16126
538 "-Wno-cast-function-type-strict",
539 ]
540 cflags_cc += [
541 "-Wno-abstract-vbase-init",
542 "-Wno-weak-vtables",
543 ]
544
545 # We are unlikely to want to fix these.
546 cflags += [
547 "-Wno-covered-switch-default",
548 "-Wno-deprecated",
549 "-Wno-missing-noreturn",
550 "-Wno-old-style-cast",
551 "-Wno-newline-eof",
552 "-Wno-padded",
553 "-Wno-return-std-move-in-c++11", # we no longer support C++11, and don't
554 # need C++11-only performance warnings
555 "-Wno-shadow-field-in-constructor",
556 "-Wno-shadow-uncaptured-local",
557 "-Wno-zero-as-null-pointer-constant", # VK_NULL_HANDLE is defined as 0
558 "-Wno-declaration-after-statement",
559 "-Wno-unsafe-buffer-usage", # Treats most array accesses as warnings
560
561 # https://quuxplusone.github.io/blog/2020/08/26/wrange-loop-analysis/
562 # https://bugzilla.mozilla.org/show_bug.cgi?id=1683213
563 # https://reviews.llvm.org/D73007
564 # May be re-enabled once clang > 12 or XCode > 12 are required.
565 # When this line is removed the -Wrange-loop-construct line below can also be removed.
566 "-Wno-range-loop-analysis",
567 ]
568 cflags_cc += [
569 "-Wno-c++98-compat",
570 "-Wno-c++98-compat-pedantic",
571 "-Wno-undefined-func-template",
572 "-Wc++98-compat-extra-semi",
573 ]
574 cflags_objc += [
575 "-Wno-direct-ivar-access",
576 "-Wno-objc-interface-ivars",
577 ]
578 cflags_objcc += [
579 "-Wno-direct-ivar-access",
580 "-Wno-objcc-interface-ivars",
581 ]
582
583 # Wno-range-loop-analysis turns off the whole group, but this warning was later split into
584 # range-loop-construct and range-loop-bind-reference. We want the former but not the latter.
585 # Created from clang/include/clang/Basic/DiagnosticGroups.td
586 cflags += [ "-Wrange-loop-construct" ]
587
588 # Wno-deprecated turns off the whole group, but also has its own warnings like
589 # out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated [-Werror,-Wdeprecated]
590 # but we would like others. Created from clang/include/clang/Basic/DiagnosticGroups.td
591 cflags += [
592 "-Wdeprecated-anon-enum-enum-conversion",
593 "-Wdeprecated-array-compare",
594 "-Wdeprecated-attributes",
595 "-Wdeprecated-comma-subscript",
596 "-Wdeprecated-copy",
597 "-Wdeprecated-copy-dtor",
598
599 #"-Wdeprecated-declarations",
600 "-Wdeprecated-dynamic-exception-spec",
601 "-Wdeprecated-enum-compare",
602 "-Wdeprecated-enum-compare-conditional",
603 "-Wdeprecated-enum-enum-conversion",
604 "-Wdeprecated-enum-float-conversion",
605 "-Wdeprecated-increment-bool",
606 "-Wdeprecated-register",
607 "-Wdeprecated-this-capture",
608 "-Wdeprecated-volatile",
609 "-Wdeprecated-writable-str",
610 "-Wextra-semi",
611 ]
612 }
613
614 # !is_clang is a proxy for gcc.
615 if (!is_clang && !is_win) {
616 cflags += [
617 "-Wno-unreachable-code", # Causes false positives in old GCC; removed
618 # from modern GCC entirely
619 ]
620 cflags_cc += [
621 "-Wno-dangling-reference", # Attempt at borrow checker in C++.
622 # Warns on temporary views, like Span.
623 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107532
624 ]
625 }
626
627 cflags_objcc += cflags_cc
628 }
629
630 config("warnings_for_public_headers") {
631 if (is_clang) {
632 cflags = [
633 "-Wsign-conversion",
634 "-Wunused-parameter",
635 "-Wshorten-64-to-32",
636 ]
637 }
638 }
639
640 config("extra_flags") {
641 # extra_flags only applies to the default toolchain (usually the target).
642 if (current_toolchain == default_toolchain) {
643 asmflags = extra_asmflags
644 cflags = extra_cflags
645 cflags_c = extra_cflags_c
646 cflags_cc = extra_cflags_cc
647 ldflags = extra_ldflags
648 }
649 }
650
651 config("debug_symbols") {
652 # It's annoying to wait for full debug symbols to push over
653 # to Android devices. -gline-tables-only is a lot slimmer.
654 if (is_android) {
655 cflags = [
656 "-gline-tables-only",
657 "-funwind-tables", # Helps make in-process backtraces fuller.
658 ]
659 } else if (is_win) {
660 cflags = [ "/Z7" ]
661 if (is_clang) {
662 cflags += [ "-gcodeview-ghash" ]
663 ldflags = [ "/DEBUG:GHASH" ]
664 } else {
665 ldflags = [ "/DEBUG:FASTLINK" ]
666 }
667 } else {
668 cflags = [
669 "-g",
670 "-gdwarf-4", # older versions of addr2line do not work well with v5
671 ]
672 }
673 }
674
675 config("no_rtti") {
676 # -fsanitize=vptr requires RTTI which is enabled as a part of
677 # -fsanitize=undefined
678 if (sanitize != "ASAN") {
679 if (is_win) {
680 cflags_cc = [ "/GR-" ]
681 } else {
682 cflags_cc = [ "-fno-rtti" ]
683 cflags_objcc = cflags_cc
684 }
685 }
686 }
687
688 config("optimize") {
689 ldflags = []
690 if (is_win) {
691 cflags = [
692 "/O2",
693 "/Zc:inline",
694 ]
695 if (skia_enable_optimize_size) {
696 cflags += [ "/Os" ]
697 }
698 ldflags += [
699 "/OPT:ICF",
700 "/OPT:REF",
701 ]
702 } else {
703 if (skia_enable_optimize_size) {
704 cflags = [ "-Oz" ]
705 if (!is_android) {
706 cflags += [
707 # Clang 15 turns PIE (Position-indendendent Executable) on by default.
708 "-fno-PIE",
709 "-fno-pie",
710 ]
711 ldflags += [ "-no-pie" ]
712 }
713 } else {
714 cflags = [ "-O3" ]
715 }
716 if (is_mac || is_ios) {
717 ldflags += [ "-dead_strip" ]
718 } else if (!is_wasm) {
719 cflags += [
720 "-fdata-sections",
721 "-ffunction-sections",
722 ]
723 ldflags += [ "-Wl,--gc-sections" ]
724 }
725 }
726 }
727
728 config("NDEBUG") {
729 defines = [ "NDEBUG" ]
730 }
731
732 config("trivial_abi") {
733 if (is_clang) {
734 defines = [ "SK_TRIVIAL_ABI=[[clang::trivial_abi]]" ]
735 }
736 }
737
738 # PartitionAlloc, Chrome, and many other C++ projects are written assuming
739 # different types may freely point to the same location in memory. This is
740 # undefined behavior in C/C++. With `-fstrict-aliasing`, some compiler will
741 # optimize code in a way that would crash those projects.
742 #
743 # As of 2024, only GCC is aggressive about strict aliasing. Clang isn't.
744 config("strict_aliasing") {
745 if (!is_win) {
746 cflags = [ "-fstrict-aliasing" ]
747 }
748 }
749 config("no_strict_aliasing") {
750 if (!is_win) {
751 cflags = [ "-fno-strict-aliasing" ]
752 }
753 }
754
755 config("executable") {
756 if (is_android) {
757 ldflags = [
758 "-pie",
759 "-rdynamic",
760 ]
761 } else if (is_mac) {
762 ldflags = [ "-Wl,-rpath,@loader_path/." ]
763 } else if (is_linux) {
764 ldflags = [
765 "-rdynamic",
766 "-Wl,-rpath,\$ORIGIN",
767 ]
768 } else if (is_win) {
769 ldflags = [
770 "/SUBSYSTEM:CONSOLE", # Quiet "no subsystem specified; CONSOLE assumed".
771 "/INCREMENTAL:NO", # Quiet warnings about failing to incrementally link
772 # by never trying to.
773 ]
774 }
775 }