123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- Subject: Update support for ThinLTO, Mold LTO, and Gold LTO. (For 16.x to 17.x)
- Author: Orson Teodoro <orsonteodoro@hotmail.com
- Date: Fri Feb 4 10:41:12 PM PST 2022 (Unix time: 1644043272)
- Patch status: Testing
- diff -urp node-v16.13.2.orig/common.gypi node-v16.13.2/common.gypi
- --- node-v16.13.2.orig/common.gypi 2022-02-04 21:37:23.667470037 -0800
- +++ node-v16.13.2/common.gypi 2022-02-04 22:00:56.500753953 -0800
- @@ -177,8 +177,18 @@
- }],
- ['llvm_version=="0.0"', {
- 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', # GCC
- - }, {
- - 'lto': ' -flto ', # Clang
- + }],
- + ['llvm_version!="0.0" and with_goldlto=="true"', {
- + 'lto': ' -flto', # Clang Gold LTO
- + }],
- + ['llvm_version!="0.0" and with_moldlto=="true"', {
- + 'lto': ' -flto', # Mold LTO
- + }],
- + ['llvm_version!="0.0" and with_thinlto=="true"', {
- + 'lto': ' -flto=thin', # Clang ThinLTO
- + }],
- + ['llvm_version!="0.0" and with_goldlto=="false" and with_thinlto=="false" and with_mold=="false"', {
- + 'lto': ' -flto', # Clang with system default
- }],
- ],
- },
- @@ -190,6 +194,21 @@
- 'LLVM_LTO': 'YES',
- },
- }],
- + ['OS=="linux" and with_moldlto=="true"', {
- + 'ldflags': [
- + '-fuse-ld=mold',
- + ],
- + }],
- + ['OS=="linux" and with_thinlto=="true"', {
- + 'ldflags': [
- + '-fuse-ld=lld',
- + ],
- + }],
- + ['OS=="linux" and (with_goldlto=="true" or node_section_ordering_info!="")', {
- + 'ldflags': [
- + '-fuse-ld=gold',
- + ],
- + }],
- ['OS=="linux"', {
- 'conditions': [
- ['node_section_ordering_info!=""', {
- @@ -198,7 +212,6 @@
- '-ffunction-sections',
- ],
- 'ldflags': [
- - '-fuse-ld=gold',
- '-Wl,--section-ordering-file=<(node_section_ordering_info)',
- ],
- }],
- diff -urp node-v16.13.2.orig/configure.py node-v16.13.2/configure.py
- --- node-v16.13.2.orig/configure.py 2022-01-10 13:33:29.000000000 -0800
- +++ node-v16.13.2/configure.py 2022-02-04 22:00:58.260824431 -0800
- @@ -540,6 +540,24 @@ parser.add_argument('--use-section-order
- 'Node.js be linked using the gold linker. The gold linker must have ' +
- 'version 1.2 or greater.')
-
- +parser.add_argument('--with-goldlto',
- + action='store_true',
- + dest='with_goldlto',
- + default=None,
- + help='Use Gold LTO')
- +
- +parser.add_argument('--with-moldlto',
- + action='store_true',
- + dest='with_moldlto',
- + default=None,
- + help='Use Mold LTO')
- +
- +parser.add_argument('--with-thinlto',
- + action='store_true',
- + dest='with_thinlto',
- + default=None,
- + help='Use ThinLTO and LLD')
- +
- intl_optgroup.add_argument('--with-intl',
- action='store',
- dest='with_intl',
- @@ -1344,6 +1350,23 @@ def configure_node(o):
- print('Warning! Loading builtin modules from disk is for development')
- o['variables']['node_builtin_modules_path'] = options.node_builtin_modules_path
-
- + o['variables']['with_goldlto'] = 'false'
- + o['variables']['with_moldlto'] = 'false'
- + o['variables']['with_thinlto'] = 'false'
- + if options.enable_lto:
- + if options.with_goldlto and options.with_moldlto:
- + error('''with_goldlto and with_moldlto cannot both be enabled''')
- + if options.with_thinlto and options.with_goldlto:
- + error('''with_thinlto and with_goldlto cannot both be enabled''')
- + if options.with_thinlto and options.with_moldlto:
- + error('''with_thinlto and with_moldlto cannot both be enabled''')
- + if options.with_goldlto:
- + o['variables']['with_goldlto'] = 'true'
- + elif options.with_moldlto:
- + o['variables']['with_moldlto'] = 'true'
- + elif options.with_thinlto:
- + o['variables']['with_thinlto'] = 'true'
- +
- def configure_napi(output):
- version = getnapibuildversion.get_napi_version()
- output['variables']['napi_build_version'] = version
- @@ -1825,6 +1841,10 @@ def configure_inspector(o):
- o['variables']['v8_enable_inspector'] = 0 if disable_inspector else 1
-
- def configure_section_file(o):
- + if options.with_thinlto and options.node_section_ordering_info != "":
- + error('''node_section_ordering_info cannot be combined with thinlto''')
- + if options.with_moldlto and options.node_section_ordering_info != "":
- + error('''node_section_ordering_info cannot be combined with moldlto''')
- try:
- proc = subprocess.Popen(['ld.gold'] + ['-v'], stdin = subprocess.PIPE,
- stdout = subprocess.PIPE, stderr = subprocess.PIPE)
- @@ -1843,7 +1861,7 @@ def configure_section_file(o):
- error('''GNU gold version must be greater than 1.2 in order to use section
- reordering''')
-
- - if options.node_section_ordering_info != "":
- + if options.node_section_ordering_info != "" and options.with_thinlto == None and options.with_moldlto == None:
- o['variables']['node_section_ordering_info'] = os.path.realpath(
- str(options.node_section_ordering_info))
- else:
|