Menu

#144 Build fails on musl with implicit declaration of function basename error

None
closed-fixed
Jan Kara
None
5
2024-07-22
2024-07-20
listout
No

Building DiskQuota on musl fails with

quota.c: In function 'main':
quota.c:322:20: error: implicit declaration of function 'basename' [-Wimplicit-function-declaration[https://gcc.gnu.org/onlinedocs/gcc-14.1.0/gcc/Warning-Options.html#index-Wimplicit-function-declaration]]
  322 |         progname = basename(argv[0]);
      |                    ^~~~~~~~
quota.c:322:18: error: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion[https://gcc.gnu.org/onlinedocs/gcc-14.1.0/gcc/Warning-Options.html#index-Wint-conversion]]
  322 |         progname = basename(argv[0]);
      |                  ^

It's on musl there's in only one implementation of basename, unlike glibc. According to linux man page[0] there are two implementation of basename, one is the the POSIX version which comes from libgen.h and the GNU version which comes from string.h with _GNU_SOURCE defined.

A temporary fix is to use basename from libgen.h by default (attached patch).

1 Attachments

Discussion

  • listout

    listout - 2024-07-20
     
  • Jan Kara

    Jan Kara - 2024-07-22

    Thanks for the patch! After some thought I think this is actually going to be the most futureproof solution. I've just fixed up quota_nld.c (and removed the change to rquota.c) in your patch.

     
  • Jan Kara

    Jan Kara - 2024-07-22
    • status: open --> closed-fixed
    • Group: -->
     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB