Skip to contentSkip to conversation

package/libtalloc: new package

PATCH New Jared Bents 2 participants 2 messages Mar 27, 2020 – Mar 29, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 package/libtalloc: new package

libtalloc is a hierarchical, reference counted memory pool system with destructors. It is the core memory allocator used in Samba.

--
v2: - updated commit message to fit new package standard
- updated to waf package type
- added developers entry
- added toolchain dependencies
- license and license file updates
- removed TARGET_NLS_LIBS dependency
- removed empty python_LDFLAGS and python_LIBDIR

---
 DEVELOPERS                       |  1 +
 package/Config.in                |  1 +
 package/libtalloc/Config.in      | 20 +++++++++
 package/libtalloc/libtalloc.hash |  4 ++
 package/libtalloc/libtalloc.mk   | 72 ++++++++++++++++++++++++++++++++
 5 files changed, 98 insertions(+)
 create mode 100644 package/libtalloc/Config.in
 create mode 100644 package/libtalloc/libtalloc.hash
 create mode 100644 package/libtalloc/libtalloc.mk
DEVELOPERS +1 -0
index fd312a44af..afad4fad12 100644
@@ -1166,6 +1166,7 @@ F:	package/zynq-boot-bin/
 
 N:	Jared Bents <[email protected]>
 F:	package/davici/
+F:	package/libtalloc/
 
 N:	Jarkko Sakkinen <[email protected]>
 F:	package/quota/
package/Config.in +1 -0
index 091f5d39f7..37c2c3df12 100644
@@ -1769,6 +1769,7 @@ menu "Other"
 	source "package/libsigc/Config.in"
 	source "package/libsigsegv/Config.in"
 	source "package/libspatialindex/Config.in"
+	source "package/libtalloc/Config.in"
 	source "package/libtasn1/Config.in"
 	source "package/libtommath/Config.in"
 	source "package/libtpl/Config.in"
package/libtalloc/Config.in new file +20 -0
new file mode 100644
index 0000000000..333d7305ac
@@ -0,0 +1,20 @@
+comment "libtalloc needs a uClibc or glibc toolchain w/ wchar, dynamic library, NPTL"
+	depends on BR2_TOOLCHAIN_HAS_SYNC_4
+	depends on !BR2_USE_WCHAR || BR2_TOOLCHAIN_USES_MUSL \
+		|| BR2_STATIC_LIBS || !BR2_TOOLCHAIN_HAS_THREADS_NPTL
+	depends on BR2_USE_MMU
+
+config BR2_PACKAGE_LIBTALLOC
+	bool "libtalloc"
+	depends on BR2_USE_MMU # fork()
+	depends on BR2_USE_WCHAR # python
+	depends on BR2_TOOLCHAIN_HAS_THREADS_NPTL # python -> libffi
+	depends on !BR2_STATIC_LIBS # cmocka, python, gnutls
+	depends on BR2_TOOLCHAIN_HAS_SYNC_4
+	depends on !BR2_TOOLCHAIN_USES_MUSL
+	help
+	  talloc is a hierarchical, reference counted memory pool
+	  system with destructors. It is the core memory allocator
+	  used in Samba.
+
+	  https://talloc.samba.org/talloc/doc/html/index.html
package/libtalloc/libtalloc.hash new file +4 -0
new file mode 100644
index 0000000000..34e41ddd9f
@@ -0,0 +1,4 @@
+# Locally calculated after checking pgp signature
+sha256 ef4822d2fdafd2be8e0cabc3ec3c806ae29b8268e932c5e9a4cd5585f37f9f77  talloc-2.3.1.tar.gz
+sha256 15c2767545d1e43dc35832736253bde5be956f8ffec0474a6d0f70349b646ed3  talloc.h
+sha256 8742f2dad3aaf885c7b4b699c20bfa0e9edeab380689f91a88aa90af03e6947b  pytalloc.h
package/libtalloc/libtalloc.mk new file +72 -0

72 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/1 package/libtalloc: new package

Hello Jared,

Quoted 5 lines · On Fri, 27 Mar 2020 10:02:25 -0500 Jared Bents…

libtalloc is a hierarchical, reference counted memory pool system with destructors. It is the core memory allocator used in Samba.

Thanks for this new iteration.

Review

Quoted 8 lines
(quoted diff) +8 -0
+config BR2_PACKAGE_LIBTALLOC
+	bool "libtalloc"
+	depends on BR2_USE_MMU # fork()
+	depends on BR2_USE_WCHAR # python
+	depends on BR2_TOOLCHAIN_HAS_THREADS_NPTL # python -> libffi
+	depends on !BR2_STATIC_LIBS # cmocka, python, gnutls
+	depends on BR2_TOOLCHAIN_HAS_SYNC_4
+	depends on !BR2_TOOLCHAIN_USES_MUSL

I don't understand why you have added these gazillions of dependencies. BR2_USE_MMU is indeed needed, as fork() is used.

But the other dependencies, I don't understand:

- Python is only an optional dependency of your package, so there's no reason to replicate Python's dependencies.

- cmocka and gnutls are not dependencies either.

- It builds fine with musl.

So, unless you have a good justification (a build failure), please drop all those dependencies, and keep only the BR2_USE_MMU.

Of course, if that's indeed the case, you can drop the Config.in comment as well.

Review

Quoted 2 lines
(quoted diff) +2 -0
+define LIBTALLOC_CONFIGURE_CMDS
+	$(INSTALL) -m 0644 package/samba4/samba4-cache.txt $(@D)/cache.txt;

Final semi-colon not needed.

Review

Quoted 1 line
(quoted diff) +1 -0
+	echo 'Checking uname machine type: $(BR2_ARCH)' >>$(@D)/cache.txt;

Final semi-colon not needed.

I am not sure it is such a great idea to share the waf options cache with Samba though.

Quoted 7 lines
(quoted diff) +7 -0
+	(cd $(@D); \
+		$(TARGET_CONFIGURE_OPTS) \
+		$(LIBTALLOC_CONF_ENV) \
+		./buildtools/bin/waf configure \
+			--prefix=/usr \
+			--sysconfdir=/etc \
+			--localstatedir=/var \

Review

Quoted 10 lines
(quoted diff) +10 -0
+			--with-libiconv=$(STAGING_DIR)/usr \
+			--cross-compile \
+			--cross-answers=$(@D)/cache.txt \
+			--hostcc=gcc \
+			--disable-rpath \
+			--disable-rpath-install \
+			--bundled-libraries='!asn1_compile,!compile_et' \
+			$(LIBTALLOC_CONF_OPTS) \
+	)
+endef

Here, we're not using the waf-package infrastructure properly. In fact, you almost don't use anything of it.

One thing that makes it not possible to use it as-is is that the waf script is not in ./waf, but in ./buildtools/bin/waf. To make this work, add a preparation patch that does this in pkg-waf.mk:

package/pkg-waf.mk +1 -1
index a32d5dab33..5579f2bef0 100644
@@ -46,7 +46,7 @@ ifeq ($$($(2)_NEEDS_EXTERNAL_WAF),YES)
 $(2)_DEPENDENCIES += host-waf
 $(2)_WAF = $$(HOST_DIR)/bin/waf
 else
-$(2)_WAF = ./waf
+$(2)_WAF ?= ./waf
 endif
 
 $(2)_BUILD_OPTS                                ?=

Then in libtalloc.mk, you can do:

LIBTALLOC_WAF = ./buildtools/bin/waf

and then, drop your custom LIBTALLOC_CONFIGURE_CMDS.

Review

Quoted 4 lines
(quoted diff) +4 -0
+
+define LIBTALLOC_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(LIBTALLOC_PYTHON) $(MAKE) -C $(@D)
+endef

Why don't you use waf here ?

Review

Quoted 7 lines
(quoted diff) +7 -0
+define LIBTALLOC_INSTALL_STAGING_CMDS
+	$(TARGET_MAKE_ENV) $(LIBTALLOC_PYTHON) $(MAKE) -C $(@D) DESTDIR=$(STAGING_DIR) install
+endef
+
+define LIBTALLOC_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(LIBTALLOC_PYTHON) $(MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install
+endef

Same question.

At the end, your libtalloc.mk should look like this:

################################################################################
#

# libtalloc
#
################################################################################

LIBTALLOC_VERSION = 2.3.1
LIBTALLOC_SITE = https://www.samba.org/ftp/talloc
LIBTALLOC_SOURCE = talloc-$(LIBTALLOC_VERSION).tar.gz LIBTALLOC_LICENSE = LGPL-3.0+, GPL-3.0+ LIBTALLOC_LICENSE_FILES = talloc.h pytalloc.h LIBTALLOC_INSTALL_STAGING = YES LIBTALLOC_CFLAGS = $(TARGET_CFLAGS) LIBTALLOC_LDFLAGS = $(TARGET_LDFLAGS)

LIBTALLOC_CONF_ENV = \
	CFLAGS="$(LIBTALLOC_CFLAGS)" \
	LDFLAGS="$(LIBTALLOC_LDFLAGS)" \
	XSLTPROC=false \
	WAF_NO_PREFORK=1
LIBTALLOC_CONF_OPTS = \
	--sysconfdir=/etc \
	--localstatedir=/var \
	--with-libiconv=$(STAGING_DIR)/usr \
	--cross-compile \
	--cross-answers=$(@D)/cache.txt \
	--hostcc=gcc \
	--disable-rpath \
	--disable-rpath-install \
	--bundled-libraries='!asn1_compile,!compile_et'

ifeq ($(BR2_PACKAGE_LIBTIRPC),y)
LIBTALLOC_CFLAGS += $(PKG_CONFIG_HOST_BINARY) --cflags libtirpc LIBTALLOC_LDFLAGS += $(PKG_CONFIG_HOST_BINARY) --libs libtirpc LIBTALLOC_DEPENDENCIES += libtirpc host-pkgconf
endif

ifeq ($(BR2_PACKAGE_PYTHON3),y)

LIBTALLOC_PYTHON = \
	PYTHON="$(HOST_DIR)/bin/python3" \
	PYTHON_CONFIG="$(STAGING_DIR)/usr/bin/python3-config"
LIBTALLOC_DEPENDENCIES += host-python3 python3
LIBTALLOC_CONF_ENV += \
	$(LIBTALLOC_PYTHON)

# There is not a --enable-python configuration option else
LIBTALLOC_CONF_OPTS += --disable-python
endif

LIBTALLOC_WAF = ./buildtools/bin/waf

define LIBTALLOC_POPULATE_WAF_CACHE

	$(INSTALL) -m 0644 package/samba4/samba4-cache.txt $(@D)/cache.txt
	echo 'Checking uname machine type: $(BR2_ARCH)' >>$(@D)/cache.txt

endef

LIBTALLOC_PRE_CONFIGURE_HOOKS += LIBTALLOC_POPULATE_WAF_CACHE

$(eval $(waf-package))

Best regards,

Thomas

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