troglobit / finit

Fast init for Linux. Cookies included
https://troglobit.com/projects/finit/
MIT License
634 stars 63 forks source link

Build error using clang 17 on musl (call to undeclared function 'basename') #389

Closed Stargirl-chan closed 11 months ago

Stargirl-chan commented 11 months ago

Hello! Musl has removed the declaration of basename from string.h, which now causes a build error when using clang 17+ on musl. https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7

Error log snippet:

--- finit-mdadm.o ---
mdadm.c:61:12: error: call to undeclared function 'basename'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   61 |                         array = basename(gl->gl_pathv[i]);
      |                                 ^
mdadm.c:61:10: error: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
   61 |                         array = basename(gl->gl_pathv[i]);
      |                               ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
*** [finit-mdadm.o] Error code 1

make[2]: stopped in /build/iglunix/init/finit/src/finit-4.6/src

Full build log: https://pastebin.com/zQqms8X7

A possible solution would be to include libgen.h in the afflicting .c files to use the posix implementation of basename. I do not know if there is a better solution to fix the issue.

troglobit commented 11 months ago

Please submit a PR to add an include for libgen.h