Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni via buildroot <buildroot@buildroot.org>
To: Matt Staveley-Taylor <matt.stav.taylor@gmail.com>
Cc: buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 2/2] package/bcachefs-tools: new package
Date: Sun, 14 Jul 2024 22:56:02 +0200	[thread overview]
Message-ID: <20240714225602.65ffd43e@windsurf> (raw)
In-Reply-To: <20240408013859.732937-3-matt.stav.taylor@gmail.com>

Hello,

On Mon,  8 Apr 2024 02:38:45 +0100
Matt Staveley-Taylor <matt.stav.taylor@gmail.com> wrote:

> Add the bcachefs-tools package. Note that this does not teach buildroot
> how to create bcachefs filesystems.
> 
> Signed-off-by: Matt Staveley-Taylor <matt.stav.taylor@gmail.com>

I wanted to apply this, but unfortunately, there is a major issue in
your package: it doesn't actually cross-compile. Indeed, when you do:

	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)

nothing tells the build system that it should use the cross-compiler.
And indeed it doesn't: it compiles everything with "cc". On my system,
it fails because I don't have liburcu installed system-wide, so it
couldn't include urcu/list.h.

The canonical way to cross-compile Makefile-based packages is to do:

	$(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D)

where TARGET_CONFIGURE_OPTS is provided by Buildroot, and contains CC,
LD, CFLAGS, etc. which are correct for cross-compilation.

Unfortunately, passing this makes the build of this package to fail
horribly.

I have made many more changes in your package, you will find my latest
version at:

  https://github.com/tpetazzoni/buildroot/commit/1d1a29b7fedcb9287afd98c2d8a6618af2b6e2df

I will comment below on the things that I have fixed.


> diff --git a/package/bcachefs-tools/Config.in b/package/bcachefs-tools/Config.in
> new file mode 100644
> index 0000000000..2c7cbcf406
> --- /dev/null
> +++ b/package/bcachefs-tools/Config.in
> @@ -0,0 +1,26 @@
> +config BR2_PACKAGE_BCACHEFS_TOOLS
> +	bool "bcachefs-tools"
> +	depends on BR2_USE_MMU # util-linux
> +	depends on BR2_TOOLCHAIN_HAS_THREADS
> +	depends on BR2_PACKAGE_HAS_UDEV

You missed several dependencies of the packages you select. Basically
for every package you select, you need to check if it has "depends on"
and replicate them. The final code I had looks like this:

	depends on BR2_USE_MMU # util-linux, keyutils
	depends on BR2_TOOLCHAIN_HAS_THREADS # liburcu
	depends on !BR2_STATIC_LIBS # keyutils
	depends on BR2_PACKAGE_HAS_UDEV
	depends on BR2_PACKAGE_LIBURCU_ARCH_SUPPORTS
	depends on BR2_INSTALL_LIBSTDCPP # liburcu

> +	select BR2_PACKAGE_KEYUTILS
> +	select BR2_PACKAGE_LIBAIO
> +	select BR2_PACKAGE_LIBSODIUM
> +	select BR2_PACKAGE_LIBURCU
> +	select BR2_PACKAGE_LZ4
> +	select BR2_PACKAGE_UTIL_LINUX
> +	select BR2_PACKAGE_UTIL_LINUX_LIBBLKID
> +	select BR2_PACKAGE_UTIL_LINUX_LIBUUID
> +	select BR2_PACKAGE_ZLIB
> +	select BR2_PACKAGE_ZSTD
> +	help
> +	  Bcachefs filesystem utilities
> +
> +	  https://bcachefs.org/
> +
> +comment "bcachefs-tools needs udev"
> +	depends on !BR2_PACKAGE_HAS_UDEV
> +
> +comment "bcachefs-tools needs a toolchain w/ threads"
> +	depends on BR2_USE_MMU
> +	depends on !BR2_TOOLCHAIN_HAS_THREADS

So these need to be updated as well:


comment "bcachefs-tools needs udev"
	depends on BR2_USE_MMU
	depends on BR2_PACKAGE_LIBURCU_ARCH_SUPPORTS
	depends on !BR2_PACKAGE_HAS_UDEV

comment "bcachefs-tools needs a toolchain w/ threads, C++, dynamic library"
	depends on BR2_USE_MMU
	depends on BR2_PACKAGE_LIBURCU_ARCH_SUPPORTS
	depends on !BR2_TOOLCHAIN_HAS_THREADS || \
		BR2_STATIC_LIBS || \
		!BR2_INSTALL_LIBSTDCPP

> diff --git a/package/bcachefs-tools/bcachefs-tools.hash b/package/bcachefs-tools/bcachefs-tools.hash
> new file mode 100644
> index 0000000000..def2762bea
> --- /dev/null
> +++ b/package/bcachefs-tools/bcachefs-tools.hash
> @@ -0,0 +1,2 @@
> +# Locally computed
> +sha256  f2125c10494e484611e77a32c301e1cbd5cf6f247808cf1c2c7987c68c7ebd8c  bcachefs-tools-vendored-1.6.4.tar.zst

You have forgotten the hash of the license file. But I had forgotten as
well.

> diff --git a/package/bcachefs-tools/bcachefs-tools.mk b/package/bcachefs-tools/bcachefs-tools.mk
> new file mode 100644
> index 0000000000..1a4ca15e8d
> --- /dev/null
> +++ b/package/bcachefs-tools/bcachefs-tools.mk
> @@ -0,0 +1,23 @@
> +################################################################################
> +#
> +# bcachefs-tools
> +#
> +################################################################################
> +
> +BCACHEFS_TOOLS_VERSION = 1.6.4
> +BCACHEFS_TOOLS_SOURCE = bcachefs-tools-vendored-$(BCACHEFS_TOOLS_VERSION).tar.zst
> +BCACHEFS_TOOLS_SITE = https://evilpiepirate.org/bcachefs-tools
> +BCACHEFS_TOOLS_LICENSE = GPL-2.0
> +BCACHEFS_TOOLS_LICENSE_FILES = COPYING
> +BCACHEFS_TOOLS_DEPENDENCIES = host-rustc host-clang keyutils libaio libsodium liburcu lz4 udev util-linux zlib zstd

That line was a bit too long, so I split it with one package per line.

> +
> +define BCACHEFS_TOOLS_BUILD_CMDS
> +	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)

This probably needs $(TARGET_CONFIGURE_OPTS) as discussed above.

> +endef
> +
> +define BCACHEFS_TOOLS_INSTALL_TARGET_CMDS
> +	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR="$(TARGET_DIR)" PREFIX=/usr install

Likewise.

> +endef
> +
> +$(eval $(generic-package))
> +$(eval $(host-generic-package))

The host-generic-package is to create host packages (compiled
natively), and it isn't used anywhere here, so I dropped this line.
Only generic-package is needed to create a target package
(cross-compiled for the target).

Here is a Buildroot configuration that couldn't build your package:

BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_VFP=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_INIT_NONE=y
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_BCACHEFS_TOOLS=y
# BR2_TARGET_ROOTFS_TAR is not set

In order to validate your package, make sure it builds with the
following sequence:

$ make clean
$ cat > .config <<EOF
BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_VFP=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_INIT_NONE=y
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_BCACHEFS_TOOLS=y
# BR2_TARGET_ROOTFS_TAR is not set
EOF
$ ./utils/docker-run make olddefconfig
$ ./utils/docker-run make

Could you have a look and submit a v2 which fixes this problem? No need
to resent your PATCH 1/2 as I applied it to master. Thanks!

Best regards,

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2024-07-14 20:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-08  1:38 [Buildroot] [PATCH 0/2] Add bcachefs-tools package Matt Staveley-Taylor
2024-04-08  1:38 ` [Buildroot] [PATCH 1/2] package: add support for extracting zstd archives Matt Staveley-Taylor
2024-07-14 20:48   ` Thomas Petazzoni via buildroot
2024-04-08  1:38 ` [Buildroot] [PATCH 2/2] package/bcachefs-tools: new package Matt Staveley-Taylor
2024-07-14 20:56   ` Thomas Petazzoni via buildroot [this message]
2024-04-08 20:54 ` [Buildroot] [PATCH 0/2] Add bcachefs-tools package Thomas Petazzoni via buildroot
2024-04-09 22:43   ` Matt Staveley-Taylor
2024-04-10  9:30     ` Thomas Petazzoni via buildroot
2024-04-11  1:32       ` Matt Staveley-Taylor
2024-04-11 12:48         ` Thomas Petazzoni via buildroot
2024-04-11 22:51           ` Matt Staveley-Taylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240714225602.65ffd43e@windsurf \
    --to=buildroot@buildroot.org \
    --cc=matt.stav.taylor@gmail.com \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox