Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7dc6b2f

Browse filesBrowse files
Gabriel Schulhofdanielleadams
authored andcommitted
build: add support for section ordering
Adds support for using a section ordering file with the gold linker. This makes it possible to reorder functions in a build to optimize for a specific workload. `hfsort` is a tool that can be used to generate such a file from perf- recorded last branch record (LBR) data by running Node.js as `node --perf-basic-prof`. Refs: https://github.com/facebook/hhvm/tree/9966d482c19c6120c621c6f3896525fb19fb3842/hphp/tools/hfsort Refs: https://software.intel.com/content/www/us/en/develop/articles/runtime-optimization-blueprint-IA-optimization-with-last-branch-record.html Refs: #16891 Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com> PR-URL: #35272 Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
1 parent a4e5a3a commit 7dc6b2f
Copy full SHA for 7dc6b2f

File tree

Expand file treeCollapse file tree

2 files changed

+49
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+49
-0
lines changed
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@
111111
['target_arch in "ppc64 s390x"', {
112112
'v8_enable_backtrace': 1,
113113
}],
114+
['OS=="linux"', {
115+
'node_section_ordering_info%': ''
116+
}]
114117
],
115118
},
116119

@@ -172,6 +175,20 @@
172175
},
173176
'cflags': [ '-O3' ],
174177
'conditions': [
178+
['OS=="linux"', {
179+
'conditions': [
180+
['node_section_ordering_info!=""', {
181+
'cflags': [
182+
'-fuse-ld=gold',
183+
'-ffunction-sections',
184+
],
185+
'ldflags': [
186+
'-fuse-ld=gold',
187+
'-Wl,--section-ordering-file=<(node_section_ordering_info)',
188+
],
189+
}],
190+
],
191+
}],
175192
['OS=="solaris"', {
176193
# pull in V8's postmortem metadata
177194
'ldflags': [ '-Wl,-z,allextract' ]
Collapse file

‎configure.py‎

Copy file name to clipboardExpand all lines: configure.py
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,14 @@
455455
dest='node_use_large_pages_script_lld',
456456
help='This option has no effect. --use-largepages is now a runtime option.')
457457

458+
parser.add_option('--use-section-ordering-file',
459+
action='store',
460+
dest='node_section_ordering_info',
461+
default='',
462+
help='Pass a section ordering file to the linker. This requires that ' +
463+
'Node.js be linked using the gold linker. The gold linker must have ' +
464+
'version 1.2 or greater.')
465+
458466
intl_optgroup.add_option('--with-intl',
459467
action='store',
460468
dest='with_intl',
@@ -1709,6 +1717,29 @@ def configure_inspector(o):
17091717
options.without_ssl)
17101718
o['variables']['v8_enable_inspector'] = 0 if disable_inspector else 1
17111719

1720+
def configure_section_file(o):
1721+
try:
1722+
proc = subprocess.Popen(['ld.gold'] + ['-v'], stdin = subprocess.PIPE,
1723+
stdout = subprocess.PIPE, stderr = subprocess.PIPE)
1724+
except OSError:
1725+
warn('''No acceptable ld.gold linker found!''')
1726+
return 0
1727+
1728+
match = re.match(r"^GNU gold.*([0-9]+)\.([0-9]+)$",
1729+
proc.communicate()[0].decode("utf-8"))
1730+
1731+
if match:
1732+
gold_major_version = match.group(1)
1733+
gold_minor_version = match.group(2)
1734+
if int(gold_major_version) == 1 and int(gold_minor_version) <= 1:
1735+
error('''GNU gold version must be greater than 1.2 in order to use section
1736+
reordering''')
1737+
1738+
if options.node_section_ordering_info != "":
1739+
o['variables']['node_section_ordering_info'] = os.path.realpath(
1740+
str(options.node_section_ordering_info))
1741+
else:
1742+
o['variables']['node_section_ordering_info'] = ""
17121743

17131744
def make_bin_override():
17141745
if sys.platform == 'win32':
@@ -1774,6 +1805,7 @@ def make_bin_override():
17741805
configure_intl(output)
17751806
configure_static(output)
17761807
configure_inspector(output)
1808+
configure_section_file(output)
17771809

17781810
# Forward OSS-Fuzz settings
17791811
output['variables']['ossfuzz'] = b(options.ossfuzz)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.