#43737: Configure scripts give needless -Wimplicit-function-declaration errors on macOS Open Date: 2022-01-29 11:15 Last Update: 2022-01-29 12:51 URL for this Ticket: https://osdn.net//projects/freeciv/ticket/43737 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=43737 --------------------------------------------------------------------- Last Changes/Comment on this Ticket: 2022-01-29 12:51 Updated by: cazfi Comment: Trying to figure out if we should still try to get fix for this to 3.0.0, as a freeze exception. Reply To jdlh macOS's Xcode compilers (based on clang) have applied -Werror and -Wimplicit-function-declaration options since about 2019. Does the '-Werror' here mean that the issue is an hard error, completely preventing freeciv compilation on MaxPorts? Ticket subject too seems to indicate an error, rather than warning. Another occurrence of a -Wimplicit-function-declaration, generated by Freeciv's configuration scripts, comes from a check on c11 functionality. It is not a matter of a missing #include. This will be the subject of a separate ticket. Does this mean that fixing this ticket alone would not make freeciv compilable on MacPorts, but also that future(?) ticket needs to be fixed to actually achieve anything making it worth freeze exception? --------------------------------------------------------------------- Ticket Status: Reporter: jdlh Owner: (None) Type: Bugs Status: Open Priority: 5 - Medium MileStone: 3.0.1 Component: Bootstrap Severity: 4 Resolution: None --------------------------------------------------------------------- Ticket details: Three configuration macros create simple C programs which, when compiled on macOS, needlessly cause -Wimplicit-function-declaration errors. Adding #include <stdlib.h> and #include <stdlib.h> to those macros prevents those warnings, without changing what the configuration macros are trying to check for. macOS's Xcode compilers (based on clang) have applied -Werror and -Wimplicit-function-declaration options since about 2019. They do this as part of support for the Apple ARM architecture CPUs. On those CPUs, the calling sequence for varargs functions differ from the calling sequence for functions with a fixed number of parameters. If a function prototype is not declared, the compiler is unable to guess which kind of args the function uses. This means that the programs generated by the configuration macros may, on macOS, fail to compile, instead of compiling and running. This means in turn that the macros may get the wrong result about the system's capabilities, and so they may configure Freeciv incorrectly. Also, defining functions without explicitly declaring them has been illegal C language since about the late 1980s, but many compilers have tolerated it. Thus, compiler errors have not been a reason to clean up these macros — until now. For more on the Xcode compiler issue, see the writeup in the MacPorts wiki at https://trac.macports.org/wiki/WimplicitFunctionDeclaration . Since 2021, the MacPorts distribution software has specifically elevated -Wimplicit-function-declaration errors to the user's attention. As an interim measure, the MacPorts distribution can patch Freeciv to prevent these errors. See MacPorts ticket #64551 freec****@2*****: X11 config tests gives -Wimplicit-function-declaration warning on exit, strcmp. In the long term, it helps MacPorts to distribute Freeciv if Freeciv can prevent these warnings upstream from MacPorts. The fix for all but one of these errors is simple: patch m4/x.m4 to add one line in each of two places, and patch m4/vsnprintf.m4 to add two lines in one place. I will attach patches to this ticket, which I have tested on the S2_6 branch, version 2.6.6 code. I will also test against the other branches, and produce different patches for those branches if necessary. Another occurrence of a -Wimplicit-function-declaration, generated by Freeciv's configuration scripts, comes from a check on c11 functionality. It is not a matter of a missing #include. This will be the subject of a separate ticket. -- Ticket information of Freeciv project Freeciv Project is hosted on OSDN Project URL: https://osdn.net/projects/freeciv/ OSDN: https://osdn.net URL for this Ticket: https://osdn.net/projects/freeciv/ticket/43737 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=43737