From ab59f6930622815437e554c3eb8e823c04b469e7 Mon Sep 17 00:00:00 2001
From: Andreas Wacknitz <A.Wacknitz@gmx.de>
Date: Sun, 10 Dec 2023 14:08:17 +0100
Subject: [PATCH] nodejs-16: update to 16.20.2

---
 components/runtime/node16/Makefile                        |    4 +-
 components/runtime/node16/patches/03-genv8constants.patch |   74 +++++++++++++++++++++++++++++++++++++
 components/runtime/node16/pkg5                            |    2 
 3 files changed, 77 insertions(+), 3 deletions(-)

diff --git a/components/runtime/node16/Makefile b/components/runtime/node16/Makefile
index 0822367..70a245d 100644
--- a/components/runtime/node16/Makefile
+++ b/components/runtime/node16/Makefile
@@ -16,12 +16,12 @@
 
 COMPONENT_NAME=			node
 COMPONENT_MAJOR_VERSION=16
-COMPONENT_VERSION=		$(COMPONENT_MAJOR_VERSION).20.1
+COMPONENT_VERSION=		$(COMPONENT_MAJOR_VERSION).20.2
 COMPONENT_SUMMARY=		Evented I/O for V8 JavaScript
 COMPONENT_PROJECT_URL=	https://nodejs.org
 COMPONENT_SRC=			$(COMPONENT_NAME)-v$(COMPONENT_VERSION)
 COMPONENT_ARCHIVE=		$(COMPONENT_SRC).tar.xz
-COMPONENT_ARCHIVE_HASH= sha256:83e03381e271f1a5619188e7aea9d85d9b7e12f5be2a28ceb78d7249ed22b7f1
+COMPONENT_ARCHIVE_HASH= sha256:576f1a03c455e491a8d132b587eb6b3b84651fc8974bb3638433dd44d22c8f49
 COMPONENT_ARCHIVE_URL=	$(COMPONENT_PROJECT_URL)/dist/v$(COMPONENT_VERSION)/$(COMPONENT_ARCHIVE)
 COMPONENT_FMRI=			runtime/nodejs-$(COMPONENT_MAJOR_VERSION)
 COMPONENT_CLASSIFICATION=	Development/Other Languages
diff --git a/components/runtime/node16/patches/03-genv8constants.patch b/components/runtime/node16/patches/03-genv8constants.patch
new file mode 100644
index 0000000..57b615a
--- /dev/null
+++ b/components/runtime/node16/patches/03-genv8constants.patch
@@ -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.*$')
diff --git a/components/runtime/node16/pkg5 b/components/runtime/node16/pkg5
index b9f8c7f..7c27f37 100644
--- a/components/runtime/node16/pkg5
+++ b/components/runtime/node16/pkg5
@@ -3,7 +3,7 @@
         "SUNWcs",
         "runtime/python-39",
         "system/library",
-        "system/library/g++-10-runtime",
+        "system/library/g++-13-runtime",
         "system/library/math"
     ],
     "fmris": [

--
Gitblit v1.9.3