diff mbox series

[meta-oe] nodejs: extend libatomic patch to x86

Message ID 20260204085730.2441346-1-skandigraun@gmail.com
State New
Headers show
Series [meta-oe] nodejs: extend libatomic patch to x86 | expand

Commit Message

Gyorgy Sarvari Feb. 4, 2026, 8:57 a.m. UTC
This patch isn't intended to introduce new behavior, rather it
changes the order of some existing LDFLAGS to fix a workaround that
stopped working at some point in the past.

LDFLAGS:x86 contains libatomic, because linking with this library
is required for this platform.

However when gyp links, it invokes the following (pseudo-)command:
$LD $LDFLAGS $RESOURCES_TO_LINK $EXTRA_LIBS $EXTRA_LDFLAGS

The EXTRA* arguments are coming from the gyp config. Since
LDFLAGS appears very early in the command, libatomic also
appears early amongst the resources, and the linker couldn't
find the relevant symbols when compiled for x86 platform (as
it was processed the very last):

| [...] undefined reference to `__atomic_compare_exchange'

Using this patch the library appears at the end, along with
the other EXTRA_LIBS, after the list of linked resources,
allowing linking to succeed.

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
---
 .../nodejs/nodejs/libatomic.patch             | 29 +++++++++++++++----
 .../recipes-devtools/nodejs/nodejs_22.22.0.bb |  2 --
 2 files changed, 24 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/meta-oe/recipes-devtools/nodejs/nodejs/libatomic.patch b/meta-oe/recipes-devtools/nodejs/nodejs/libatomic.patch
index d987ac50be..835c7018de 100644
--- a/meta-oe/recipes-devtools/nodejs/nodejs/libatomic.patch
+++ b/meta-oe/recipes-devtools/nodejs/nodejs/libatomic.patch
@@ -17,6 +17,10 @@  Fix:
 Upstream-Status: Inappropriate [OE specific]
 
 Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+
+Added libatomic library explicitly to x86 targets.
+
+Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
 ---
  node.gyp                 | 13 ++++++++++++-
  tools/v8_gypfiles/v8.gyp | 15 ++++++++++++---
@@ -26,7 +30,7 @@  diff --git a/node.gyp b/node.gyp
 index b425f443..f296f35c 100644
 --- a/node.gyp
 +++ b/node.gyp
-@@ -487,7 +487,18 @@
+@@ -503,7 +503,18 @@
          ],
        }],
        ['OS=="linux" and clang==1', {
@@ -50,7 +54,7 @@  diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp
 index b23263cf..dcabf4ca 100644
 --- a/tools/v8_gypfiles/v8.gyp
 +++ b/tools/v8_gypfiles/v8.gyp
-@@ -1100,9 +1100,18 @@
+@@ -1348,9 +1348,18 @@
          # Platforms that don't have Compare-And-Swap (CAS) support need to link atomic library
          # to implement atomic memory access
          ['v8_current_cpu in ["mips64", "mips64el", "ppc", "arm", "riscv64", "loong64"]', {
@@ -72,6 +76,21 @@  index b23263cf..dcabf4ca 100644
          }],
        ],
      },  # v8_base_without_compiler
--- 
-2.35.5
-
+diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp
+index cb82d4f15bc..65cb123b7bf 100644
+--- a/tools/v8_gypfiles/v8.gyp
++++ b/tools/v8_gypfiles/v8.gyp
+@@ -1820,6 +1820,13 @@
+         ['enable_lto=="true"', {
+           'ldflags': [ '-fno-lto' ],
+         }],
++        # For future patch-rebases: this hunk is in mksnapshot target.
++        # ia32 includes x86 also
++        ['v8_target_arch=="ia32"', {
++          'link_settings': {
++            'libraries': ['-latomic']
++          }
++        }],
+       ],
+     },  # mksnapshot
+     {
diff --git a/meta-oe/recipes-devtools/nodejs/nodejs_22.22.0.bb b/meta-oe/recipes-devtools/nodejs/nodejs_22.22.0.bb
index 1ef01cc3b2..b3a4fb4245 100644
--- a/meta-oe/recipes-devtools/nodejs/nodejs_22.22.0.bb
+++ b/meta-oe/recipes-devtools/nodejs/nodejs_22.22.0.bb
@@ -133,8 +133,6 @@  python do_create_v8_qemu_wrapper () {
 do_create_v8_qemu_wrapper[dirs] = "${B}"
 addtask create_v8_qemu_wrapper after do_configure before do_compile
 
-LDFLAGS:append:x86 = " -latomic"
-
 export CC_host
 export CFLAGS_host
 export CXX_host