nodejs: extend libatomic patch to x86

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>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Gyorgy Sarvari 2026-02-04 09:57:30 +01:00 committed by Khem Raj
parent 5ff9251b94
commit bfbd962813
No known key found for this signature in database
GPG Key ID: BB053355919D3314
2 changed files with 24 additions and 7 deletions

View File

@ -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
{

View File

@ -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