Skip to contentSkip to conversation

Split vim and xxd in different recipes

PATCH Superseded João Marcos Costa 4 participants 11 messages May 8 – May 12

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Split vim and xxd in different recipes

Hello,

Honestly, my main motivation to send this series comes from a time when I was building u-boot (meta-freescale) and I saw vim-native in Bitbake's tasks. It blew my mind that a bootloader somehow dependend on a text editor (yes, only to be built, not to be executed, I know), and the whole text editor was being built to provide nothing more than xxd.

Just to be clear, what bothers me is NOT u-boot depending on xxd. It is actually configuring and compiling Vim (considering the overhead this represents) only to use a single tiny piece of it.

As for the tests I performed:

- machine: qemuriscv64
- toolchains: clang and gcc
- classes (xxd, vim-xxd): target, native, nativesdk
- classes (vim): target, native, nativesdk

Everything built fine, and the core-image-minimal running with qemu also correctly shipped vim and xxd, which executed fine as well.

Best regards,

João Marcos Costa (4):
vim: introduce vim-sources.inc file
vim-xxd: introduce new recipe for xxd
vim: drop references to xxd in base recipe vim.inc: remove xxd from the destination directory

 meta/conf/distro/include/maintainers.inc |  1 +
 meta/recipes-support/vim/vim-sources.inc | 16 +++++++++++++
 meta/recipes-support/vim/vim-xxd_9.2.bb  | 29 ++++++++++++++++++++++++
 meta/recipes-support/vim/vim.inc         | 21 ++++-------------
 meta/recipes-support/vim/vim_9.2.bb      | 10 --------
 5 files changed, 51 insertions(+), 26 deletions(-)
 create mode 100644 meta/recipes-support/vim/vim-sources.inc
 create mode 100644 meta/recipes-support/vim/vim-xxd_9.2.bb
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/4 vim: introduce vim-sources.inc file

This include file contains source-related settings that should be common for any recipes whose sources belong into Vim's source code.

The first example is xxd, which will be introduced in a follow-up commit.

---
 meta/recipes-support/vim/vim-sources.inc | 16 ++++++++++++++++
 meta/recipes-support/vim/vim.inc         | 17 +----------------
 2 files changed, 17 insertions(+), 16 deletions(-)
 create mode 100644 meta/recipes-support/vim/vim-sources.inc
meta/recipes-support/vim/vim-sources.inc new file +16 -0
new file mode 100644
index 0000000000..8a12485c39
@@ -0,0 +1,16 @@
+LICENSE = "Vim"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=d1a651ab770b45d41c0f8cb5a8ca930e"
+
+SRC_URI = "git://github.com/vim/vim.git;branch=master;protocol=https;tag=v${PV} \
+           file://disable_acl_header_check.patch \
+           file://0001-src-Makefile-improve-reproducibility.patch \
+           file://no-path-adjust.patch \
+           "
+
+PV .= ".0340"
+SRCREV = "6addd6c101117706bc9b3609d3a418e26e92618f"
+
+# Do not consider .z in x.y.z, as that is updated with every commit
+UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>\d+\.\d+)\.0"
+# Ignore that the upstream version .z in x.y.z is always newer
+UPSTREAM_VERSION_UNKNOWN = "1"
meta/recipes-support/vim/vim.inc +1 -16
index d6fdf45706..74777864e7 100644
@@ -9,22 +9,7 @@ DEPENDS = "ncurses gettext-native"
 # vimdiff doesn't like busybox diff
 RSUGGESTS:${PN} = "diffutils"
 
-LICENSE = "Vim"
-LIC_FILES_CHKSUM = "file://LICENSE;md5=d1a651ab770b45d41c0f8cb5a8ca930e"
-
-SRC_URI = "git://github.com/vim/vim.git;branch=master;protocol=https;tag=v${PV} \
-           file://disable_acl_header_check.patch \
-           file://0001-src-Makefile-improve-reproducibility.patch \
-           file://no-path-adjust.patch \
-           "
-
-PV .= ".0340"
-SRCREV = "6addd6c101117706bc9b3609d3a418e26e92618f"
-
-# Do not consider .z in x.y.z, as that is updated with every commit
-UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>\d+\.\d+)\.0"
-# Ignore that the upstream version .z in x.y.z is always newer
-UPSTREAM_VERSION_UNKNOWN = "1"
+require vim-sources.inc
 
 VIMDIR = "vim${@d.getVar('PV').split('.')[0]}${@d.getVar('PV').split('.')[1]}"
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/4 vim-xxd: introduce new recipe for xxd

In reply to João Marcos Costa

This new recipe's main purpose is to handle xxd in the simplest way possible, stripping it from any needless tasks and/or dependencies that come from the fact it was originally provided by the same recipe as Vim.

Not only this recipe is faster to build, but it still provides the very same program for both build-time and run-time, so there should be no migration needed by the recipes depend on xxd.

---
 meta/conf/distro/include/maintainers.inc |  1 +
 meta/recipes-support/vim/vim-xxd_9.2.bb  | 29 ++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
 create mode 100644 meta/recipes-support/vim/vim-xxd_9.2.bb
meta/conf/distro/include/maintainers.inc +1 -0
index f98305e930..7d45bfaf65 100644
@@ -871,6 +871,7 @@ RECIPE_MAINTAINER:pn-vala = "Unassigned <[email protected]>"
 RECIPE_MAINTAINER:pn-valgrind = "Mingli Yu <[email protected]>"
 RECIPE_MAINTAINER:pn-vim = "Unassigned <[email protected]>"
 RECIPE_MAINTAINER:pn-vim-tiny = "Unassigned <[email protected]>"
+RECIPE_MAINTAINER:pn-vim-xxd = "João Marcos Costa <[email protected]>"
 RECIPE_MAINTAINER:pn-virglrenderer = "Unassigned <[email protected]>"
 RECIPE_MAINTAINER:pn-volatile-binds = "Chen Qi <[email protected]>"
 RECIPE_MAINTAINER:pn-vte = "Unassigned <[email protected]>"
meta/recipes-support/vim/vim-xxd_9.2.bb new file +29 -0
new file mode 100644
index 0000000000..d876efec4e
@@ -0,0 +1,29 @@
+SUMMARY = "Hex dump and reverse utility from the Vim source tree"
+DESCRIPTION = "xxd is a small utility usually distributed with Vim that creates hex dumps from binary data and can also convert hex dumps back to their original form."
+SECTION = "console/utils"
+HOMEPAGE = "https://www.vim.org/"
+BUGTRACKER = "https://github.com/vim/vim/issues"
+
+require vim-sources.inc
+
+inherit update-alternatives
+
+PROVIDES += "xxd"
+
+do_compile() {
+    cd  ${S}/src/xxd;
+    oe_runmake xxd
+}
+
+do_install() {
+    install -d ${D}${bindir}
+    install -m 0755 src/xxd/xxd ${D}${bindir}
+}
+
+RPROVIDES:${PN} += "xxd"
+
+ALTERNATIVE:${PN} = "xxd"
+ALTERNATIVE_TARGET[xxd] = "${bindir}/xxd"
+ALTERNATIVE_LINK_NAME[xxd] = "${bindir}/xxd"
+
+BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.43.0
#3 lore raw

Re: [PATCH 2/4] vim-xxd: introduce new recipe for xxd

Quoted 52 lines · João Marcos Costa

This new recipe's main purpose is to handle xxd in the simplest way possible, stripping it from any needless tasks and/or dependencies that come from the fact it was originally provided by the same recipe as Vim.

Not only this recipe is faster to build, but it still provides the very same program for both build-time and run-time, so there should be no migration needed by the recipes depend on xxd.

---
 meta/conf/distro/include/maintainers.inc |  1 +
 meta/recipes-support/vim/vim-xxd_9.2.bb  | 29 ++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
 create mode 100644 meta/recipes-support/vim/vim-xxd_9.2.bb
meta/conf/distro/include/maintainers.inc +1 -0
index f98305e930..7d45bfaf65 100644
@@ -871,6 +871,7 @@ RECIPE_MAINTAINER:pn-vala = "Unassigned <[email protected]>"
 RECIPE_MAINTAINER:pn-valgrind = "Mingli Yu <[email protected]>"
 RECIPE_MAINTAINER:pn-vim = "Unassigned <[email protected]>"
 RECIPE_MAINTAINER:pn-vim-tiny = "Unassigned <[email protected]>"
+RECIPE_MAINTAINER:pn-vim-xxd = "João Marcos Costa <[email protected]>"
 RECIPE_MAINTAINER:pn-virglrenderer = "Unassigned <[email protected]>"
 RECIPE_MAINTAINER:pn-volatile-binds = "Chen Qi <[email protected]>"
 RECIPE_MAINTAINER:pn-vte = "Unassigned <[email protected]>"
meta/recipes-support/vim/vim-xxd_9.2.bb new file +19 -0
new file mode 100644
index 0000000000..d876efec4e
@@ -0,0 +1,29 @@
+SUMMARY = "Hex dump and reverse utility from the Vim source tree"
+DESCRIPTION = "xxd is a small utility usually distributed with Vim that creates hex dumps from binary data and can also convert hex dumps back to their original form."
+SECTION = "console/utils"
+HOMEPAGE = "https://www.vim.org/"
+BUGTRACKER = "https://github.com/vim/vim/issues"
+
+require vim-sources.inc
+
+inherit update-alternatives
+
+PROVIDES += "xxd"
+
+do_compile() {
+    cd  ${S}/src/xxd;
+    oe_runmake xxd
+}
+
+do_install() {
+    install -d ${D}${bindir}

meta/recipes-support/vim/vim-xxd_9.2.bb line 29

Quoted 10 lines
meta/recipes-support/vim/vim-xxd_9.2.bb new file +10 -0
+    install -m 0755 src/xxd/xxd ${D}${bindir}
+}
+
+RPROVIDES:${PN} += "xxd"
+
+ALTERNATIVE:${PN} = "xxd"
+ALTERNATIVE_TARGET[xxd] = "${bindir}/xxd"
+ALTERNATIVE_LINK_NAME[xxd] = "${bindir}/xxd"
+
+BBCLASSEXTEND = "native nativesdk"

I don't think separating out vim-xxd while keeping vim in OE-core is a significant improvement. There's also the potential to miss CVEs unless we set CVE_PRODUCT to "vim" in vim-xxd, and that will just result in duplication of reports.

This also doesn't reduce the amount of time people will spend backporting CVE patches to the LTS branch, and time our LTS maintainer will need to spend reviewing them. So I'd still rather eject vim from OE-core if we can.

Best regards,

Signature · 1 line
Paul Barker
#4 lore raw

Re: [OE-core] [PATCH 2/4] vim-xxd: introduce new recipe for xxd

Hello

On 5/11/26 12:42, Paul Barker wrote:
(...)

Quoted 6 lines

I don't think separating out vim-xxd while keeping vim in OE-core is a significant improvement. There's also the potential to miss CVEs unless we set CVE_PRODUCT to "vim" in vim-xxd, and that will just result in duplication of reports.

Quoted 6 lines

This also doesn't reduce the amount of time people will spend backporting CVE patches to the LTS branch, and time our LTS maintainer will need to spend reviewing them. So I'd still rather eject vim from OE-core if we can.

Best regards,

I don't know how feasible it is to have xxd's source code (i.e. src/xxd/Makefile and src/xxd/xxd.c) in a separate repository, but a brutal/dirty workaround would keeping this couple of files in do_unpack and discard the rest of Vim's sources.

However, this would be somewhat a fork of xxd, so Vim CVEs would still need to be reviewed manually to determine whether they affect xxd.

In any case, having a separate recipe for xxd can make this whole thing easier, regardless if we keep vim in oe-core or not.

Signature · 2 lines
Best regards,
João Marcos Costa
#5 lore raw

Re: [OE-core] [PATCH 2/4] vim-xxd: introduce new recipe for xxd

In reply to João Marcos Costa

meta/recipes-support/vim/vim-xxd_9.2.bb

Quoted 5 lines · Joao Marcos Costa via lists.openembedded.org
meta/recipes-support/vim/vim-xxd_9.2.bb new file +5 -0
+SUMMARY = "Hex dump and reverse utility from the Vim source tree"
+DESCRIPTION = "xxd is a small utility usually distributed with Vim that creates hex dumps from binary data and can also convert hex dumps back to their original form."
+SECTION = "console/utils"
+HOMEPAGE = "https://www.vim.org/"
+BUGTRACKER = "https://github.com/vim/vim/issues”

If we’re being pedantic here, the license of xxd.c is actually "X11-MIT or GPL-2.0” not the Vim license.

Ross

#6 lore raw

Re: [OE-core] [PATCH 2/4] vim-xxd: introduce new recipe for xxd

Hi, Ross

Quoted 10 lines · Ross Burton

meta/recipes-support/vim/vim-xxd_9.2.bb

Quoted 5 lines · Joao Marcos Costa via lists.openembedded.org
meta/recipes-support/vim/vim-xxd_9.2.bb new file +5 -0
+SUMMARY = "Hex dump and reverse utility from the Vim source tree"
+DESCRIPTION = "xxd is a small utility usually distributed with Vim that creates hex dumps from binary data and can also convert hex dumps back to their original form."
+SECTION = "console/utils"
+HOMEPAGE = "https://www.vim.org/"
+BUGTRACKER = "https://github.com/vim/vim/issues”

If we’re being pedantic here, the license of xxd.c is actually "X11-MIT or GPL-2.0” not the Vim license.

Ross

Oops! Thanks for spotting this. I will wait for more feedback from others before sending a v2 with this fix.

Signature · 2 lines
Best regards,
João Marcos Costa
#7 lore raw

PATCH 3/4 vim: drop references to xxd in base recipe

In reply to João Marcos Costa

The new vim-xxd recipe provides a binary package shipping xxd, along with the update-alternative specific settings, and it also provides xxd for build-time.

Remove these settings in Vim's base recipe to avoid duplication and potential conflicts.

---
 meta/recipes-support/vim/vim_9.2.bb | 10 ----------
 1 file changed, 10 deletions(-)
meta/recipes-support/vim/vim_9.2.bb +0 -10
index fee9f055e9..8341dd5af8 100644
@@ -1,7 +1,5 @@
 require vim.inc
 
-PROVIDES = "xxd"
-
 RDEPENDS:${PN} = "ncurses-terminfo-base ${PN}-xxd"
 # Recommend that runtime data is installed along with vim
 RRECOMMENDS:${PN} = "${PN}-syntax ${PN}-help ${PN}-tutor ${PN}-vimrc ${PN}-common"
@@ -9,14 +7,6 @@ RRECOMMENDS:${PN} = "${PN}-syntax ${PN}-help ${PN}-tutor ${PN}-vimrc ${PN}-commo
 PACKAGECONFIG:class-native = ""
 BBCLASSEXTEND = "native nativesdk"
 
-PACKAGES =+ "${PN}-xxd"
-FILES:${PN}-xxd = "${bindir}/xxd"
-RPROVIDES:${PN}-xxd = "xxd"
-
-ALTERNATIVE:${PN}-xxd = "xxd"
-ALTERNATIVE_TARGET[xxd] = "${bindir}/xxd"
-ALTERNATIVE_LINK_NAME[xxd] = "${bindir}/xxd"
-
 # We override the default in security_flags.inc because vim (not vim-tiny!) will abort
 # in many places for _FORTIFY_SOURCE=2.  Security flags become part of CC.
 #
Signature · 1 line
2.43.0
#8 lore raw

PATCH 4/4 vim.inc: remove xxd from the destination directory

In reply to João Marcos Costa

Since the default target depends on xxd, building vim leads to building xxd as well, and this raises (for instance) the error below:

error: check_data_file_clashes: Package vim wants to install file /src/build/tmp/work/qemuriscv64-oe-linux/core-image-minimal/1.0/rootfs/usr/bin/xxd But that file is already provided by package vim-xxd

This is not the ideal approach, because we are just removing something after it is compiled instead of simply not compiling it in the first place.

That being said, merely compiling xxd does not add much (or any?) actual overhead.

---
 meta/recipes-support/vim/vim.inc | 4 ++++
 1 file changed, 4 insertions(+)
meta/recipes-support/vim/vim.inc +4 -0
index 74777864e7..4a7092e4a0 100644
@@ -97,6 +97,10 @@ do_install() {
 	# delete the block.
 	sed -i '/the mouse works just fine/,+4d' ${D}/${datadir}/${BPN}/vimrc
     fi
+
+    # FIXME: ideally, Vim's makefiles should be tweaked to not build xxd,
+    # considering xxd (vim-xxd) has its own recipe now
+    rm ${D}${bindir}/xxd
 }
 
 PARALLEL_MAKEINST = ""
Signature · 1 line
2.43.0
#9 lore raw
In reply to João Marcos Costa

Hi João,

Quoted 8 lines · João Marcos Costa

Hello,

Honestly, my main motivation to send this series comes from a time when I was building u-boot (meta-freescale) and I saw vim-native in Bitbake's tasks. It blew my mind that a bootloader somehow dependend on a text editor (yes, only to be built, not to be executed, I know), and the whole text editor was being built to provide nothing more than xxd.

Quoted 4 lines

Just to be clear, what bothers me is NOT u-boot depending on xxd. It is actually configuring and compiling Vim (considering the overhead this represents) only to use a single tiny piece of it.

What's the build time impact? Because it may not be worth it in terms of complexity.

Note that you also need to specify how much it impacts a build in which both vim and vim-xxd are brought in the final image, which will result in a biggest build time.

Cheers,
Quentin

#10 lore raw

Hello,

Quoted 11 lines · Quentin Schulz via lists.openembedded.org

Hi João,

Quoted 8 lines · João Marcos Costa

Hello,

Honestly, my main motivation to send this series comes from a time when I was building u-boot (meta-freescale) and I saw vim-native in Bitbake's tasks. It blew my mind that a bootloader somehow dependend on a text editor (yes, only to be built, not to be executed, I know), and the whole text editor was being built to provide nothing more than xxd.

Quoted 6 lines
Quoted 4 lines

Just to be clear, what bothers me is NOT u-boot depending on xxd. It is actually configuring and compiling Vim (considering the overhead this represents) only to use a single tiny piece of it.

What's the build time impact? Because it may not be worth it in terms of complexity.

I performed some tests and the data below comes from tmp/buildstats. In my local.conf:

BB_NUMBER_THREADS = "20"
PARALLEL_MAKE = "-j 20"

Before every run, I ran 'bitbake -c cleansstate XXXX + rm -rf tmp/':

1) Before the splitting:

$ bitbake vim-native

Elapsed time: 18.53 seconds
CPU usage: 3.9%

$ bitbake xxd-native

Elapsed time: 18.52 seconds
CPU usage: 3.9%

2) After the splitting:

$ bitbake vim-native

Elapsed time: 18.49 seconds
CPU usage: 4.0%

$ bitbake xxd-native

Elapsed time: 4.89 seconds
CPU usage: 0.8%

2.1) Since I'm not sure if the total elapsed time counts in the parsing time, let's also compare the time spent in specific tasks:

vim-native-9.2.0340-r0: do_configure
Elapsed time: 6.81 seconds

vim-native-9.2.0340-r0: do_compile
Elapsed time: 4.43 seconds

vim-xxd-native-9.2.0340-r0: do_configure
Elapsed time: 0.03 seconds

vim-xxd-native-9.2.0340-r0: do_compile
Elapsed time: 0.23 seconds

3) I also compared the 'pn-buildlist' for both targets, and xxd-native after the splitting is minimal, considering the only dependencies are defined by BASEDEPENDS.

Another thing to consider is the build time dependencies of vim were in sstate-cache, so this is not an entirely clean build. If that was the case, the delta would be even higher (once again: vim's DEPENDS vs. xxd's BASEDEPENDS).

Quoted 1 line

Note that you also need to specify how much it impacts a build in which both vim and vim-xxd are brought in the final image, which will result in a biggest build time.

Well, vim already RDEPENDs on vim-xxd, so by default they are installed together if you have 'vim' in IMAGE_INSTALL. After the split, it is true that both recipes will be built, but as per the numbers above, the time spent building vim-xxd-native is minimal.

As a matter of fact, I do believe that the total elapsed time counts in the parsing time, because a quick sum of the per-task elapsed time reveals that the whole thing takes roughly 2 seconds.

$ cat tmp/buildstats/20260511115114/vim-xxd-native-9.2.0340-r0/do_* | grep "Elapsed time" -B1

The major difference would be seen in the case where you have *only* vim-xxd in IMAGE_INSTALL:
- before the split, vim is built only to provide vim-xxd
- after the split, only vim-xxd is built and the same package is provided

I made my best effort to keep the runtime side identical so this doesn't break anything in the final image.

Signature · 2 lines
Best regards,
João Marcos Costa