Skip to contentSkip to conversation

package/tcf-agent: fix uClibc-ng compile on ARM

PATCH Applied Waldemar Brodkorb 3 participants 3 messages Aug 17, 2023 – Aug 7, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/2 package/tcf-agent: fix uClibc-ng compile on ARM

When a shared build is used, we can use getauxval and no ARM only instuctions are in use.

When a static build is used, we need to override CFLAGS to use arm instructions, as uClibc-ng only supports getauxval for shared case.

Fixes:
- http://autobuild.buildroot.net/results/3b5/3b5c5519a3e5ee490308bc1a1b9579ce13417235

---
v1 -> v2:
- musl is not affected, change requested by Thomas Petazzoni

---
 .../0001-fix-uClibc-ng-compile.patch          | 27 +++++++++++++++++++
 package/tcf-agent/tcf-agent.mk                |  7 +++++
 2 files changed, 34 insertions(+)
 create mode 100644 package/tcf-agent/0001-fix-uClibc-ng-compile.patch
package/tcf-agent/0001-fix-uClibc-ng-compile.patch new file +27 -0
new file mode 100644
index 0000000000..b8f46f3c48
@@ -0,0 +1,27 @@
+From a78007cd139e1dea3d893f5fe1d1c3a47503e6a2 Mon Sep 17 00:00:00 2001
+From: Waldemar Brodkorb <[email protected]>
+Date: Sat, 12 Aug 2023 18:27:02 +0200
+Subject: [PATCH] fix uClibc-ng compile
+
+Signed-off-by: Waldemar Brodkorb <[email protected]>
+Upstream: N/A only mail available
+---
+ agent/machine/arm/tcf/cpudefs-mdep.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/agent/machine/arm/tcf/cpudefs-mdep.c b/agent/machine/arm/tcf/cpudefs-mdep.c
+index 051631a0..7c4fbf3e 100644
+--- a/agent/machine/arm/tcf/cpudefs-mdep.c
++++ b/agent/machine/arm/tcf/cpudefs-mdep.c
+@@ -21,7 +21,7 @@
+ 
+ #ifndef USE_getauxval
+ #  include <features.h>
+-#  define USE_getauxval (defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16)))
++#  define USE_getauxval (defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16)) || (defined(__UCLIBC__) && defined(__HAVE_SHARED__)))
+ #endif
+ 
+ #include <stddef.h>
+-- 
+2.39.2
+
package/tcf-agent/tcf-agent.mk +7 -0
index 2b8a61b66f..7c25df864a 100644
@@ -21,6 +21,13 @@ TCF_AGENT_CONF_OPTS = \
 	-DBUILD_SHARED_LIBS=OFF \
 	-DTCF_MACHINE=$(call qstrip,$(BR2_PACKAGE_TCF_AGENT_ARCH))
 
+# tcf-agent uses some arm instructions in case getauxval is not available.
+# unfortunately the uClibc-ng implementation of getauxval uses some features
+# of ld.so to work
+ifeq ($(BR2_STATIC_LIBS)$(BR2_TOOLCHAIN_USES_UCLIBC)$(BR2_ARM_INSTRUCTIONS_THUMB),yyy)
+TCF_AGENT_CONF_OPTS += -DCMAKE_C_FLAGS="$(TARGET_CFLAGS) -marm"
+endif
+
 define TCF_AGENT_INSTALL_INIT_SYSTEMD
 	$(INSTALL) -D -m 644 package/tcf-agent/tcf-agent.service \
 		$(TARGET_DIR)/usr/lib/systemd/system/tcf-agent.service
Signature · 6 lines
2.39.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 10 lines · Waldemar Brodkorb

When a shared build is used, we can use getauxval and no ARM only instuctions are in use.

When a static build is used, we need to override CFLAGS to use arm instructions, as uClibc-ng only supports getauxval for shared case.

Fixes:
- http://autobuild.buildroot.net/results/3b5/3b5c5519a3e5ee490308bc1a1b9579ce13417235

Applied to master, thanks.

Regards,
Arnout

Quoted 51 lines

---
v1 -> v2:
- musl is not affected, change requested by Thomas Petazzoni

---
  .../0001-fix-uClibc-ng-compile.patch          | 27 +++++++++++++++++++
  package/tcf-agent/tcf-agent.mk                |  7 +++++
  2 files changed, 34 insertions(+)

create mode 100644 package/tcf-agent/0001-fix-uClibc-ng-compile.patch

package/tcf-agent/0001-fix-uClibc-ng-compile.patch new file +27 -0
new file mode 100644
index 0000000000..b8f46f3c48
@@ -0,0 +1,27 @@
+From a78007cd139e1dea3d893f5fe1d1c3a47503e6a2 Mon Sep 17 00:00:00 2001
+From: Waldemar Brodkorb <[email protected]>
+Date: Sat, 12 Aug 2023 18:27:02 +0200
+Subject: [PATCH] fix uClibc-ng compile
+
+Signed-off-by: Waldemar Brodkorb <[email protected]>
+Upstream: N/A only mail available
+---
+ agent/machine/arm/tcf/cpudefs-mdep.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/agent/machine/arm/tcf/cpudefs-mdep.c b/agent/machine/arm/tcf/cpudefs-mdep.c
+index 051631a0..7c4fbf3e 100644
+--- a/agent/machine/arm/tcf/cpudefs-mdep.c
++++ b/agent/machine/arm/tcf/cpudefs-mdep.c
+@@ -21,7 +21,7 @@
+
+ #ifndef USE_getauxval
+ #  include <features.h>
+-#  define USE_getauxval (defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16)))
++#  define USE_getauxval (defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16)) || (defined(__UCLIBC__) && defined(__HAVE_SHARED__)))
+ #endif
+
+ #include <stddef.h>
+--
+2.39.2
+
package/tcf-agent/tcf-agent.mk +0 -0
index 2b8a61b66f..7c25df864a 100644
@@ -21,6 +21,13 @@ TCF_AGENT_CONF_OPTS = \
  	-DBUILD_SHARED_LIBS=OFF \
  	-DTCF_MACHINE=$(call qstrip,$(BR2_PACKAGE_TCF_AGENT_ARCH))
 

package/tcf-agent/tcf-agent.mk TCF_AGENT_CONF_OPTS = \ · line 33

Quoted 10 lines
package/tcf-agent/tcf-agent.mk +7 -0
+# tcf-agent uses some arm instructions in case getauxval is not available.
+# unfortunately the uClibc-ng implementation of getauxval uses some features
+# of ld.so to work
+ifeq ($(BR2_STATIC_LIBS)$(BR2_TOOLCHAIN_USES_UCLIBC)$(BR2_ARM_INSTRUCTIONS_THUMB),yyy)
+TCF_AGENT_CONF_OPTS += -DCMAKE_C_FLAGS="$(TARGET_CFLAGS) -marm"
+endif
+
  define TCF_AGENT_INSTALL_INIT_SYSTEMD
  	$(INSTALL) -D -m 644 package/tcf-agent/tcf-agent.service \
  		$(TARGET_DIR)/usr/lib/systemd/system/tcf-agent.service

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw
In reply to Waldemar Brodkorb
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Waldemar" == Waldemar Brodkorb <[email protected]> writes:

When a shared build is used, we can use getauxval and no ARM only instuctions are in use.

When a static build is used, we need to override CFLAGS to use arm instructions, as uClibc-ng only supports getauxval for shared case.

Quoted 7 lines

Fixes:
- http://autobuild.buildroot.net/results/3b5/3b5c5519a3e5ee490308bc1a1b9579ce13417235

---
v1 -> v2:
- musl is not affected, change requested by Thomas Petazzoni

Committed to 2024.02.x and 2024.05.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot