sys-devel/bc crash if you try to compile it using musl and GCC 15. It seems to be the same error of getopt() Reproducible: Always Steps to Reproduce: 1. Have a musl system 2. Install GCC 15 3. Try to compile sys-devel/bc Actual Results: The program cannot be compiled Expected Results: It should have compiled and installed successfully.
Created attachment 915345 [details] Build log
Created attachment 915346 [details] emerge --info
(In reply to meartzheast877 from comment #0) > sys-devel/bc doesn't compile using musl and GCC 15. It seems to be the same error of getopt() > > Reproducible: Always > > Steps to Reproduce: > 1. Have a musl system > 2. Install GCC 15 > 3. Try to compile sys-devel/bc > Actual Results: > The program cannot be compiled > > Expected Results: > It should have compiled and installed successfully.
x86_64-pc-linux-musl-gcc -DHAVE_CONFIG_H -I. -I.. -I. -I.. -I./../h -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -O2 -pipe -Wall -funsigned-char -O2 -pipe -Wall -funsigned-char -c -o number.o number.c getopt.c: In function '_getopt_initialize': getopt.c:348:21: error: too many arguments to function 'getenv'; expected 0, have 1 348 | posixly_correct = getenv ("POSIXLY_CORRECT"); | ^~~~~~ ~~~~~~~~~~~~~~~~~ getopt.c:200:14: note: declared here 200 | extern char *getenv (); | ^~~~~~ getopt.c: At top level: getopt.c:1135:1: error: conflicting types for 'getopt'; have 'int(int, char * const*, const char *)' 1135 | getopt (int argc, char *const *argv, const char *optstring) | ^~~~~~ In file included from getopt.c:106: ./../h/getopt.h:144:12: note: previous declaration of 'getopt' with type 'int(void)' 144 | extern int getopt (); | ^~~~~~ make[2]: *** [Makefile:319: getopt.o] Error 1
Temporary fix is to add -std=c99 and -Wno-implicit-function-declaration to CFLAGS
Problem exists in all versions currently in the tree.
Created attachment 928222 [details, diff] Patch to fix build on musl Patch that fixes compilation on musl; works with all versions. Also fixes some old-style prototypes. Tested by dropping into /etc/portage/patches/sys-devel/bc/
Note that I opted for the least intrusive changes to retrofit the prototypes so that it builds for the !__GNU_LIBRARY__ case. Another way is to unify the whole thing as done in e.g. https://github.com/gentoo/gentoo/pull/40514 but the result is really the same.
(In reply to Holger Hoffstätte from comment #7) > Created attachment 928222 [details, diff] [details, diff] > Patch to fix build on musl > > Patch that fixes compilation on musl; works with all versions. > Also fixes some old-style prototypes. > Tested by dropping into /etc/portage/patches/sys-devel/bc/ I also dropped it in /etc/portage/patches but portage doesn't use it for some reason Completely ignores it
$ll /etc/portage/patches/sys-devel/bc/musl.patch -rw-r--r-- 1 root root 1.8K May 9 19:21 /etc/portage/patches/sys-devel/bc/musl.patch $ebuild /var/db/repos/gentoo/sys-devel/bc/bc-1.08.1.ebuild prepare * bc-1.08.1.tar.gz BLAKE2B SHA512 size ;-) ... [ ok ] >>> Unpacking source... >>> Unpacking bc-1.08.1.tar.gz to /var/tmp/portage/sys-devel/bc-1.08.1/work >>> Source unpacked in /var/tmp/portage/sys-devel/bc-1.08.1/work >>> Preparing source in /var/tmp/portage/sys-devel/bc-1.08.1/work/bc-1.08.1 ... * ======================================================================================== * Applying user patches from /etc/portage/patches ... * Applying musl.patch ... [ ok ] * User patches applied. * ======================================================================================== >>> Source prepared.
False alarm it was a permission issue the patch works fine thanks
(In reply to zyxhere from comment #5) > Temporary fix is to add -std=c99 and -Wno-implicit-function-declaration to > CFLAGS FTR, simply -std=gnu17 should be enough. No need for -Wno* (it's a C23 issue). If you *did* need -Wno*, it was probably because of using -std=c instead of -std=gnu.