diff mbox series

libgcrypt: fix compile error for t-thread-local

Message ID 20250602205546.426714-1-hiagofranco@gmail.com
State Accepted, archived
Commit d2daf78a083688b82625800919cdc6c6555fcc52
Headers show
Series libgcrypt: fix compile error for t-thread-local | expand

Commit Message

Hiago De Franco June 2, 2025, 8:55 p.m. UTC
From: Hiago De Franco <hiago.franco@toradex.com>

Currently the libgcrypt-native build is failing with the following
error:

| ld: t_thread_local-t-thread-local.o: in function `main':
| t-thread-local.c:(.text.startup+0x187): undefined reference to `pthread_create'
| ld: t-thread-local.c:(.text.startup+0x1d0): undefined reference to `pthread_join'

Backport the fix from upstream and add "-lpthread" to
"t_thread_local_CFLAGS" to make the compilation successfull, similar to
what 0004-tests-Makefile.am-fix-undefined-reference-to-pthread.patch
does.

Signed-off-by: Hiago De Franco <hiago.franco@toradex.com>
---
 ...s-Fix-link-errors-for-t-thread-local.patch | 34 +++++++++++++++++++
 .../libgcrypt/libgcrypt_1.11.1.bb             |  1 +
 2 files changed, 35 insertions(+)
 create mode 100644 meta/recipes-support/libgcrypt/files/0001-tests-Fix-link-errors-for-t-thread-local.patch

Comments

Ross Burton June 5, 2025, 1:44 p.m. UTC | #1
On 2 Jun 2025, at 21:55, Hiago De Franco via lists.openembedded.org <hiagofranco=gmail.com@lists.openembedded.org> wrote:
> 
> From: Hiago De Franco <hiago.franco@toradex.com>
> 
> Currently the libgcrypt-native build is failing with the following
> error:
> 
> | ld: t_thread_local-t-thread-local.o: in function `main':
> | t-thread-local.c:(.text.startup+0x187): undefined reference to `pthread_create'
> | ld: t-thread-local.c:(.text.startup+0x1d0): undefined reference to `pthread_join'
> 
> Backport the fix from upstream and add "-lpthread" to
> "t_thread_local_CFLAGS" to make the compilation successfull, similar to
> what 0004-tests-Makefile.am-fix-undefined-reference-to-pthread.patch
> does.

This has been merged but I’m curious: in what situations does this fail? The commit talks about NetBSD and we’re not seeing this on the autobuilder cluster.

Ross
Khem Raj June 5, 2025, 4:46 p.m. UTC | #2
On 6/5/25 6:44 AM, Ross Burton via lists.openembedded.org wrote:
> On 2 Jun 2025, at 21:55, Hiago De Franco via lists.openembedded.org <hiagofranco=gmail.com@lists.openembedded.org> wrote:
>>
>> From: Hiago De Franco <hiago.franco@toradex.com>
>>
>> Currently the libgcrypt-native build is failing with the following
>> error:
>>
>> | ld: t_thread_local-t-thread-local.o: in function `main':
>> | t-thread-local.c:(.text.startup+0x187): undefined reference to `pthread_create'
>> | ld: t-thread-local.c:(.text.startup+0x1d0): undefined reference to `pthread_join'
>>
>> Backport the fix from upstream and add "-lpthread" to
>> "t_thread_local_CFLAGS" to make the compilation successfull, similar to
>> what 0004-tests-Makefile.am-fix-undefined-reference-to-pthread.patch
>> does.

I wonder if the -pthread should be added instead of -lpthread since its 
adding to CFLAGS and not LDFLAGS

> 
> This has been merged but I’m curious: in what situations does this fail? The commit talks about NetBSD and we’re not seeing this on the autobuilder cluster.
> 

My guess is that pthread check in configure is failing. If we can see 
config.log from build dir for this package we can get a better idea.

> Ross
> 
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#218020): https://lists.openembedded.org/g/openembedded-core/message/218020
> Mute This Topic: https://lists.openembedded.org/mt/113436606/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Khem Raj June 5, 2025, 7:53 p.m. UTC | #3
On Thu, Jun 5, 2025 at 12:40 PM Hiago De Franco <hiagofranco@gmail.com> wrote:
>
> Hi Ross, Khem,
>
> On Thu, Jun 05, 2025 at 01:44:08PM +0000, Ross Burton wrote:
> > On 2 Jun 2025, at 21:55, Hiago De Franco via lists.openembedded.org <hiagofranco=gmail.com@lists.openembedded.org> wrote:
> > >
> > > From: Hiago De Franco <hiago.franco@toradex.com>
> > >
> > > Currently the libgcrypt-native build is failing with the following
> > > error:
> > >
> > > | ld: t_thread_local-t-thread-local.o: in function `main':
> > > | t-thread-local.c:(.text.startup+0x187): undefined reference to `pthread_create'
> > > | ld: t-thread-local.c:(.text.startup+0x1d0): undefined reference to `pthread_join'
> > >
> > > Backport the fix from upstream and add "-lpthread" to
> > > "t_thread_local_CFLAGS" to make the compilation successfull, similar to
> > > what 0004-tests-Makefile.am-fix-undefined-reference-to-pthread.patch
> > > does.
> >
> > This has been merged but I’m curious: in what situations does this fail? The commit talks about NetBSD and we’re not seeing this on the autobuilder cluster.
>
> The NetBSD part is from the commit I backported, because I saw this was
> fixed upstream. Looks they were the first to see this issue.
>
> I am not sure why the autobuilder was not able to catch it, we do
> nightly builds of oe-core master with our hardware and the upgrade of
> libgcrypt recipe introduced a regression were all our machines were
> broken.
>
> I attached the do_compile log failure, but the issue happends here:
>
> build/tmp/hosttools/ld: t-thread-local.o: in function `main':
> t-thread-local.c:(.text.startup+0x187): undefined reference to `pthread_create'
> /build/tmp/hosttools/ld: t-thread-local.c:(.text.startup+0x1d0): undefined reference to `pthread_join'
>


My guess is that you are using glibc before pthread merge into libc.so
which could be alma-8 distro or some such
we do have alma-8 nodes on AB but I guess this escaped building on alma-8 hosts.

Whats your build distro  and version of glibc on it

> [...]
>
> ERROR: Task (virtual:native:layers/openembedded-core/meta/recipes-support/libgcrypt/libgcrypt_1.11.1.bb:do_compile) failed with exit code '1'
>
> >
> > Ross
>
> On Thu, Jun 05, 2025 at 09:46:52AM -0700, Khem Raj wrote:
> >
> >
> > On 6/5/25 6:44 AM, Ross Burton via lists.openembedded.org wrote:
> > > On 2 Jun 2025, at 21:55, Hiago De Franco via lists.openembedded.org <hiagofranco=gmail.com@lists.openembedded.org> wrote:
> > > >
> > > > From: Hiago De Franco <hiago.franco@toradex.com>
> > > >
> > > > Currently the libgcrypt-native build is failing with the following
> > > > error:
> > > >
> > > > | ld: t_thread_local-t-thread-local.o: in function `main':
> > > > | t-thread-local.c:(.text.startup+0x187): undefined reference to `pthread_create'
> > > > | ld: t-thread-local.c:(.text.startup+0x1d0): undefined reference to `pthread_join'
> > > >
> > > > Backport the fix from upstream and add "-lpthread" to
> > > > "t_thread_local_CFLAGS" to make the compilation successfull, similar to
> > > > what 0004-tests-Makefile.am-fix-undefined-reference-to-pthread.patch
> > > > does.
> >
> > I wonder if the -pthread should be added instead of -lpthread since its
> > adding to CFLAGS and not LDFLAGS
>
> When I saw the patch upstream I just had to add the -lpthread and the issue
> was gone. Not sure if it was the correct approach, if it is not them I
> can subbmit another patch.
>
> >
> > >
> > > This has been merged but I’m curious: in what situations does this fail? The commit talks about NetBSD and we’re not seeing this on the autobuilder cluster.
> > >
> >
> > My guess is that pthread check in configure is failing. If we can see
> > config.log from build dir for this package we can get a better idea.
>
> Good point, I checked and looks like it is correctly configured:
>
> checking for pthread_create in -lpthread... yes
>
> But after that the do_compile fails. I also attched the do_configure log
> here.
>
> >
> > > Ross
> > >
> > >
> > >
> > > -=-=-=-=-=-=-=-=-=-=-=-
> > > Links: You receive all messages sent to this group.
> > > View/Reply Online (#218020): https://lists.openembedded.org/g/openembedded-core/message/218020
> > > Mute This Topic: https://lists.openembedded.org/mt/113436606/1997914
> > > Group Owner: openembedded-core+owner@lists.openembedded.org
> > > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> > > -=-=-=-=-=-=-=-=-=-=-=-
> > >
> >
>
> Best Regards,
> Hiago.
diff mbox series

Patch

diff --git a/meta/recipes-support/libgcrypt/files/0001-tests-Fix-link-errors-for-t-thread-local.patch b/meta/recipes-support/libgcrypt/files/0001-tests-Fix-link-errors-for-t-thread-local.patch
new file mode 100644
index 000000000000..5ebc3831d4ac
--- /dev/null
+++ b/meta/recipes-support/libgcrypt/files/0001-tests-Fix-link-errors-for-t-thread-local.patch
@@ -0,0 +1,34 @@ 
+From 746dc1c3837546c1085102e546a83da8d1c773e1 Mon Sep 17 00:00:00 2001
+From: Collin Funk <collin.funk1@gmail.com>
+Date: Thu, 1 May 2025 22:20:58 -0700
+Subject: [PATCH] tests: Fix link errors for t-thread-local.
+
+On platforms where pthread_create is not in libc t-thread-local fails to
+link.  Issue found on NetBSD 10.0.
+* tests/Makefile.am (t_thread_local_LDADD): Add $(standard_ldadd),
+$(GPG_ERROR_MT_LIBS), and @LDADD_FOR_TESTS_KLUDGE@.
+(t_thread_local_CFLAGS): Add $(GPG_ERROR_MT_CFLAGS).
+
+--
+
+Upstream-Status: Backport [793eda7b258a562757b51c96044b103b638f1a63]
+GnuPG-bug-id: 7634
+Signed-off-by: Collin Funk <collin.funk1@gmail.com>
+Signed-off-by: Hiago De Franco <hiago.franco@toradex.com>
+---
+ tests/Makefile.am | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/tests/Makefile.am b/tests/Makefile.am
+index 9a9e1c2c264a..b80f266f97c2 100644
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -94,6 +94,8 @@ t_secmem_LDADD = $(standard_ldadd) @LDADD_FOR_TESTS_KLUDGE@
+ testapi_LDADD = $(standard_ldadd) @LDADD_FOR_TESTS_KLUDGE@
+ t_lock_LDADD = $(standard_ldadd) $(GPG_ERROR_MT_LIBS) @LDADD_FOR_TESTS_KLUDGE@
+ t_lock_CFLAGS = $(GPG_ERROR_MT_CFLAGS) -lpthread
++t_thread_local_LDADD = $(standard_ldadd) $(GPG_ERROR_MT_LIBS) @LDADD_FOR_TESTS_KLUDGE@
++t_thread_local_CFLAGS = $(GPG_ERROR_MT_CFLAGS) -lpthread
+ testdrv_LDADD = $(LDADD_FOR_TESTS_KLUDGE)
+ 
+ # Build a version of the test driver for the build platform.
diff --git a/meta/recipes-support/libgcrypt/libgcrypt_1.11.1.bb b/meta/recipes-support/libgcrypt/libgcrypt_1.11.1.bb
index e51a20e5bfb1..5574e8c821ef 100644
--- a/meta/recipes-support/libgcrypt/libgcrypt_1.11.1.bb
+++ b/meta/recipes-support/libgcrypt/libgcrypt_1.11.1.bb
@@ -21,6 +21,7 @@  UPSTREAM_CHECK_URI = "https://gnupg.org/download/index.html"
 SRC_URI = "${GNUPG_MIRROR}/libgcrypt/libgcrypt-${PV}.tar.bz2 \
            file://0001-libgcrypt-fix-m4-file-for-oe-core.patch \
            file://0004-tests-Makefile.am-fix-undefined-reference-to-pthread.patch \
+           file://0001-tests-Fix-link-errors-for-t-thread-local.patch \
            file://no-native-gpg-error.patch \
            file://no-bench-slope.patch \
            file://run-ptest \