Skip to contentSkip to conversation

glibc: install glibc utils to target

PATCH Superseded Nikita Sobolev 2 participants 2 messages Nov 20, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 glibc: install glibc utils to target

With this patch we introduce an option for glibc, which installs getconf, ldconfig and ldd utilities on target, that may be useful in debugging. By default these utilities are built, but not installed to the target.
ldd is a bash script, so it has bash dependency.

---
 package/glibc/Config.in | 15 +++++++++++++++
 package/glibc/glibc.mk  |  7 +++++++
 2 files changed, 22 insertions(+)
package/glibc/Config.in +15 -0
index 7821251087..43d6445177 100644
@@ -8,3 +8,18 @@ config BR2_PACKAGE_GLIBC
 	help
 	  https://www.gnu.org/software/libc/
 endif
+
+if BR2_TOOLCHAIN_BUILDROOT_GLIBC
+
+config BR2_PACKAGE_GLIBC_UTILS
+	bool "Compile and install glibc utilities"
+	depends on BR2_PACKAGE_GLIBC
+	depends on BR2_PACKAGE_BASH
+	help
+	  Enabling this option will compile and install the getconf,
+	  ldconfig and ldd glibc utilities for the target.
+
+comment "Glibc utilities need bash"
+	depends on !BR2_PACKAGE_BASH
+
+endif
package/glibc/glibc.mk +7 -0
index 68c6670007..db82792c2e 100644
@@ -143,10 +143,17 @@ ifeq ($(BR2_PACKAGE_GDB),y)
 GLIBC_LIBS_LIB += libthread_db.so.*
 endif
 
+ifeq ($(BR2_PACKAGE_GLIBC_UTILS),y)
+GLIBC_TARGET_UTILS_BIN = /build/posix/getconf /build/elf/ldconfig /build/elf/ldd
+endif
+
 define GLIBC_INSTALL_TARGET_CMDS
 	for libpattern in $(GLIBC_LIBS_LIB); do \
 		$(call copy_toolchain_lib_root,$$libpattern) ; \
 	done
+	for util in $(GLIBC_TARGET_UTILS_BIN); do \
+		$(INSTALL) -D -m 0755 $(@D)/$$util $(TARGET_DIR)/bin/ ;\
+	done
 endef
 
 $(eval $(autotools-package))
Signature · 1 line
2.16.2
#1 lore raw

PATCH 1/1 glibc: install glibc utils to target

Hello Nikita,

Thanks for the patch!

package/glibc/Config.in config BR2_PACKAGE_GLIBC · line 12

Quoted 10 lines · On Wed, 20 Nov 2019 15:16:43 +0300 Nikita Sobolev…
package/glibc/Config.in +2 -0
index 7821251087..43d6445177 100644
@@ -8,3 +8,18 @@ config BR2_PACKAGE_GLIBC
 	help
 	  https://www.gnu.org/software/libc/
 endif
+
+if BR2_TOOLCHAIN_BUILDROOT_GLIBC

This condition is redundant, since glibc/Config.in already starts with:

if BR2_TOOLCHAIN_BUILDROOT_GLIBC

package/glibc/Config.in config BR2_PACKAGE_GLIBC · line 15

Quoted 2 lines
package/glibc/Config.in +2 -0
+config BR2_PACKAGE_GLIBC_UTILS
+	bool "Compile and install glibc utilities"

Just:

bool "Install glibc utilities"

package/glibc/Config.in config BR2_PACKAGE_GLIBC · line 16

Quoted 1 line
package/glibc/Config.in +1 -0
+	depends on BR2_PACKAGE_GLIBC

This is not needed.

package/glibc/Config.in config BR2_PACKAGE_GLIBC · line 22

Quoted 6 lines
package/glibc/Config.in +6 -0
+	depends on BR2_PACKAGE_BASH
+	help
+	  Enabling this option will compile and install the getconf,
+	  ldconfig and ldd glibc utilities for the target.
+
+comment "Glibc utilities need bash"

Glibc -> glibc

package/glibc/glibc.mk ifeq ($(BR2_PACKAGE_GDB),y) · line 147

Quoted 13 lines
package/glibc/Config.in +3 -0
+	depends on !BR2_PACKAGE_BASH
+
+endif
package/glibc/glibc.mk +2 -0
index 68c6670007..db82792c2e 100644
@@ -143,10 +143,17 @@ ifeq ($(BR2_PACKAGE_GDB),y)
 GLIBC_LIBS_LIB += libthread_db.so.*
 endif
 
+ifeq ($(BR2_PACKAGE_GLIBC_UTILS),y)
+GLIBC_TARGET_UTILS_BIN = /build/posix/getconf /build/elf/ldconfig /build/elf/ldd

Drop the leading slash in each entry, and maybe the build/ as well, so:

GLIBC_TARGET_UTILS_BIN = posix/getconf elf/ldconfig elf/ldd

package/glibc/glibc.mk ifeq ($(BR2_PACKAGE_GDB),y) · line 156

Quoted 9 lines
package/glibc/glibc.mk +5 -0
+endif
+
 define GLIBC_INSTALL_TARGET_CMDS
 	for libpattern in $(GLIBC_LIBS_LIB); do \
 		$(call copy_toolchain_lib_root,$$libpattern) ; \
 	done
+	for util in $(GLIBC_TARGET_UTILS_BIN); do \
+		$(INSTALL) -D -m 0755 $(@D)/$$util $(TARGET_DIR)/bin/ ;\
+	done

Please use a make foreach loop instead, and a full destination path for the target:

	$(foreach util,$(GLIBC_TARGET_UTILS_BIN), \
		$(INSTALL) -D -m 0755 $(@D)/build/$(util) $(TARGET_DIR)/bin/$(notdir $(util))
	)

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com