Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nodejs dtrace build with newer binutils #1350

Merged
merged 1 commit into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions build/nodejs/patches-12/genv8constants.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

Since GNU binutils 2.41, gobjdump does not include .bss sections in disassembly
output, even with -z.

https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=0a3137ce4c4b38ee8

To work around this while still supporting older versions of binutils, we
need to extract a list of sections and pass them all to objdump via -j.

Opened upstream as: https://github.com/nodejs/node/issues/49991
Along with a PR at: https://github.com/nodejs/node/pull/49992

--- src/tools/genv8constants.py~ 2023-10-01 11:12:26.882863767 +0000
+++ src/tools/genv8constants.py 2023-10-01 11:12:30.311739683 +0000
@@ -18,20 +18,46 @@
sys.exit(2)

outfile = open(sys.argv[1], 'w')
-try:
- pipe = subprocess.Popen([ 'objdump', '-z', '-D', sys.argv[2] ],
- bufsize=-1, stdout=subprocess.PIPE).stdout
-except OSError as e:
- if e.errno == errno.ENOENT:
- print('''
- Node.js compile error: could not find objdump
-
- Check that GNU binutils are installed and included in PATH
- ''')
- else:
- print('problem running objdump: ', e.strerror)

- sys.exit()
+def objdump(filename, opts):
+ try:
+ pipe = subprocess.Popen([ 'objdump' ] + opts + [ filename ],
+ bufsize=-1, stdout=subprocess.PIPE).stdout
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ print('''
+ Node.js compile error: could not find objdump
+
+ Check that GNU binutils are installed and included in PATH
+ ''')
+ else:
+ print('problem running objdump: ', e.strerror)
+
+ sys.exit()
+
+ return pipe
+
+# Since GNU binutils 2.41, gobjdump does not include .bss sections in
+# disassembly output, even with -z.
+# https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=0a3137ce4c4b38ee8
+# To work around this while still supporting older versions of binutils, we
+# need to extract a list of sections and pass them all to objdump via -j.
+
+sections = set()
+pattern = re.compile(r'^\s+\d+\s+(\.\S+)')
+pipe = objdump(sys.argv[2], [ '-h' ])
+for line in pipe:
+ line = line.decode('utf-8')
+ match = pattern.match(line)
+ if match is None:
+ continue
+ sections.add(str(match.group(1)))
+
+opts = [ '-z', '-D' ]
+for section in sections:
+ opts.extend([ '-j', section ])
+
+pipe = objdump(sys.argv[2], opts)

pattern = re.compile('([0-9a-fA-F]{8}|[0-9a-fA-F]{16}) <(.*)>:')
v8dbg = re.compile('^v8dbg.*$')
1 change: 1 addition & 0 deletions build/nodejs/patches-12/series
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
madvise.patch
genv8constants.patch
74 changes: 74 additions & 0 deletions build/nodejs/patches-14/genv8constants.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

Since GNU binutils 2.41, gobjdump does not include .bss sections in disassembly
output, even with -z.

https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=0a3137ce4c4b38ee8

To work around this while still supporting older versions of binutils, we
need to extract a list of sections and pass them all to objdump via -j.

Opened upstream as: https://github.com/nodejs/node/issues/49991
Along with a PR at: https://github.com/nodejs/node/pull/49992

--- src/tools/genv8constants.py~ 2023-10-01 11:12:26.882863767 +0000
+++ src/tools/genv8constants.py 2023-10-01 11:12:30.311739683 +0000
@@ -18,20 +18,46 @@
sys.exit(2)

outfile = open(sys.argv[1], 'w')
-try:
- pipe = subprocess.Popen([ 'objdump', '-z', '-D', sys.argv[2] ],
- bufsize=-1, stdout=subprocess.PIPE).stdout
-except OSError as e:
- if e.errno == errno.ENOENT:
- print('''
- Node.js compile error: could not find objdump
-
- Check that GNU binutils are installed and included in PATH
- ''')
- else:
- print('problem running objdump: ', e.strerror)

- sys.exit()
+def objdump(filename, opts):
+ try:
+ pipe = subprocess.Popen([ 'objdump' ] + opts + [ filename ],
+ bufsize=-1, stdout=subprocess.PIPE).stdout
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ print('''
+ Node.js compile error: could not find objdump
+
+ Check that GNU binutils are installed and included in PATH
+ ''')
+ else:
+ print('problem running objdump: ', e.strerror)
+
+ sys.exit()
+
+ return pipe
+
+# Since GNU binutils 2.41, gobjdump does not include .bss sections in
+# disassembly output, even with -z.
+# https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=0a3137ce4c4b38ee8
+# To work around this while still supporting older versions of binutils, we
+# need to extract a list of sections and pass them all to objdump via -j.
+
+sections = set()
+pattern = re.compile(r'^\s+\d+\s+(\.\S+)')
+pipe = objdump(sys.argv[2], [ '-h' ])
+for line in pipe:
+ line = line.decode('utf-8')
+ match = pattern.match(line)
+ if match is None:
+ continue
+ sections.add(str(match.group(1)))
+
+opts = [ '-z', '-D' ]
+for section in sections:
+ opts.extend([ '-j', section ])
+
+pipe = objdump(sys.argv[2], opts)

pattern = re.compile('([0-9a-fA-F]{8}|[0-9a-fA-F]{16}) <(.*)>:')
v8dbg = re.compile('^v8dbg.*$')
1 change: 1 addition & 0 deletions build/nodejs/patches-14/series
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
madvise.patch
python3.11.patch
genv8constants.patch
74 changes: 74 additions & 0 deletions build/nodejs/patches-16/genv8constants.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

Since GNU binutils 2.41, gobjdump does not include .bss sections in disassembly
output, even with -z.

https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=0a3137ce4c4b38ee8

To work around this while still supporting older versions of binutils, we
need to extract a list of sections and pass them all to objdump via -j.

Opened upstream as: https://github.com/nodejs/node/issues/49991
Along with a PR at: https://github.com/nodejs/node/pull/49992

--- src/tools/genv8constants.py~ 2023-10-01 11:12:26.882863767 +0000
+++ src/tools/genv8constants.py 2023-10-01 11:12:30.311739683 +0000
@@ -18,20 +18,46 @@
sys.exit(2)

outfile = open(sys.argv[1], 'w')
-try:
- pipe = subprocess.Popen([ 'objdump', '-z', '-D', sys.argv[2] ],
- bufsize=-1, stdout=subprocess.PIPE).stdout
-except OSError as e:
- if e.errno == errno.ENOENT:
- print('''
- Node.js compile error: could not find objdump
-
- Check that GNU binutils are installed and included in PATH
- ''')
- else:
- print('problem running objdump: ', e.strerror)

- sys.exit()
+def objdump(filename, opts):
+ try:
+ pipe = subprocess.Popen([ 'objdump' ] + opts + [ filename ],
+ bufsize=-1, stdout=subprocess.PIPE).stdout
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ print('''
+ Node.js compile error: could not find objdump
+
+ Check that GNU binutils are installed and included in PATH
+ ''')
+ else:
+ print('problem running objdump: ', e.strerror)
+
+ sys.exit()
+
+ return pipe
+
+# Since GNU binutils 2.41, gobjdump does not include .bss sections in
+# disassembly output, even with -z.
+# https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=0a3137ce4c4b38ee8
+# To work around this while still supporting older versions of binutils, we
+# need to extract a list of sections and pass them all to objdump via -j.
+
+sections = set()
+pattern = re.compile(r'^\s+\d+\s+(\.\S+)')
+pipe = objdump(sys.argv[2], [ '-h' ])
+for line in pipe:
+ line = line.decode('utf-8')
+ match = pattern.match(line)
+ if match is None:
+ continue
+ sections.add(str(match.group(1)))
+
+opts = [ '-z', '-D' ]
+for section in sections:
+ opts.extend([ '-j', section ])
+
+pipe = objdump(sys.argv[2], opts)

pattern = re.compile('([0-9a-fA-F]{8}|[0-9a-fA-F]{16}) <(.*)>:')
v8dbg = re.compile('^v8dbg.*$')
1 change: 1 addition & 0 deletions build/nodejs/patches-16/series
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mmaphint.patch
libuv-portrace.patch
madvise.patch
genv8constants.patch
74 changes: 74 additions & 0 deletions build/nodejs/patches-18/genv8constants.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

Since GNU binutils 2.41, gobjdump does not include .bss sections in disassembly
output, even with -z.

https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=0a3137ce4c4b38ee8

To work around this while still supporting older versions of binutils, we
need to extract a list of sections and pass them all to objdump via -j.

Opened upstream as: https://github.com/nodejs/node/issues/49991
Along with a PR at: https://github.com/nodejs/node/pull/49992

--- src/tools/genv8constants.py~ 2023-10-01 11:12:26.882863767 +0000
+++ src/tools/genv8constants.py 2023-10-01 11:12:30.311739683 +0000
@@ -18,20 +18,46 @@
sys.exit(2)

outfile = open(sys.argv[1], 'w')
-try:
- pipe = subprocess.Popen([ 'objdump', '-z', '-D', sys.argv[2] ],
- bufsize=-1, stdout=subprocess.PIPE).stdout
-except OSError as e:
- if e.errno == errno.ENOENT:
- print('''
- Node.js compile error: could not find objdump
-
- Check that GNU binutils are installed and included in PATH
- ''')
- else:
- print('problem running objdump: ', e.strerror)

- sys.exit()
+def objdump(filename, opts):
+ try:
+ pipe = subprocess.Popen([ 'objdump' ] + opts + [ filename ],
+ bufsize=-1, stdout=subprocess.PIPE).stdout
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ print('''
+ Node.js compile error: could not find objdump
+
+ Check that GNU binutils are installed and included in PATH
+ ''')
+ else:
+ print('problem running objdump: ', e.strerror)
+
+ sys.exit()
+
+ return pipe
+
+# Since GNU binutils 2.41, gobjdump does not include .bss sections in
+# disassembly output, even with -z.
+# https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=0a3137ce4c4b38ee8
+# To work around this while still supporting older versions of binutils, we
+# need to extract a list of sections and pass them all to objdump via -j.
+
+sections = set()
+pattern = re.compile(r'^\s+\d+\s+(\.\S+)')
+pipe = objdump(sys.argv[2], [ '-h' ])
+for line in pipe:
+ line = line.decode('utf-8')
+ match = pattern.match(line)
+ if match is None:
+ continue
+ sections.add(str(match.group(1)))
+
+opts = [ '-z', '-D' ]
+for section in sections:
+ opts.extend([ '-j', section ])
+
+pipe = objdump(sys.argv[2], opts)

pattern = re.compile('([0-9a-fA-F]{8}|[0-9a-fA-F]{16}) <(.*)>:')
v8dbg = re.compile('^v8dbg.*$')
1 change: 1 addition & 0 deletions build/nodejs/patches-18/series
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mmaphint.patch
madvise-remove-own-declaration.patch
netinet-in.h.patch
genv8constants.patch
Loading