Skip to contentSkip to conversation

ostree: Always use libgcc for runtime with clang on x86

PATCH New Khem Raj 1 participant 7 messages Jul 21, 2025

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/7 ostree: Always use libgcc for runtime with clang on x86

compiler-rt does not have 128-bit int support for 32bit x86

---
 meta-oe/recipes-extended/ostree/ostree_2024.10.bb | 3 +++
 1 file changed, 3 insertions(+)
meta-oe/recipes-extended/ostree/ostree_2024.10.bb +3 -0
index c33624987a..8d3b1cd32e 100644
@@ -118,6 +118,9 @@ SYSROOT_DIR = "${STAGING_DIR_TARGET}"
 SYSROOT_DIR:class-native = "${STAGING_DIR_NATIVE}"
 do_configure[vardeps] += "SYSROOT_DIR"
 
+# i686-yoe-linux-ld.lld: error: undefined symbol: __unordtf2
+LDFLAGS:append:libc-glibc:toolchain-clang:x86 = " --rtlib=libgcc --unwindlib=libgcc"
+
 do_configure:prepend() {
     # this reflects what autogen.sh does, but the OE wrappers for autoreconf
     # allow it to work without the other gyrations which exist there
author
#1 lore raw

PATCH 2/7 libhugetlbfs: Do not add LDFLAGS to compiler

Add LDFLAGS in makefile for linking the helper libraries instead

when linking with LLD it ends up with errors
i686-yoe-linux-clang: warning: -Wl,-O1: 'linker' input unused [-Wunused-command-line-argument]
i686-yoe-linux-clang: warning: -Wl,--hash-style=gnu: 'linker' input unused [-Wunused-command-line-argument]
i686-yoe-linux-clang: warning: -Wl,--as-needed: 'linker' input unused [-Wunused-command-line-argument]

---
 ...s-to-linker-commandline-for-libheaps.patch | 33 +++++++++++++++++++
 .../libhugetlbfs/libhugetlbfs_2.24.bb         |  3 +-
 2 files changed, 34 insertions(+), 2 deletions(-)
 create mode 100644 meta-oe/recipes-benchmark/libhugetlbfs/files/0014-tests-Add-ldflags-to-linker-commandline-for-libheaps.patch
meta-oe/recipes-benchmark/libhugetlbfs/files/0014-tests-Add-ldflags-to-linker-commandline-for-libheaps.patch new file +33 -0
new file mode 100644
index 0000000000..94a88647ea
@@ -0,0 +1,33 @@
+From 834662425936ae222789f4823d10a1371b951ae1 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Sun, 20 Jul 2025 14:19:59 -0700
+Subject: [PATCH] tests: Add ldflags to linker commandline for libheapshrink.so
+
+This fixes build QA errors
+ERROR: libhugetlbfs-1_2.24-r0 do_package_qa: QA Issue: File /usr/lib/libhugetlbfs/tests/obj64/libheapshrink.so in package libhugetlbfs-tests doesn't have GNU_HASH (didn't pass LDFLAGS?) [ldflags]
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <[email protected]>
+---
+ tests/Makefile.in | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/tests/Makefile.in b/tests/Makefile.in
+index d33a228..042af8d 100644
+--- a/tests/Makefile.in
++++ b/tests/Makefile.in
+@@ -140,12 +140,12 @@ obj64/%-pic.o: %.c
+ obj32/libheapshrink.so: obj32/heapshrink-helper-pic.o
+ 	@$(VECHO) LD32 "(shared)" $@
+ 	@mkdir -p obj32
+-	$(CC32) -Wl,-soname,$(notdir $@) -shared -o $@ $^
++	$(CC32) -Wl,-soname,$(notdir $@) -shared $(LDFLAGS) -o $@ $^
+ 
+ obj64/libheapshrink.so: obj64/heapshrink-helper-pic.o
+ 	@$(VECHO) LD64 "(shared)" $@
+ 	@mkdir -p obj64
+-	$(CC64) -Wl,-soname,$(notdir $@) -shared -o $@ $^
++	$(CC64) -Wl,-soname,$(notdir $@) -shared $(LDFLAGS) -o $@ $^
+ 
+ $(LIB_TESTS:%=obj32/%): %: %.o obj32/testutils.o obj32/libtestutils.o
+ 	@$(VECHO) LD32 "(lib test)" $@
meta-oe/recipes-benchmark/libhugetlbfs/libhugetlbfs_2.24.bb +1 -2
index e688d6ede2..a43ddf0d53 100644
@@ -24,6 +24,7 @@ SRC_URI = " \
     file://0011-include-limits.h-for-PATH_MAX.patch \
     file://0012-huge_page_setup_helper-use-python3-interpreter.patch \
     file://0013-elflink.c-include-libgen.h-for-basename.patch \
+    file://0014-tests-Add-ldflags-to-linker-commandline-for-libheaps.patch \
 "
 
 UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>\d+(\.\d+)+)"
@@ -42,8 +43,6 @@ CFLAGS += "-fexpensive-optimizations -frename-registers -fomit-frame-pointer -g0
 
 export HUGETLB_LDSCRIPT_PATH = "${S}/ldscripts"
 
-TARGET_CC_ARCH += "${LDFLAGS}"
-
 LDFLAGS += "-B${S}"
 
 inherit autotools-brokensep
author
#2 lore raw

PATCH 3/7 libhugetlbfs: Always use ligcc for compiler runtime with clang on x86

In reply to Khem Raj

glibc objects here expect libgcc to be linked in sadly compiler-rt does not provide all the needed function implementations e.g. __unordtf2 __letf2, __multf3, __addtf3 needed for 128 bit data types

---
 meta-oe/recipes-benchmark/libhugetlbfs/libhugetlbfs_2.24.bb | 3 +++
 1 file changed, 3 insertions(+)
meta-oe/recipes-benchmark/libhugetlbfs/libhugetlbfs_2.24.bb +3 -0
index a43ddf0d53..0546d4b0b5 100644
@@ -44,6 +44,9 @@ CFLAGS += "-fexpensive-optimizations -frename-registers -fomit-frame-pointer -g0
 export HUGETLB_LDSCRIPT_PATH = "${S}/ldscripts"
 
 LDFLAGS += "-B${S}"
+# glibc objects have missing symbols from libgcc that compiler-rt does not provide
+# /usr/src/debug/glibc/2.41+git/stdio-common/../stdio-common/printf_fphex.c:123:(.text+0x77): undefined reference to `__unordtf2'
+LDFLAGS:append:libc-glibc:toolchain-clang:x86 = " --rtlib=libgcc --unwindlib=libgcc"
 
 inherit autotools-brokensep
 
author
#3 lore raw

PATCH 4/7 tsocks: Always use ligcc for compiler runtime with clang on x86

In reply to Khem Raj
---
 meta-networking/recipes-protocols/tsocks/tsocks_1.8beta5.bb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta-networking/recipes-protocols/tsocks/tsocks_1.8beta5.bb +3 -1
index 2cbb025049..af0823829d 100644
@@ -21,6 +21,9 @@ inherit autotools-brokensep
 LIBS:append:libc-musl = " -lssp_nonshared"
 LIBS:append:libc-glibc = " -lc_nonshared"
 
+# i686-yoe-linux-ld.lld: error: undefined symbol: __unordtf2
+LDFLAGS:append:libc-glibc:toolchain-clang:x86 = " --rtlib=libgcc --unwindlib=libgcc"
+
 S = "${UNPACKDIR}/tsocks-1.8"
 
 FILES:${PN} = "${libdir}/* ${bindir}/tsocks"
@@ -28,4 +31,3 @@ FILES:${PN}-dev = ""
 INSANE_SKIP:${PN} = "dev-so"
 
 EXTRA_OEMAKE = "SHCC='${CC} -fPIC ${LDFLAGS}' LIBS='${LIBS}'"
-
author
#4 lore raw

PATCH 5/7 libc-bench: Always use libgcc runtime with clang on x86

In reply to Khem Raj
---
 meta-oe/recipes-benchmark/libc-bench/libc-bench_git.bb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
meta-oe/recipes-benchmark/libc-bench/libc-bench_git.bb +2 -1
index ae87262870..30313f4315 100644
@@ -16,9 +16,10 @@ SRC_URI = "git://git.musl-libc.org/libc-bench;branch=master \
 # Upstream repo does not tag
 UPSTREAM_CHECK_COMMITS = "1"
 
+# i686-yoe-linux-ld.lld: error: undefined symbol: __addtf3
+LDFLAGS:append:libc-glibc:toolchain-clang:x86 = " --rtlib=libgcc --unwindlib=libgcc"
 
 do_install () {
     install -d ${D}${bindir}
     install -m 0755 ${B}/libc-bench ${D}${bindir}
 }
-
author
#5 lore raw

PATCH 6/7 aufs-util: Always use libgcc as compiler runtime with clang on x86

In reply to Khem Raj
---
 meta-filesystems/recipes-utils/aufs-util/aufs-util_git.bb | 2 ++
 1 file changed, 2 insertions(+)
meta-filesystems/recipes-utils/aufs-util/aufs-util_git.bb +2 -0
index 913b2c1d32..61ec508b43 100644
@@ -21,6 +21,8 @@ UPSTREAM_CHECK_COMMITS = "1"
 
 PV = "4.9+git"
 
+#i686-yoe-linux-ld.bfd: /usr/src/debug/glibc/2.41+git/stdio-common/../stdio-common/printf_fphex.c:123:(.text+0xdf): undefined reference to `__letf2'
+LDFLAGS:append:libc-glibc:toolchain-clang:x86 = " --rtlib=libgcc --unwindlib=libgcc"
 
 export HOSTCC = "${BUILD_CC}"
 do_configure:prepend() {
author
#6 lore raw

PATCH 7/7 nodejs: Fix build on arm64 hosts

In reply to Khem Raj

When clang is used as cross compiler, it confuses gyp system to enable -m64 option for host pieces of build and the reason is that it assumes clang to be biarch by default for all architectures but that maybe true for x86/x86_64 combo but not true for arm/aarch64 systems

This is a backport from node 24

---
 ...ld-remove-redundant-mXX-flags-for-V8.patch | 133 ++++++++++++++++++
 .../recipes-devtools/nodejs/nodejs_22.16.0.bb |   1 +
 2 files changed, 134 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/nodejs/nodejs/0001-build-remove-redundant-mXX-flags-for-V8.patch
meta-oe/recipes-devtools/nodejs/nodejs/0001-build-remove-redundant-mXX-flags-for-V8.patch new file +133 -0
new file mode 100644
index 0000000000..7841a9d7bc
@@ -0,0 +1,133 @@
+From 403264c02edc2689671dbefaf032e3acb4fb713d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= <[email protected]>
+Date: Sat, 19 Apr 2025 12:22:10 +0200
+Subject: [PATCH] build: remove redundant `-mXX` flags for V8
+
+They are already set by `common.gypi`.
+
+
+Needed to build on aarch64 build hosts with clang compiler
+Drop it when upgrading to 0.24.x or newer.
+
+Upstream-Status: Backport [https://github.com/nodejs/node/commit/403264c02edc2689671dbefaf032e3acb4fb713d]
+
+PR-URL: https://github.com/nodejs/node/pull/57907
+Reviewed-By: James M Snell <[email protected]>
+Reviewed-By: Marco Ippolito <[email protected]>
+Reviewed-By: Chengzhong Wu <[email protected]>
+Reviewed-By: Rafael Gonzaga <[email protected]>
+Reviewed-By: Luigi Pinca <[email protected]>
+---
+ tools/v8_gypfiles/toolchain.gypi | 91 --------------------------------
+ 1 file changed, 91 deletions(-)
+
+Index: node-v22.16.0/tools/v8_gypfiles/toolchain.gypi
+===================================================================
+--- node-v22.16.0.orig/tools/v8_gypfiles/toolchain.gypi
++++ node-v22.16.0/tools/v8_gypfiles/toolchain.gypi
+@@ -97,33 +97,6 @@
+     # Indicates if gcmole tools are downloaded by a hook.
+     'gcmole%': 0,
+   },
+-
+-  # [GYP] this needs to be outside of the top level 'variables'
+-  'conditions': [
+-    ['host_arch=="ia32" or host_arch=="x64" or \
+-      host_arch=="ppc" or host_arch=="ppc64" or \
+-      host_arch=="s390x" or \
+-      clang==1', {
+-      'variables': {
+-        'host_cxx_is_biarch%': 1,
+-       },
+-     }, {
+-      'variables': {
+-        'host_cxx_is_biarch%': 0,
+-      },
+-    }],
+-    ['target_arch=="ia32" or target_arch=="x64" or \
+-      target_arch=="ppc" or target_arch=="ppc64" or \
+-      target_arch=="s390x" or clang==1', {
+-      'variables': {
+-        'target_cxx_is_biarch%': 1,
+-       },
+-     }, {
+-      'variables': {
+-        'target_cxx_is_biarch%': 0,
+-      },
+-    }],
+-  ],
+   'target_defaults': {
+     'include_dirs': [
+       '<(V8_ROOT)',
+@@ -553,71 +526,6 @@
+           '-mmmx',  # Allows mmintrin.h for MMX intrinsics.
+         ],
+       }],
+-      ['(OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
+-         or OS=="netbsd" or OS=="mac" or OS=="android" or OS=="qnx") and \
+-        (v8_target_arch=="arm" or v8_target_arch=="ia32" or \
+-         v8_target_arch=="ppc")', {
+-        'target_conditions': [
+-          ['_toolset=="host"', {
+-            'conditions': [
+-              ['host_cxx_is_biarch==1', {
+-                'conditions': [
+-                  ['host_arch=="s390x"', {
+-                    'cflags': [ '-m31' ],
+-                    'ldflags': [ '-m31' ]
+-                  },{
+-                   'cflags': [ '-m32' ],
+-                   'ldflags': [ '-m32' ]
+-                  }],
+-                ],
+-              }],
+-            ],
+-            'xcode_settings': {
+-              'ARCHS': [ 'i386' ],
+-            },
+-          }],
+-          ['_toolset=="target"', {
+-            'conditions': [
+-              ['target_cxx_is_biarch==1', {
+-                'conditions': [
+-                  ['host_arch=="s390x"', {
+-                    'cflags': [ '-m31' ],
+-                    'ldflags': [ '-m31' ]
+-                  },{
+-                   'cflags': [ '-m32' ],
+-                   'ldflags': [ '-m32' ],
+-                  }],
+-                ],
+-              }],
+-            ],
+-            'xcode_settings': {
+-              'ARCHS': [ 'i386' ],
+-            },
+-          }],
+-        ],
+-      }],
+-      ['(OS=="linux" or OS=="android") and \
+-        (v8_target_arch=="x64" or v8_target_arch=="arm64" or \
+-         v8_target_arch=="ppc64" or v8_target_arch=="s390x")', {
+-        'target_conditions': [
+-          ['_toolset=="host"', {
+-            'conditions': [
+-              ['host_cxx_is_biarch==1', {
+-                'cflags': [ '-m64' ],
+-                'ldflags': [ '-m64' ]
+-              }],
+-             ],
+-           }],
+-          ['_toolset=="target"', {
+-             'conditions': [
+-               ['target_cxx_is_biarch==1', {
+-                 'cflags': [ '-m64' ],
+-                 'ldflags': [ '-m64' ],
+-               }],
+-             ]
+-           }],
+-         ],
+-      }],
+       ['OS=="android" and v8_android_log_stdout==1', {
+         'defines': [
+           'V8_ANDROID_LOG_STDOUT',
meta-oe/recipes-devtools/nodejs/nodejs_22.16.0.bb +1 -0
index 4bc829f140..0663e8c52e 100644
@@ -30,6 +30,7 @@ SRC_URI = "http://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz \
            file://0001-deps-disable-io_uring-support-in-libuv.patch \
            file://0001-positional-args.patch \
            file://0001-custom-env.patch \
+           file://0001-build-remove-redundant-mXX-flags-for-V8.patch \
            file://run-ptest \
            "
 SRC_URI:append:class-target = " \