Skip to contentSkip to conversation

nspr: Fix build with nativesdk-gcc from buildtools-extended-tarball

PATCH In review Robert Yang 3 participants 3 messages Jan 6, 2021 – Jun 11, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nspr: Fix build with nativesdk-gcc from buildtools-extended-tarball

Fixed when built with nativesdk-gcc from buildtools-extended-tarball:

$ bitbake nspr-native

gcc abstract.o -Xlinker -L../../dist/lib -lplc4 -L../../dist/lib -lnspr4 -lpthread -o abstract
/path/to/x86_64-wrlinuxsdk-linux/bin/ld:
/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_getcpuclockid@GLIBC_PRIVATE' /path/to/x86_64-wrlinuxsdk-linux/bin/ld:
/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_nanosleep@GLIBC_PRIVATE' /path/to/x86_64-wrlinuxsdk-linux/bin/ld:
/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_settime@GLIBC_PRIVATE' /path/to/x86_64-wrlinuxsdk-linux/bin/ld:
/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_getres@GLIBC_PRIVATE'

Referred to:
https://github.com/linux-test-project/ltp/issues/255

There should be a bug hidden in nativesdk-gcc or other toolchains, but it's very had to figure it out. The quick workaround is using "-lpthread -lrt"

---
 ...ts-Makefile.in-Add-lrt-to-EXTRA_LIBS.patch | 47 +++++++++++++++++++
 meta-oe/recipes-support/nspr/nspr_4.29.bb     |  1 +
 2 files changed, 48 insertions(+)
 create mode 100644 meta-oe/recipes-support/nspr/nspr/0001-nspr-pr-tests-Makefile.in-Add-lrt-to-EXTRA_LIBS.patch
meta-oe/recipes-support/nspr/nspr/0001-nspr-pr-tests-Makefile.in-Add-lrt-to-EXTRA_LIBS.patch new file +47 -0
new file mode 100644
index 000000000..c71871c34
@@ -0,0 +1,47 @@
+From 4441e9c15684623adb3d5cbd6c2f27c1f3d212ac Mon Sep 17 00:00:00 2001
+From: Robert Yang <[email protected]>
+Date: Tue, 29 Dec 2020 03:57:07 +0000
+Subject: [PATCH] nspr/pr/tests/Makefile.in: Add -lrt to EXTRA_LIBS
+
+Fixed when built with nativesdk-gcc from buildtools-extended-tarball:
+$ bitbake nspr-native
+
+gcc   abstract.o -Xlinker -L../../dist/lib -lplc4 -L../../dist/lib -lnspr4 -lpthread -o abstract
+/path/to/x86_64-wrlinuxsdk-linux/bin/ld: 
+/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_getcpuclockid@GLIBC_PRIVATE'
+/path/to/x86_64-wrlinuxsdk-linux/bin/ld: 
+/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_nanosleep@GLIBC_PRIVATE'
+/path/to/x86_64-wrlinuxsdk-linux/bin/ld: 
+/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_settime@GLIBC_PRIVATE'
+/path/to/x86_64-wrlinuxsdk-linux/bin/ld: 
+/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_getres@GLIBC_PRIVATE'
+
+Referred to:
+https://github.com/linux-test-project/ltp/issues/255
+
+There should be a bug hidden in nativesdk-gcc or other toolchains, but it's
+very had to figure it out. The quick workaround is using "-lpthread -lrt"
+
+Upstream-Status: Inappropriate [OE specific]
+
+Signed-off-by: Robert Yang <[email protected]>
+---
+ nspr/pr/tests/Makefile.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/pr/tests/Makefile.in b/pr/tests/Makefile.in
+index 2ccb992..45270e9 100644
+--- a/pr/tests/Makefile.in
++++ b/pr/tests/Makefile.in
+@@ -274,7 +274,7 @@ endif # SunOS
+ ifeq (,$(filter-out Linux GNU GNU_%,$(OS_ARCH)))
+     LDOPTS += -Xlinker
+     ifeq ($(USE_PTHREADS),1)
+-        EXTRA_LIBS = -lpthread
++        EXTRA_LIBS = -lpthread -lrt
+     endif
+ endif
+ 
+-- 
+2.29.2
+
meta-oe/recipes-support/nspr/nspr_4.29.bb +1 -0
index 6307c159e..fa05bc022 100644
@@ -13,6 +13,7 @@ SRC_URI = "http://ftp.mozilla.org/pub/nspr/releases/v${PV}/src/nspr-${PV}.tar.gz
            file://0001-md-Fix-build-with-musl.patch \
            file://Makefile.in-remove-_BUILD_STRING-and-_BUILD_TIME.patch \
            file://nspr.pc.in \
+           file://0001-nspr-pr-tests-Makefile.in-Add-lrt-to-EXTRA_LIBS.patch \
 "
 
 CACHED_CONFIGUREVARS_append_libc-musl = " CFLAGS='${CFLAGS} -D_PR_POLL_AVAILABLE \
Signature · 1 line
2.17.1
#1 lore raw

ping.

Thanks,

Quoted 96 lines · Robert Yang

Fixed when built with nativesdk-gcc from buildtools-extended-tarball:

$ bitbake nspr-native

gcc abstract.o -Xlinker -L../../dist/lib -lplc4 -L../../dist/lib -lnspr4 -lpthread -o abstract
/path/to/x86_64-wrlinuxsdk-linux/bin/ld:
/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_getcpuclockid@GLIBC_PRIVATE' /path/to/x86_64-wrlinuxsdk-linux/bin/ld:
/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_nanosleep@GLIBC_PRIVATE' /path/to/x86_64-wrlinuxsdk-linux/bin/ld:
/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_settime@GLIBC_PRIVATE' /path/to/x86_64-wrlinuxsdk-linux/bin/ld:
/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_getres@GLIBC_PRIVATE'

Referred to:
https://github.com/linux-test-project/ltp/issues/255

There should be a bug hidden in nativesdk-gcc or other toolchains, but it's very had to figure it out. The quick workaround is using "-lpthread -lrt"

---
  ...ts-Makefile.in-Add-lrt-to-EXTRA_LIBS.patch | 47 +++++++++++++++++++
  meta-oe/recipes-support/nspr/nspr_4.29.bb     |  1 +
  2 files changed, 48 insertions(+)

create mode 100644 meta-oe/recipes-support/nspr/nspr/0001-nspr-pr-tests-Makefile.in-Add-lrt-to-EXTRA_LIBS.patch

meta-oe/recipes-support/nspr/nspr/0001-nspr-pr-tests-Makefile.in-Add-lrt-to-EXTRA_LIBS.patch new file +47 -0
new file mode 100644
index 000000000..c71871c34
@@ -0,0 +1,47 @@
+From 4441e9c15684623adb3d5cbd6c2f27c1f3d212ac Mon Sep 17 00:00:00 2001
+From: Robert Yang <[email protected]>
+Date: Tue, 29 Dec 2020 03:57:07 +0000
+Subject: [PATCH] nspr/pr/tests/Makefile.in: Add -lrt to EXTRA_LIBS
+
+Fixed when built with nativesdk-gcc from buildtools-extended-tarball:
+$ bitbake nspr-native
+
+gcc   abstract.o -Xlinker -L../../dist/lib -lplc4 -L../../dist/lib -lnspr4 -lpthread -o abstract
+/path/to/x86_64-wrlinuxsdk-linux/bin/ld:
+/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_getcpuclockid@GLIBC_PRIVATE'
+/path/to/x86_64-wrlinuxsdk-linux/bin/ld:
+/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_nanosleep@GLIBC_PRIVATE'
+/path/to/x86_64-wrlinuxsdk-linux/bin/ld:
+/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_settime@GLIBC_PRIVATE'
+/path/to/x86_64-wrlinuxsdk-linux/bin/ld:
+/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_getres@GLIBC_PRIVATE'
+
+Referred to:
+https://github.com/linux-test-project/ltp/issues/255
+
+There should be a bug hidden in nativesdk-gcc or other toolchains, but it's
+very had to figure it out. The quick workaround is using "-lpthread -lrt"
+
+Upstream-Status: Inappropriate [OE specific]
+
+Signed-off-by: Robert Yang <[email protected]>
+---
+ nspr/pr/tests/Makefile.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/pr/tests/Makefile.in b/pr/tests/Makefile.in
+index 2ccb992..45270e9 100644
+--- a/pr/tests/Makefile.in
++++ b/pr/tests/Makefile.in
+@@ -274,7 +274,7 @@ endif # SunOS
+ ifeq (,$(filter-out Linux GNU GNU_%,$(OS_ARCH)))
+     LDOPTS += -Xlinker
+     ifeq ($(USE_PTHREADS),1)
+-        EXTRA_LIBS = -lpthread
++        EXTRA_LIBS = -lpthread -lrt
+     endif
+ endif
+
+--
+2.29.2
+
meta-oe/recipes-support/nspr/nspr_4.29.bb +1 -0
index 6307c159e..fa05bc022 100644
@@ -13,6 +13,7 @@ SRC_URI = "http://ftp.mozilla.org/pub/nspr/releases/v${PV}/src/nspr-${PV}.tar.gz
             file://0001-md-Fix-build-with-musl.patch \
             file://Makefile.in-remove-_BUILD_STRING-and-_BUILD_TIME.patch \
             file://nspr.pc.in \
+           file://0001-nspr-pr-tests-Makefile.in-Add-lrt-to-EXTRA_LIBS.patch \
  "
 
  CACHED_CONFIGUREVARS_append_libc-musl = " CFLAGS='${CFLAGS} -D_PR_POLL_AVAILABLE \
#2 lore raw

can you check who is passing librt to it. It seems to be linking librt from host in failing case. I wonder when using -lrt how does it work? I guess it then links in nativesdk-glibc version but perhaps gcc -v in failing link cmdline can reveal some more.

Quoted 102 lines · Mingli

ping.

Thanks,

Quoted 96 lines · Robert Yang

Fixed when built with nativesdk-gcc from buildtools-extended-tarball:

$ bitbake nspr-native

gcc abstract.o -Xlinker -L../../dist/lib -lplc4 -L../../dist/lib -lnspr4 -lpthread -o abstract
/path/to/x86_64-wrlinuxsdk-linux/bin/ld:
/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_getcpuclockid@GLIBC_PRIVATE' /path/to/x86_64-wrlinuxsdk-linux/bin/ld:
/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_nanosleep@GLIBC_PRIVATE' /path/to/x86_64-wrlinuxsdk-linux/bin/ld:
/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_settime@GLIBC_PRIVATE' /path/to/x86_64-wrlinuxsdk-linux/bin/ld:
/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_getres@GLIBC_PRIVATE'

Referred to:
https://github.com/linux-test-project/ltp/issues/255

There should be a bug hidden in nativesdk-gcc or other toolchains, but it's very had to figure it out. The quick workaround is using "-lpthread -lrt"

---
  ...ts-Makefile.in-Add-lrt-to-EXTRA_LIBS.patch | 47 +++++++++++++++++++
  meta-oe/recipes-support/nspr/nspr_4.29.bb     |  1 +
  2 files changed, 48 insertions(+)

create mode 100644 meta-oe/recipes-support/nspr/nspr/0001-nspr-pr-tests-Makefile.in-Add-lrt-to-EXTRA_LIBS.patch

meta-oe/recipes-support/nspr/nspr/0001-nspr-pr-tests-Makefile.in-Add-lrt-to-EXTRA_LIBS.patch new file +47 -0
new file mode 100644
index 000000000..c71871c34
@@ -0,0 +1,47 @@
+From 4441e9c15684623adb3d5cbd6c2f27c1f3d212ac Mon Sep 17 00:00:00 2001
+From: Robert Yang <[email protected]>
+Date: Tue, 29 Dec 2020 03:57:07 +0000
+Subject: [PATCH] nspr/pr/tests/Makefile.in: Add -lrt to EXTRA_LIBS
+
+Fixed when built with nativesdk-gcc from buildtools-extended-tarball:
+$ bitbake nspr-native
+
+gcc   abstract.o -Xlinker -L../../dist/lib -lplc4 -L../../dist/lib -lnspr4 -lpthread -o abstract
+/path/to/x86_64-wrlinuxsdk-linux/bin/ld:
+/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_getcpuclockid@GLIBC_PRIVATE'
+/path/to/x86_64-wrlinuxsdk-linux/bin/ld:
+/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_nanosleep@GLIBC_PRIVATE'
+/path/to/x86_64-wrlinuxsdk-linux/bin/ld:
+/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_settime@GLIBC_PRIVATE'
+/path/to/x86_64-wrlinuxsdk-linux/bin/ld:
+/lib/x86_64-linux-gnu/librt.so.1: undefined reference to `__clock_getres@GLIBC_PRIVATE'
+
+Referred to:
+https://github.com/linux-test-project/ltp/issues/255
+
+There should be a bug hidden in nativesdk-gcc or other toolchains, but it's
+very had to figure it out. The quick workaround is using "-lpthread -lrt"
+
+Upstream-Status: Inappropriate [OE specific]
+
+Signed-off-by: Robert Yang <[email protected]>
+---
+ nspr/pr/tests/Makefile.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/pr/tests/Makefile.in b/pr/tests/Makefile.in
+index 2ccb992..45270e9 100644
+--- a/pr/tests/Makefile.in
++++ b/pr/tests/Makefile.in
+@@ -274,7 +274,7 @@ endif # SunOS
+ ifeq (,$(filter-out Linux GNU GNU_%,$(OS_ARCH)))
+     LDOPTS += -Xlinker
+     ifeq ($(USE_PTHREADS),1)
+-        EXTRA_LIBS = -lpthread
++        EXTRA_LIBS = -lpthread -lrt
+     endif
+ endif
+
+--
+2.29.2
+
meta-oe/recipes-support/nspr/nspr_4.29.bb +1 -0
index 6307c159e..fa05bc022 100644
@@ -13,6 +13,7 @@ SRC_URI = "http://ftp.mozilla.org/pub/nspr/releases/v${PV}/src/nspr-${PV}.tar.gz
             file://0001-md-Fix-build-with-musl.patch \
             file://Makefile.in-remove-_BUILD_STRING-and-_BUILD_TIME.patch \
             file://nspr.pc.in \
+           file://0001-nspr-pr-tests-Makefile.in-Add-lrt-to-EXTRA_LIBS.patch \
  "
 
  CACHED_CONFIGUREVARS_append_libc-musl = " CFLAGS='${CFLAGS} -D_PR_POLL_AVAILABLE \