Re: Missing basename in util/test-path.c on musl-based systems

James Prestwood <[email protected]> Thu, 27 Feb 2025 07:02:05 -0800
Newsgroups dev.linux.lists.ell
Message-ID <[email protected]>
Hi,

On 2/23/25 8:43 AM, NHO wrote:
> In systems using musl as libc, eg. certain Gentoo profiles, tests of 
> ell fail to build, with error:
> clang -DHAVE_CONFIG_H -I.    -fvisibility=hidden 
> -DUNITDIR=\""./unit/"\" -DCERTDIR=\""./unit/"\" -O2 -pipe 
> -fsigned-char -Wno-unknown-warning-option -Wno-unknown-pragmas -c -o 
> unit/test-path.o unit/test-path.c
> unit/test-path.c:65:9: error: call to undeclared function 'basename'; 
> ISO C99 and later do not support implicit function declarations 
> [-Wimplicit-function-declaration]
>    65 |         base = basename(tmp_path);
>       |                ^
> unit/test-path.c:65:9: note: did you mean 'l_basename'?
> ./ell/path.h:20:13: note: 'l_basename' declared here
>    20 | const char *l_basename(const char *path);
>       |             ^
> unit/test-path.c:65:7: error: incompatible integer to pointer 
> conversion assigning to 'char *' from 'int' [-Wint-conversion]
>    65 |         base = basename(tmp_path);
>       |              ^ ~~~~~~~~~~~~~~~~~~
> 2 errors generated.
>
> Musl doesn't have GNU basename() in the string.h, only POSIX in libgen.h
> See also: Gentoo bug https://bugs.gentoo.org/942788
> second error appears to be a false positive.
>
I just sent a patch updating this test to use ELL's internal 
implementation, l_basename(). This should fix the build on musl.

Thanks,

James