Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Side by Side Diff: build/config/compiler/BUILD.gn

Issue 2385643004: Enables GN build on windows (Closed)
Patch Set: Add .gitignore for build Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import("//build/config/android/config.gni") 5 import("//build/config/android/config.gni")
6 if (current_cpu == "arm") { 6 if (current_cpu == "arm") {
7 import("//build/config/arm.gni") 7 import("//build/config/arm.gni")
8 } 8 }
9 if (current_cpu == "mipsel" || current_cpu == "mips64el") { 9 if (current_cpu == "mipsel" || current_cpu == "mips64el") {
10 import("//build/config/mips.gni") 10 import("//build/config/mips.gni")
11 } 11 }
12 if (is_posix) { 12 if (is_posix) {
13 import("//build/config/gcc/gcc_version.gni") 13 import("//build/config/gcc/gcc_version.gni")
14 } 14 }
15 if (is_win) { 15 if (is_win) {
16 import("//build/config/win/visual_studio_version.gni") 16 import("//build/config/win/visual_studio_version.gni")
17 } 17 }
18 18
19 import("//build/toolchain/ccache.gni") 19 import("//build/toolchain/ccache.gni")
20 import("//build/config/sanitizers/sanitizers.gni") 20 import("//build/config/sanitizers/sanitizers.gni")
21 21
22 declare_args() {
23 if (is_win) {
24 # Whether the VS xtree header has been patched to disable warning 4702. If
25 # it has, then we don't need to disable 4702 (unreachable code warning).
26 # The patch is preapplied to the internal toolchain and hence all bots.
27 msvs_xtree_patched = false
28 }
29 }
30
31 # default_include_dirs --------------------------------------------------------- 22 # default_include_dirs ---------------------------------------------------------
32 # 23 #
33 # This is a separate config so that third_party code (which would not use the 24 # This is a separate config so that third_party code (which would not use the
34 # source root and might have conflicting versions of some headers) can remove 25 # source root and might have conflicting versions of some headers) can remove
35 # this and specify their own include paths. 26 # this and specify their own include paths.
36 config("default_include_dirs") { 27 config("default_include_dirs") {
37 include_dirs = [ 28 include_dirs = [
38 "//", 29 "//",
39 root_gen_dir, 30 root_gen_dir,
40 ] 31 ]
41 } 32 }
42 33
43 # TODO(GYP): is_ubsan, is_ubsan_vptr
44 if (!is_win) { 34 if (!is_win) {
45 using_sanitizer = is_asan || is_lsan || is_tsan || is_msan 35 using_sanitizer = is_asan || is_lsan || is_tsan || is_msan
46 } 36 }
47 37
48 # compiler --------------------------------------------------------------------- 38 # compiler ---------------------------------------------------------------------
49 # 39 #
50 # Base compiler configuration. 40 # Base compiler configuration.
51 # 41 #
52 # See also "runtime_library" below for related stuff and a discussion about 42 # See also "runtime_library" below for related stuff and a discussion about
53 # where stuff should go. Put warning related stuff in the "warnings" config. 43 # where stuff should go. Put warning related stuff in the "warnings" config.
(...skipping 12 matching lines...) Expand all
66 # GCC flags, and then we handle the other non-Windows platforms specifically 56 # GCC flags, and then we handle the other non-Windows platforms specifically
67 # below. 57 # below.
68 if (is_win) { 58 if (is_win) {
69 # Windows compiler flags setup. 59 # Windows compiler flags setup.
70 # ----------------------------- 60 # -----------------------------
71 cflags += [ 61 cflags += [
72 "/Gy", # Enable function-level linking. 62 "/Gy", # Enable function-level linking.
73 "/GS", # Enable buffer security checking. 63 "/GS", # Enable buffer security checking.
74 "/FS", # Preserve previous PDB behavior. 64 "/FS", # Preserve previous PDB behavior.
75 ] 65 ]
76
77 # Building with Clang on Windows is a work in progress and very
78 # experimental. See crbug.com/82385.
79 # Keep this in sync with the similar block in build/common.gypi
80 if (is_clang) {
81 cflags += [
82 # Many files use intrinsics without including this header.
83 # TODO(hans): Fix those files, or move this to sub-GYPs.
84 "/FIIntrin.h",
85 ]
86
87 if (visual_studio_version == "2013") {
88 cflags += [ "-fmsc-version=1800" ]
89 } else if (visual_studio_version == "2015") {
90 cflags += [ "-fmsc-version=1900" ]
91 }
92
93 if (current_cpu == "x86") {
94 cflags += [
95 "/fallback",
96 "-m32",
97 ]
98 } else {
99 cflags += [ "-m64" ]
100 }
101 if (exec_script("//build/win/use_ansi_codes.py", [], "trim string") ==
102 "True") {
103 cflags += [
104 # cmd.exe doesn't understand ANSI escape codes by default,
105 # so only enable them if something emulating them is around.
106 "-fansi-escape-codes",
107 ]
108 }
109 }
110 } else { 66 } else {
111 # Common GCC compiler flags setup. 67 # Common GCC compiler flags setup.
112 # -------------------------------- 68 # --------------------------------
113 common_flags = [ 69 common_flags = [
114 # Not exporting C++ inline functions can generally be applied anywhere 70 # Not exporting C++ inline functions can generally be applied anywhere
115 # so we do so here. Normal function visibility is controlled by 71 # so we do so here. Normal function visibility is controlled by
116 # //build/config/gcc:symbol_visibility_hidden. 72 # //build/config/gcc:symbol_visibility_hidden.
117 "-fvisibility-inlines-hidden", 73 "-fvisibility-inlines-hidden",
118 74
119 # We need the frame pointer for CPU and heap profiling. 75 # We need the frame pointer for CPU and heap profiling.
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 cflags = [ "-mfpu=$arm_fpu" ] 419 cflags = [ "-mfpu=$arm_fpu" ]
464 } 420 }
465 } 421 }
466 422
467 # runtime_library ------------------------------------------------------------- 423 # runtime_library -------------------------------------------------------------
468 # 424 #
469 # Sets the runtime library and associated options. 425 # Sets the runtime library and associated options.
470 # 426 #
471 # How do you determine what should go in here vs. "compiler" above? Consider if 427 # How do you determine what should go in here vs. "compiler" above? Consider if
472 # a target might choose to use a different runtime library (ignore for a moment 428 # a target might choose to use a different runtime library (ignore for a moment
473 # if this is possible or reasonable on your system). If such a target would want 429 # if this is possible or reasonable on your system). If such a target would
474 # to change or remove your option, put it in the runtime_library config. If a 430 # want to change or remove your option, put it in the runtime_library config.
475 # target wants the option regardless, put it in the compiler config. 431 # If a target wants the option regardless, put it in the compiler config.
476 432
477 config("runtime_library") { 433 config("runtime_library") {
478 cflags = [] 434 cflags = []
479 defines = [] 435 defines = []
480 ldflags = [] 436 ldflags = []
481 lib_dirs = [] 437 lib_dirs = []
482 libs = [] 438 libs = []
483 439
484 if (is_component_build) { 440 # Static CRT.
485 # Component mode: dynamic CRT. 441 if (is_win) {
486 defines += [ "COMPONENT_BUILD" ] 442 if (is_debug) {
487 if (is_win) { 443 cflags += [ "/MTd" ]
488 # Since the library is shared, it requires exceptions or will give errors 444 } else {
489 # about things not matching, so keep exceptions on. 445 cflags += [ "/MT" ]
490 if (is_debug) {
491 cflags += [ "/MDd" ]
492 } else {
493 cflags += [ "/MD" ]
494 }
495 } 446 }
496 } else {
497 # Static CRT.
498 if (is_win) {
499 if (is_debug) {
500 cflags += [ "/MTd" ]
501 } else {
502 cflags += [ "/MT" ]
503 }
504 }
505 }
506
507 if (is_win) {
508 defines += [ 447 defines += [
509 "__STD_C", 448 "__STD_C",
510 "_CRT_RAND_S", 449 "_CRT_RAND_S",
511 "_CRT_SECURE_NO_DEPRECATE", 450 "_CRT_SECURE_NO_DEPRECATE",
512 "_HAS_EXCEPTIONS=0", 451 "_HAS_EXCEPTIONS=0",
513 "_SCL_SECURE_NO_DEPRECATE", 452 "_SCL_SECURE_NO_DEPRECATE",
514 ] 453 ]
515 } 454 }
516 455
517 # Android standard library setup. 456 # Android standard library setup.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 } 522 }
584 523
585 # default_warning_flags collects all warning flags that are used by default. 524 # default_warning_flags collects all warning flags that are used by default.
586 # This is in a variable instead of a config so that it can be used in 525 # This is in a variable instead of a config so that it can be used in
587 # both chromium_code and no_chromium_code. This way these flags are guaranteed 526 # both chromium_code and no_chromium_code. This way these flags are guaranteed
588 # to appear on the compile command line after -Wall. 527 # to appear on the compile command line after -Wall.
589 528
590 default_warning_flags = [] 529 default_warning_flags = []
591 default_warning_flags_cc = [] 530 default_warning_flags_cc = []
592 if (is_win) { 531 if (is_win) {
593 if (!is_clang || current_cpu != "x86") { 532 if (current_cpu != "x86") {
594 default_warning_flags += [ "/WX" ] # Treat warnings as errors. 533 default_warning_flags += [ "/WX" ] # Treat warnings as errors.
595 } 534 }
596 535
597 default_warning_flags += [ 536 default_warning_flags += [
598 # Warnings permanently disabled: 537 # Permanent.
599 538 "/wd4091", # typedef warning from dbghelp.h
600 # TODO(GYP) The GYP build doesn't have this globally enabled but disabled 539 # Investigate.
601 # for a bunch of individual targets. Re-enable this globally when those 540 "/wd4312", # int to pointer of greater size conversion.
602 # targets are fixed. 541 "/wd4838", # Narrowing conversion required.
603 "/wd4018", # Comparing signed and unsigned values. 542 "/wd4172", # Returning address of local.
604 543 "/wd4005", # Redefinition of macros for PRId64 etc.
605 # C4127: conditional expression is constant 544 "/wd4311", # Pointer truncation from PVOID to DWORD.
606 # This warning can in theory catch dead code and other problems, but 545 "/wd4477", # Format string requires wchar_t*
607 # triggers in far too many desirable cases where the conditional
608 # expression is either set by macros or corresponds some legitimate
609 # compile-time constant expression (due to constant template args,
610 # conditionals comparing the sizes of different types, etc.). Some of
611 # these can be worked around, but it's not worth it.
612 "/wd4127",
613
614 # C4251: 'identifier' : class 'type' needs to have dll-interface to be
615 # used by clients of class 'type2'
616 # This is necessary for the shared library build.
617 "/wd4251",
618
619 # C4351: new behavior: elements of array 'array' will be default
620 # initialized
621 # This is a silly "warning" that basically just alerts you that the
622 # compiler is going to actually follow the language spec like it's
623 # supposed to, instead of not following it like old buggy versions did.
624 # There's absolutely no reason to turn this on.
625 "/wd4351",
626
627 # C4355: 'this': used in base member initializer list
628 # It's commonly useful to pass |this| to objects in a class' initializer
629 # list. While this warning can catch real bugs, most of the time the
630 # constructors in question don't attempt to call methods on the passed-in
631 # pointer (until later), and annotating every legit usage of this is
632 # simply more hassle than the warning is worth.
633 "/wd4355",
634
635 # C4503: 'identifier': decorated name length exceeded, name was
636 # truncated
637 # This only means that some long error messages might have truncated
638 # identifiers in the presence of lots of templates. It has no effect on
639 # program correctness and there's no real reason to waste time trying to
640 # prevent it.
641 "/wd4503",
642
643 # Warning C4589 says: "Constructor of abstract class ignores
644 # initializer for virtual base class." Disable this warning because it
645 # is flaky in VS 2015 RTM. It triggers on compiler generated
646 # copy-constructors in some cases.
647 "/wd4589",
648
649 # C4611: interaction between 'function' and C++ object destruction is
650 # non-portable
651 # This warning is unavoidable when using e.g. setjmp/longjmp. MSDN
652 # suggests using exceptions instead of setjmp/longjmp for C++, but
653 # Chromium code compiles without exception support. We therefore have to
654 # use setjmp/longjmp for e.g. JPEG decode error handling, which means we
655 # have to turn off this warning (and be careful about how object
656 # destruction happens in such cases).
657 "/wd4611",
658
659 # Warnings to evaluate and possibly fix/reenable later:
660
661 "/wd4100", # Unreferenced formal function parameter.
662 "/wd4121", # Alignment of a member was sensitive to packing.
663 "/wd4244", # Conversion: possible loss of data.
664 "/wd4481", # Nonstandard extension: override specifier.
665 "/wd4505", # Unreferenced local function has been removed.
666 "/wd4510", # Default constructor could not be generated.
667 "/wd4512", # Assignment operator could not be generated.
668 "/wd4610", # Class can never be instantiated, constructor required.
669 "/wd4996", # Deprecated function warning.
670 ] 546 ]
671
672 # VS xtree header file needs to be patched or 4702 (unreachable code
673 # warning) is reported if _HAS_EXCEPTIONS=0. Disable the warning if xtree is
674 # not patched.
675 if (!msvs_xtree_patched &&
676 exec_script("../../win_is_xtree_patched.py", [], "value") == 0) {
677 default_warning_flags += [ "/wd4702" ] # Unreachable code.
678 }
679
680 # Building with Clang on Windows is a work in progress and very
681 # experimental. See crbug.com/82385.
682 # Keep this in sync with the similar block in build/common.gypi
683 if (is_clang) {
684 default_warning_flags += [
685 # TODO(hans): Make this list shorter eventually, http://crbug.com/504657
686 "-Qunused-arguments", # http://crbug.com/504658
687 "-Wno-microsoft", # http://crbug.com/505296
688 "-Wno-switch", # http://crbug.com/505308
689 "-Wno-unknown-pragmas", # http://crbug.com/505314
690 "-Wno-unused-function", # http://crbug.com/505316
691 "-Wno-unused-value", # http://crbug.com/505318
692 "-Wno-unused-local-typedef", # http://crbug.com/411648
693 ]
694 }
695 } else { 547 } else {
696 # Common GCC warning setup. 548 # Common GCC warning setup.
697 default_warning_flags += [ 549 default_warning_flags += [
698 # Enables. 550 # Enables.
699 "-Wendif-labels", # Weird old-style text after an #endif. 551 "-Wendif-labels", # Weird old-style text after an #endif.
700 552
701 # Disables. 553 # Disables.
702 "-Wno-missing-field-initializers", # "struct foo f = {0};" 554 "-Wno-missing-field-initializers", # "struct foo f = {0};"
703 "-Wno-unused-parameter", # Unused function parameters. 555 "-Wno-unused-parameter", # Unused function parameters.
704 ] 556 ]
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 } 602 }
751 } 603 }
752 604
753 # chromium_code --------------------------------------------------------------- 605 # chromium_code ---------------------------------------------------------------
754 # 606 #
755 # Toggles between higher and lower warnings for code that is (or isn't) 607 # Toggles between higher and lower warnings for code that is (or isn't)
756 # part of Chromium. 608 # part of Chromium.
757 609
758 config("chromium_code") { 610 config("chromium_code") {
759 if (is_win) { 611 if (is_win) {
760 cflags = [ "/W4" ] # Warning level 4. 612 # TODO(zra): Enable higher warning levels.
613 # cflags = [ "/W4" ] # Warning level 4.
614 cflags = []
761 } else { 615 } else {
762 cflags = [ 616 cflags = [
763 "-Wall", 617 "-Wall",
764 "-Wextra", 618 "-Wextra",
765 "-Werror", 619 "-Werror",
766 ] 620 ]
767 621
768 defines = [] 622 defines = []
769 if (!using_sanitizer && (!is_linux || !is_clang)) { 623 if (!using_sanitizer && (!is_linux || !is_clang)) {
770 # _FORTIFY_SOURCE isn't really supported by Clang now, see 624 # _FORTIFY_SOURCE isn't really supported by Clang now, see
771 # http://llvm.org/bugs/show_bug.cgi?id=16821. 625 # http://llvm.org/bugs/show_bug.cgi?id=16821.
772 # It seems to work fine with Ubuntu 12 headers though, so use it in 626 # It seems to work fine with Ubuntu 12 headers though, so use it in
773 # official builds. 627 # official builds.
774 # 628 #
775 # Non-chromium code is not guaranteed to compile cleanly with 629 # Non-chromium code is not guaranteed to compile cleanly with
776 # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are 630 # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are
777 # disabled, so only do that for Release build. 631 # disabled, so only do that for Release build.
778 defines += [ "_FORTIFY_SOURCE=2" ] 632 defines += [ "_FORTIFY_SOURCE=2" ]
779 } 633 }
780 } 634 }
781 cflags += default_warning_flags 635 cflags += default_warning_flags
782 cflags_cc = default_warning_flags_cc 636 cflags_cc = default_warning_flags_cc
783 } 637 }
784 config("no_chromium_code") { 638 config("no_chromium_code") {
785 cflags = [] 639 cflags = []
786 cflags_cc = [] 640 cflags_cc = []
787 defines = [] 641 defines = []
788 642
789 if (is_win) { 643 if (is_win) {
790 cflags += [
791 "/W3", # Warning level 3.
792 "/wd4800", # Disable warning when forcing value to bool.
793 "/wd4267", # TODO(jschuh): size_t to int.
794 "/wd4996", # Deprecated function warning.
795 ]
796 defines += [ 644 defines += [
797 "_CRT_NONSTDC_NO_WARNINGS", 645 "_CRT_NONSTDC_NO_WARNINGS",
798 "_CRT_NONSTDC_NO_DEPRECATE", 646 "_CRT_NONSTDC_NO_DEPRECATE",
799 ] 647 ]
800 } 648 }
801 649
802 cflags += default_warning_flags 650 cflags += default_warning_flags
803 cflags_cc += default_warning_flags_cc 651 cflags_cc += default_warning_flags_cc
804 } 652 }
805 653
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. 791 cflags = [ "/Zi" ] # Produce PDB file, no edit and continue.
944 } 792 }
945 ldflags = [ "/DEBUG" ] 793 ldflags = [ "/DEBUG" ]
946 } else { 794 } else {
947 cflags = [ 795 cflags = [
948 "-g3", 796 "-g3",
949 "-ggdb3", 797 "-ggdb3",
950 ] 798 ]
951 } 799 }
952 } 800 }
OLDNEW
« no previous file with comments | « build/config/BUILDCONFIG.gn ('k') | build/config/win/BUILD.gn » ('j') | utils/invoke_dart.gni » ('J')

Powered by Google App Engine
This is Rietveld 408576698