GeezerVison is showing github.com — build,win: enable x64 PGO · nodejs/node@2551abd
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: common.gypi +60Lines changed: 60 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 12 | 12 | 'msvs_multi_core_compile': '0', # we do enable multicore compiles, but not using the V8 way | 13 | 13 | 'enable_pgo_generate%': '0', | 14 | 14 | 'enable_pgo_use%': '0', | | 15 | + 'clang_profile_lib%': '', | 15 | 16 | 'python%': 'python', | 16 | 17 |
| 17 | 18 | 'node_shared%': 'false', | | 246 | 247 | },], | 247 | 248 | ], | 248 | 249 | },], | | 250 | + ['OS=="win"', { | | 251 | + 'conditions': [ | | 252 | + ['enable_lto=="true"', { | | 253 | + 'msvs_settings': { | | 254 | + 'VCCLCompilerTool': { | | 255 | + 'AdditionalOptions': ['-flto=full'], | | 256 | + }, | | 257 | + 'VCLibrarianTool': { | | 258 | + 'AdditionalOptions': ['-flto=full'], | | 259 | + }, | | 260 | + 'VCLinkerTool': { | | 261 | + 'AdditionalOptions': ['-flto=full'], | | 262 | + }, | | 263 | + }, | | 264 | + },], | | 265 | + ['enable_thin_lto=="true"', { | | 266 | + 'msvs_settings': { | | 267 | + 'VCCLCompilerTool': { | | 268 | + 'AdditionalOptions': ['-flto=thin'], | | 269 | + }, | | 270 | + 'VCLibrarianTool': { | | 271 | + 'AdditionalOptions': ['-flto=thin'], | | 272 | + }, | | 273 | + 'VCLinkerTool': { | | 274 | + 'AdditionalOptions': ['-flto=thin'], | | 275 | + }, | | 276 | + }, | | 277 | + },], | | 278 | + ], | | 279 | + 'target_conditions': [ | | 280 | + ['_toolset=="target"', { | | 281 | + 'conditions': [ | | 282 | + ['enable_pgo_generate=="true"', { | | 283 | + 'msvs_settings': { | | 284 | + 'VCCLCompilerTool': { | | 285 | + 'AdditionalOptions': ['-fprofile-generate'], | | 286 | + }, | | 287 | + 'VCLinkerTool': { | | 288 | + 'AdditionalOptions': [ | | 289 | + '/NODEFAULTLIB:clang_rt.profile.lib', | | 290 | + '"<(clang_profile_lib)"', | | 291 | + ], | | 292 | + }, | | 293 | + }, | | 294 | + },], | | 295 | + ['enable_pgo_use=="true"', { | | 296 | + 'msvs_settings': { | | 297 | + 'VCCLCompilerTool': { | | 298 | + 'AdditionalOptions': ['-fprofile-use=$(SolutionDir)node.profdata'], | | 299 | + }, | | 300 | + 'VCLinkerTool': { | | 301 | + 'AdditionalOptions': ['-fprofile-use=$(SolutionDir)node.profdata'], | | 302 | + }, | | 303 | + }, | | 304 | + },], | | 305 | + ], | | 306 | + },], | | 307 | + ], | | 308 | + },], | 249 | 309 | ['OS == "android"', { | 250 | 310 | 'cflags': [ '-fPIC', '-I<(android_ndk_path)/sources/android/cpufeatures' ], | 251 | 311 | 'ldflags': [ '-fPIC' ] | |
Collapse file Copy file name to clipboardExpand all lines: configure.py +57-14Lines changed: 57 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 202 | 202 | dest="enable_pgo_generate", | 203 | 203 | default=None, | 204 | 204 | help="Enable profiling with pgo of a binary. This feature is only available " | 205 | | - "on linux with gcc and g++ 5.4.1 or newer.") | | 205 | + "on linux with gcc and g++ 5.4.1 or newer and on windows.") | 206 | 206 |
| 207 | 207 | parser.add_argument("--enable-pgo-use", | 208 | 208 | action="store_true", | 209 | 209 | dest="enable_pgo_use", | 210 | 210 | default=None, | 211 | 211 | help="Enable use of the profile generated with --enable-pgo-generate. This " | 212 | | - "feature is only available on linux with gcc and g++ 5.4.1 or newer.") | | 212 | + "feature is only available on linux with gcc and g++ 5.4.1 or newer and on windows.") | 213 | 213 |
| 214 | 214 | parser.add_argument("--enable-lto", | 215 | 215 | action="store_true", | | 218 | 218 | help="Enable compiling with lto of a binary. This feature is only available " | 219 | 219 | "with gcc 5.4.1+ or clang 3.9.1+.") | 220 | 220 |
| | 221 | +parser.add_argument("--enable-thin-lto", | | 222 | + action="store_true", | | 223 | + dest="enable_thin_lto", | | 224 | + default=None, | | 225 | + help="Enable compiling with thin lto of a binary. This feature is only available " | | 226 | + "on windows.") | | 227 | + | 221 | 228 | parser.add_argument("--link-module", | 222 | 229 | action="append", | 223 | 230 | dest="linked_module", | | 859 | 866 | action='store_true', | 860 | 867 | dest='with_ltcg', | 861 | 868 | default=None, | 862 | | - help='Use Link Time Code Generation. This feature is only available on Windows.') | | 869 | + help='Use Thin LTO scoped to node.exe and libnode only. ' | | 870 | + 'This feature is only available on Windows.') | 863 | 871 |
| 864 | 872 | parser.add_argument('--write-snapshot-as-array-literals', | 865 | 873 | action='store_true', | @@ -1712,9 +1720,9 @@ def configure_node(o): | 1712 | 1720 | else: | 1713 | 1721 | o['variables']['node_enable_v8_vtunejit'] = 'false' | 1714 | 1722 |
| 1715 | | - if flavor != 'linux' and (options.enable_pgo_generate or options.enable_pgo_use): | | 1723 | + if (flavor != 'linux' and flavor != 'win') and (options.enable_pgo_generate or options.enable_pgo_use): | 1716 | 1724 | raise Exception( | 1717 | | - 'The pgo option is supported only on linux.') | | 1725 | + 'The pgo option is supported only on linux and windows.') | 1718 | 1726 |
| 1719 | 1727 | if flavor == 'linux': | 1720 | 1728 | if options.enable_pgo_generate or options.enable_pgo_use: | @@ -1725,21 +1733,55 @@ def configure_node(o): | 1725 | 1733 | 'The options --enable-pgo-generate and --enable-pgo-use ' | 1726 | 1734 | f'are supported for gcc and gxx {version_checked_str} or newer only.') | 1727 | 1735 |
| 1728 | | - if options.enable_pgo_generate and options.enable_pgo_use: | 1729 | | - raise Exception( | 1730 | | - 'Only one of the --enable-pgo-generate or --enable-pgo-use options ' | 1731 | | - 'can be specified at a time. You would like to use ' | 1732 | | - '--enable-pgo-generate first, profile node, and then recompile ' | 1733 | | - 'with --enable-pgo-use') | | 1736 | + if options.enable_pgo_generate and options.enable_pgo_use: | | 1737 | + raise Exception( | | 1738 | + 'Only one of the --enable-pgo-generate or --enable-pgo-use options ' | | 1739 | + 'can be specified at a time. You would like to use ' | | 1740 | + '--enable-pgo-generate first, profile node, and then recompile ' | | 1741 | + 'with --enable-pgo-use') | 1734 | 1742 |
| 1735 | 1743 | o['variables']['enable_pgo_generate'] = b(options.enable_pgo_generate) | 1736 | 1744 | o['variables']['enable_pgo_use'] = b(options.enable_pgo_use) | 1737 | 1745 |
| 1738 | | - if flavor == 'win' and (options.enable_lto): | | 1746 | + if flavor == 'win' and (options.enable_pgo_generate or options.enable_pgo_use): | | 1747 | + lib_suffix = 'aarch64' if target_arch == 'arm64' else 'x86_64' | | 1748 | + lib_name = f'clang_rt.profile-{lib_suffix}.lib' | | 1749 | + msvc_dir = target_arch # 'x64' or 'arm64' | | 1750 | + | | 1751 | + vc_tools_dir = os.environ.get('VCToolsInstallDir', '') | | 1752 | + if vc_tools_dir: | | 1753 | + clang_profile_lib = os.path.join(vc_tools_dir, 'lib', msvc_dir, lib_name) | | 1754 | + if os.path.isfile(clang_profile_lib): | | 1755 | + o['variables']['clang_profile_lib'] = clang_profile_lib | | 1756 | + else: | | 1757 | + raise Exception( | | 1758 | + f'PGO profile runtime library not found at {clang_profile_lib}. ' | | 1759 | + 'Ensure the ClangCL toolset is installed.') | | 1760 | + else: | | 1761 | + raise Exception( | | 1762 | + 'VCToolsInstallDir not set. Run from a Visual Studio command prompt.') | | 1763 | + | | 1764 | + if flavor != 'win' and options.enable_thin_lto: | 1739 | 1765 | raise Exception( | 1740 | | - 'Use Link Time Code Generation instead.') | | 1766 | + 'Use --enable-lto instead.') | | 1767 | + | | 1768 | + # LTO mutual exclusion | | 1769 | + if flavor == 'win': | | 1770 | + lto_options = [] | | 1771 | + if options.enable_lto: | | 1772 | + lto_options.append('--enable-lto') | | 1773 | + if options.enable_thin_lto: | | 1774 | + lto_options.append('--enable-thin-lto') | | 1775 | + if options.with_ltcg: | | 1776 | + lto_options.append('--with-ltcg') | | 1777 | + if len(lto_options) > 1: | | 1778 | + raise Exception( | | 1779 | + f'Only one LTO option can be specified at a time: {", ".join(lto_options)}. ' | | 1780 | + 'Use --enable-lto for Full LTO (global), ' | | 1781 | + '--enable-thin-lto for Thin LTO (global), ' | | 1782 | + 'or --with-ltcg for Thin LTO (scoped to node.exe and libnode).') | 1741 | 1783 |
| 1742 | | - if options.enable_lto: | | 1784 | + if options.enable_lto and flavor != 'win': | 1743 | 1785 | gcc_version_checked = (5, 4, 1) | 1744 | 1786 | clang_version_checked = (3, 9, 1) | 1745 | 1787 | if not gcc_version_ge(gcc_version_checked) and not clang_version_ge(clang_version_checked): | @@ -1750,6 +1792,7 @@ def configure_node(o): | 1750 | 1792 | f'or clang {clang_version_checked_str}+ only.') | 1751 | 1793 |
| 1752 | 1794 | o['variables']['enable_lto'] = b(options.enable_lto) | | 1795 | + o['variables']['enable_thin_lto'] = b(options.enable_thin_lto) | 1753 | 1796 |
| 1754 | 1797 | if options.node_use_large_pages or options.node_use_large_pages_script_lld: | 1755 | 1798 | warn('''The `--use-largepages` and `--use-largepages-script-lld` options | |
Collapse file Copy file name to clipboardExpand all lines: deps/openssl/openssl-cli.gypi +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 25 | 25 | ['enable_lto=="true"', { | 26 | 26 | 'ldflags': [ '-fno-lto' ], | 27 | 27 | }], | | 28 | + ['node_with_ltcg=="true" or enable_lto=="true" or enable_thin_lto=="true"', { | | 29 | + 'msvs_settings': { | | 30 | + 'VCCLCompilerTool': { | | 31 | + 'AdditionalOptions': ['-fno-lto'], | | 32 | + }, | | 33 | + 'VCLinkerTool': { | | 34 | + 'AdditionalOptions': ['-fno-lto'], | | 35 | + }, | | 36 | + }, | | 37 | + }], | 28 | 38 | ], | 29 | 39 | } |
Collapse file Copy file name to clipboardExpand all lines: deps/openssl/openssl.gyp +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 77 | 77 | ['enable_lto=="true"', { | 78 | 78 | 'ldflags': [ '-fno-lto' ], | 79 | 79 | }], | | 80 | + ['node_with_ltcg=="true" or enable_lto=="true" or enable_thin_lto=="true"', { | | 81 | + 'msvs_settings': { | | 82 | + 'VCCLCompilerTool': { | | 83 | + 'AdditionalOptions': ['-fno-lto'], | | 84 | + }, | | 85 | + 'VCLinkerTool': { | | 86 | + 'AdditionalOptions': ['-fno-lto'], | | 87 | + }, | | 88 | + }, | | 89 | + }], | 80 | 90 | ] | 81 | 91 | }, { | 82 | 92 | # openssl-fipsmodule target | |
Collapse file Copy file name to clipboardExpand all lines: node.gyp +65-15Lines changed: 65 additions & 15 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 697 | 697 | 'Ws2_32.lib', | 698 | 698 | ], | 699 | 699 | }], | | 700 | + # Thin LTO for node_main.cc and linker (scoped to node_exe) | 700 | 701 | ['node_with_ltcg=="true"', { | 701 | 702 | 'msvs_settings': { | 702 | 703 | 'VCCLCompilerTool': { | 703 | | - 'WholeProgramOptimization': 'true' # /GL, whole program optimization, needed for LTCG | | 704 | + 'AdditionalOptions': ['-flto=thin'], | 704 | 705 | }, | 705 | | - 'VCLibrarianTool': { | 706 | | - 'AdditionalOptions': [ | 707 | | - '/LTCG:INCREMENTAL', # link time code generation | 708 | | - ], | | 706 | + 'VCLinkerTool': { | | 707 | + 'AdditionalOptions': ['-flto=thin'], | 709 | 708 | }, | | 709 | + }, | | 710 | + }], | | 711 | + # Whole-program optimization: either Thin LTO or PGO | | 712 | + ['node_with_ltcg=="true" or enable_lto=="true" or enable_thin_lto=="true" or enable_pgo_generate=="true" or enable_pgo_use=="true"', { | | 713 | + 'msvs_settings': { | 710 | 714 | 'VCLinkerTool': { | 711 | 715 | 'OptimizeReferences': 2, # /OPT:REF | 712 | 716 | 'EnableCOMDATFolding': 2, # /OPT:ICF | 713 | 717 | 'LinkIncremental': 1, # disable incremental linking | 714 | | - 'AdditionalOptions': [ | 715 | | - '/LTCG:INCREMENTAL', # incremental link-time code generation | 716 | | - ], | 717 | | - } | 718 | | - } | | 718 | + }, | | 719 | + }, | 719 | 720 | }, { | | 721 | + # No whole-program optimization | 720 | 722 | 'msvs_settings': { | 721 | | - 'VCCLCompilerTool': { | 722 | | - 'WholeProgramOptimization': 'false' | 723 | | - }, | 724 | 723 | 'VCLinkerTool': { | 725 | | - 'LinkIncremental': 2 # enable incremental linking | | 724 | + 'LinkIncremental': 2, # enable incremental linking | 726 | 725 | }, | 727 | 726 | }, | 728 | | - }], | | 727 | + }], | 729 | 728 | ['node_use_node_snapshot=="true"', { | 730 | 729 | 'dependencies': [ | 731 | 730 | 'node_mksnapshot', | | 1068 | 1067 | [ 'debug_nghttp2==1', { | 1069 | 1068 | 'defines': [ 'NODE_DEBUG_NGHTTP2=1' ] | 1070 | 1069 | }], | | 1070 | + # Thin LTO for node sources (scoped to libnode, not global) | | 1071 | + ['node_with_ltcg=="true"', { | | 1072 | + 'msvs_settings': { | | 1073 | + 'VCCLCompilerTool': { | | 1074 | + 'AdditionalOptions': ['-flto=thin'], | | 1075 | + }, | | 1076 | + 'VCLibrarianTool': { | | 1077 | + 'AdditionalOptions': ['-flto=thin'], | | 1078 | + }, | | 1079 | + }, | | 1080 | + }], | 1071 | 1081 | ], | 1072 | 1082 | 'actions': [ | 1073 | 1083 | { | | 1366 | 1376 | ['enable_lto=="true"', { | 1367 | 1377 | 'ldflags': [ '-fno-lto' ], | 1368 | 1378 | }], | | 1379 | + ['node_with_ltcg=="true" or enable_lto=="true" or enable_thin_lto=="true"', { | | 1380 | + 'msvs_settings': { | | 1381 | + 'VCCLCompilerTool': { | | 1382 | + 'AdditionalOptions': ['-fno-lto'], | | 1383 | + }, | | 1384 | + 'VCLinkerTool': { | | 1385 | + 'AdditionalOptions': ['-fno-lto'], | | 1386 | + }, | | 1387 | + }, | | 1388 | + }], | 1369 | 1389 | ], | 1370 | 1390 | }, # cctest | 1371 | 1391 |
| | 1430 | 1450 | ['enable_lto=="true"', { | 1431 | 1451 | 'ldflags': [ '-fno-lto' ], | 1432 | 1452 | }], | | 1453 | + ['node_with_ltcg=="true" or enable_lto=="true" or enable_thin_lto=="true"', { | | 1454 | + 'msvs_settings': { | | 1455 | + 'VCCLCompilerTool': { | | 1456 | + 'AdditionalOptions': ['-fno-lto'], | | 1457 | + }, | | 1458 | + 'VCLinkerTool': { | | 1459 | + 'AdditionalOptions': ['-fno-lto'], | | 1460 | + }, | | 1461 | + }, | | 1462 | + }], | 1433 | 1463 | ], | 1434 | 1464 | }, # embedtest | 1435 | 1465 |
| | 1452 | 1482 | ['enable_lto=="true"', { | 1453 | 1483 | 'ldflags': [ '-fno-lto' ], | 1454 | 1484 | }], | | 1485 | + ['node_with_ltcg=="true" or enable_lto=="true" or enable_thin_lto=="true"', { | | 1486 | + 'msvs_settings': { | | 1487 | + 'VCCLCompilerTool': { | | 1488 | + 'AdditionalOptions': ['-fno-lto'], | | 1489 | + }, | | 1490 | + 'VCLinkerTool': { | | 1491 | + 'AdditionalOptions': ['-fno-lto'], | | 1492 | + }, | | 1493 | + }, | | 1494 | + }], | 1455 | 1495 | ] | 1456 | 1496 | }, # overlapped-checker | 1457 | 1497 | { | | 1575 | 1615 | ['enable_lto=="true"', { | 1576 | 1616 | 'ldflags': [ '-fno-lto' ], | 1577 | 1617 | }], | | 1618 | + ['node_with_ltcg=="true" or enable_lto=="true" or enable_thin_lto=="true"', { | | 1619 | + 'msvs_settings': { | | 1620 | + 'VCCLCompilerTool': { | | 1621 | + 'AdditionalOptions': ['-fno-lto'], | | 1622 | + }, | | 1623 | + 'VCLinkerTool': { | | 1624 | + 'AdditionalOptions': ['-fno-lto'], | | 1625 | + }, | | 1626 | + }, | | 1627 | + }], | 1578 | 1628 | ], | 1579 | 1629 | }, # node_mksnapshot | 1580 | 1630 | ], # end targets | |
|