Skip to content

Include libgen.h to fix musl builds#272

Merged
bkucman merged 1 commit into
md-raid-utilities:mainfrom
bkuhls:fixmusl
Feb 12, 2026
Merged

Include libgen.h to fix musl builds#272
bkucman merged 1 commit into
md-raid-utilities:mainfrom
bkuhls:fixmusl

Conversation

@bkuhls

@bkuhls bkuhls commented Nov 27, 2025

Copy link
Copy Markdown
Contributor

Fixes various build errors like

block.c: In function 'block_set_devnode':
block.c:226:22: error: implicit declaration of function 'basename'
 [-Wimplicit-function-declaration]
  226 |         char *name = basename(device->sysfs_path);

Recorded by the buildroot autobuilders:
https://autobuild.buildroot.net/results/942/942cb2dcd061b8620211b63d4be34dc414251b62/build-end.log

Alpine Linux contains a similar patch for ledmon v1.0.0:
https://gitlab.alpinelinux.org/p_q/aports/-/blob/master/testing/ledmon/gcc14-basename.patch

@bkucman

bkucman commented Dec 1, 2025

Copy link
Copy Markdown
Collaborator

Hi, thansk for your fix.

It looks like this fix breaks basic compatibility; I’ve already seen a solution for a similar issue that is safer.
md-raid-utilities/mdadm#12
md-raid-utilities/mdadm#14

bkuhls added a commit to bkuhls/ledmon that referenced this pull request Dec 1, 2025
If GNU basename is not avilable, define it. It is safer to use that
rather than include libgen.h with XPG basename() definition.

Suggested in
md-raid-utilities#272 (comment)

Code copied from
md-raid-utilities/mdadm@9dbd11e
@bkuhls

bkuhls commented Dec 1, 2025

Copy link
Copy Markdown
Contributor Author

I’ve already seen a solution for a similar issue that is safer.
md-raid-utilities/mdadm#12
md-raid-utilities/mdadm#14

Hi, thanks for the review. I force-pushed a new patch which fixes the problem reported by buildroot toolchains with musl and does not introduce build errors for uClibc and glibc. I hope that I used the correct header file.

@bkucman bkucman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
In my opinion, this is a right header for this define.

please fix style issues.

If GNU basename is not avilable, define it. It is safer to use that
rather than include libgen.h with XPG basename() definition.

Suggested in https://github.com/md-raid-utilities/ledmon/pull/
272#issuecomment-3596495739

Code copied from
md-raid-utilities/mdadm@9dbd11e

Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
@bkuhls
bkuhls requested a review from bkucman December 4, 2025 19:34
arnout pushed a commit to buildroot/buildroot that referenced this pull request Dec 30, 2025
Updated patch following an upstream review:
md-raid-utilities/ledmon#272 (comment)

Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
arnout pushed a commit to buildroot/buildroot that referenced this pull request Jan 13, 2026
Updated patch following an upstream review:
md-raid-utilities/ledmon#272 (comment)

Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
(cherry picked from commit b4668ed)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
arnout pushed a commit to buildroot/buildroot that referenced this pull request Jan 13, 2026
Updated patch following an upstream review:
md-raid-utilities/ledmon#272 (comment)

Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
(cherry picked from commit b4668ed)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
@bkucman
bkucman merged commit f79aa65 into md-raid-utilities:main Feb 12, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants