[Freeciv-tickets] [freeciv] #43737: Configure scripts give needless -Wimplicit-function-declaration errors on macOS

Zurück zum Archiv-Index
OSDN Ticket System norep****@osdn*****
Sat Jan 29 18:59:47 JST 2022


#43737: Configure scripts give needless -Wimplicit-function-declaration errors on macOS

  Open Date: 2022-01-29 11:15
Last Update: 2022-01-29 11:59

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 11:59 Updated by: cazfi
 * Milestone Update from (None) to 3.0.1

Comment:

Ok, so I assume these particular configure checks get run before our configure sets -Wimplicit-function-declaration itself, and have thus avoided getting caught when the option is not on by default.
From the MacPorts ticket it seems that two of the occurrences are from x11 configure checks, needed for xaw-client support in freeciv-2.6 and earlier. As xaw-client has been dropped from freeciv-3.0, I think these are already gone. This leaves one occurrence in vsnprintf.m4.

---------------------------------------------------------------------
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



More information about the Freeciv-tickets mailing list
Zurück zum Archiv-Index