https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111530
Bug ID: 111530 Summary: Unable to build GM2 standard library on BSD due to a `getopt_long_only' GNU extension dependency Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: modula2 Assignee: gaius at gcc dot gnu.org Reporter: macro at orcam dot me.uk Target Milestone: --- Target: *-*-netbsd* As in the summary the GM2 frontend fails to build for a BSD system, here the `vax-dec-netbsdelf' target specifically, due to an unguarded requirement for the presence of a GNU extension, `getopt_long_only' specifically, in the system C library. This is not a standard ISO C or POSIX function and is not therefore provided by NetBSD (version 9.0 here): .../gcc/libgm2/libm2pim/cgetopt.cc: In function 'int m2pim_cgetopt_getopt_long_only(int, char**, char*, const option*, int*)': .../gcc/libgm2/libm2pim/cgetopt.cc:74:11: error: 'getopt_long_only' was not declared in this scope; did you mean 'getopt_long'? 74 | int r = getopt_long_only (argc, argv, optstring, longopts, longindex); | ^~~~~~~~~~~~~~~~ | getopt_long make[5]: *** [Makefile:888: cgetopt.lo] Error 1 It is not clear to me from GM2 documentation if `getopt_long_only' is provided as a part of the standard Modula 2 language API (in which case it should be substituted, possibly from our in-tree libiberty) or just as a convenience pass-through to the system facility (in which case it should be disabled). Either way it has to be autoconf'd for and handled accordingly. NB NetBSD does implement `getopt_long' as an own extension (as indicated by the error message above) using an almost identical prototype, however documentation indicates the semantics is slightly different from GNU `getopt_long' for corner cases. I'm unsure if that matters for GM2, but thought it would be worth mentioning since I noticed that.