Opened 7 months ago

Closed 7 months ago

Last modified 6 months ago

#64550 closed defect (fixed)

freeciv @2.6.6: at_quick_exit gives -Wimplicit-function-declaration warning, false positive

Reported by: JDLH (Jim DeLaHunt) Owned by: JDLH (Jim DeLaHunt)
Priority: Normal Milestone:
Component: ports Version: 2.7.1
Keywords: Cc:
Port: freeciv

Description

When building freeciv @2.6.6 (work in progress, a major rewrite, see #62984), MacPorts prints a warning, "indications of -Wimplicit-function-declaration", regarding function named at_quick_exit. This is a false positive. The configuration code which the port uses does explicitly include <stdlib.h> to declare the function. My "Apple clang version 11.0.0 (clang-1100.0.33.12)" compiler apparently lacks that feature of the C11 standard library.

This is the initial warning from MacPorts:

% sudo port build freeciv-common
--->  Computing dependencies for freeciv-common
--->  Fetching distfiles for freeciv-common
--->  Verifying checksums for freeciv-common
--->  Extracting freeciv-common
--->  Configuring freeciv-common
Warning: Configuration logfiles contain indications of -Wimplicit-function-declaration; check that features were not accidentally disabled:
  strcmp: found in freeciv-2.6.6/config.log
  exit: found in freeciv-2.6.6/config.log
  at_quick_exit: found in freeciv-2.6.6/config.log
--->  Building freeciv-common
%

Change History (7)

comment:1 Changed 7 months ago by JDLH (Jim DeLaHunt)

More diagnosis on this warning.

In the config.log, the relevant configuration output is (with line breaks added for legibility):

configure:25690: checking for C11 at_quick_exit()
configure:25713: /usr/bin/clang -o conftest -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -arch x86_64 
-I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -Werror -Wall -Wpointer-arith -Wcast-align 
-Wno-tautological-compare -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk 
-arch x86_64 conftest.c  -liconv >&5
conftest.c:99:2: error: implicit declaration of function 'at_quick_exit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
 at_quick_exit(func);
 ^
1 error generated.
configure:25713: $? = 1
configure: failed program was:
| /* confdefs.h */
| …[lines omitted for brevity]…
| /* end confdefs.h.  */
| #include <stdlib.h>
| static void func(void)
| {}
| 
| int
| main (void)
| {
|  at_quick_exit(func);
|   ;
|   return 0;
| }
configure:25723: result: no

Note that this code does contain #include <stdlib.h>. Thus the function definition would not be implicit if the stdlib supported the at_quick_exit C11 language feature.

See email thread How to suppress -Wimplicit-function-declaration warning, if <stdlib.h> really does not have the declaration?, started Wed Jan 26 07:43:23 UTC 2022. Joshua Root replied,

we maintain lists of functions that are known not to exist on each macOS version, so the warning can be suppressed. They are in the ports tree here: <https://github.com/macports/macports-ports/tree/master/_resources/port1.0/checks/implicit_function_declaration>

So, I think the immediate workaround for this problem is to add at_quick_exit to the list at <https://github.com/macports/macports-ports/blob/master/_resources/port1.0/checks/implicit_function_declaration/macosx10.14.sdk.list>. I do not know how many other macOS versions are affected.

I also plan to file a bug upstream with FreeCiv developers, to see if they have a way to rewrite this configuration test so that it does not trigger a -Wimplicit-function-declaration warning from the compiler.

comment:2 Changed 7 months ago by JDLH (Jim DeLaHunt)

Port: freeciv added

Oops, enter "freeciv" in the Port field.

comment:3 in reply to:  1 Changed 7 months ago by jmroot (Joshua Root)

Replying to JDLH:

So, I think the immediate workaround for this problem is to add at_quick_exit to the list at <https://github.com/macports/macports-ports/blob/master/_resources/port1.0/checks/implicit_function_declaration/macosx10.14.sdk.list>.

That's not a workaround, that's the fix. Without this outside information, it's impossible to know whether the error is due to a missing include or due to the system not implementing the function.

I also plan to file a bug upstream with FreeCiv developers, to see if they have a way to rewrite this configuration test so that it does not trigger a -Wimplicit-function-declaration warning from the compiler.

Unlikely; that's just how autoconf works.

comment:4 Changed 7 months ago by JDLH (Jim DeLaHunt)

comment:5 Changed 7 months ago by Jim DeLaHunt <from+github@…>

Resolution: fixed
Status: assignedclosed

In d71265125e7d04e13abd716932aa21bf5b05b69e/macports-ports (master):

64550 Add 'at_quick_exit' to <= 10.14 whitelist

Apple clang version 11.0.0 (clang-1100.0.33.12) appears to lack the C11
language feature 'at_quick_exit' when compiling for macOS X 10.14. This
causes the compiler to generate a -Wimplicit-function-declaration
error message, even for correct configuration code, which correctly has
a #include <stdlib.h> directive. MacPorts elevates this to the
main.log. But it is a false positive. The configuration code is not
implicitly declaring 'at_quick_exit'. So, this function name belongs in
the whitelist.

An example of configuration code which demonstrates this condition is:

| #include <stdlib.h>
| static void func(void)
| {}
|
| int
| main (void)
| {
| at_quick_exit(func);
| ;
| return 0;
| }

The verbose compiler output from my test of this code on macOS X 10.14.6
Mojave, using the macOS X 10.14 SDK, is:

| % /usr/bin/clang -v -o conftest -std=c11 -Werror -Wall -Wpointer-arith -Wcast-align -Wno-tautological-compare conftest.c -liconv
| Apple clang version 11.0.0 (clang-1100.0.33.12)
| Target: x86_64-apple-darwin18.7.0
| Thread model: posix
| InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
| "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name conftest.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=10.14 -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -ggnu-pubnames -target-linker-version 520 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -Werror -Wall -Wpointer-arith -Wcast-align -Wno-tautological-compare -Wno-framework-include-private-from-public -Wno-atimport-in-framework-header -Wno-extra-semi-stmt -Wno-quoted-include-in-framework-header -std=c11 -fdebug-compilation-dir /Users/jdlh/workspace/freeciv_overall/freeciv_S2_6 -ferror-limit 19 -fmessage-length 132 -stack-protector 1 -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fobjc-runtime=macosx-10.14.0 -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/5p/zmlrjq6c8xj84s0059bnypz80000gp/T/conftest-901715.o -x c conftest.c
| clang -cc1 version 11.0.0 (clang-1100.0.33.12) default target x86_64-apple-darwin18.7.0
| ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
| ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
| #include "..." search starts here:
| #include <...> search starts here:
| /usr/local/include
| /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/include
| /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
| /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
| /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
| End of search list.
| conftest.c:99:2: error: implicit declaration of function 'at_quick_exit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
| at_quick_exit(func);
|
| 1 error generated.

Detected while diagnosing ticket #64550:
freeciv @2.6.6: at_quick_exit gives -Wimplicit-function-declaration
warning, false positive.

Closes: #64550

comment:6 Changed 6 months ago by JDLH (Jim DeLaHunt)

I did a port selfupdate on my local system. I see the result of this fix:

% cd /opt/local/var/macports//sources/rsync.macports.org/release/tarballs/ports/_resources/port1.0/                         
% grep at_quick_exit checks/implicit_function_declaration/macosx*.sdk.list 
checks/implicit_function_declaration/macosx10.10.sdk.list:at_quick_exit
checks/implicit_function_declaration/macosx10.11.sdk.list:at_quick_exit
checks/implicit_function_declaration/macosx10.12.sdk.list:at_quick_exit
checks/implicit_function_declaration/macosx10.13.sdk.list:at_quick_exit
checks/implicit_function_declaration/macosx10.14.sdk.list:at_quick_exit
checks/implicit_function_declaration/macosx10.4u.sdk.list:at_quick_exit
checks/implicit_function_declaration/macosx10.5.sdk.list:at_quick_exit
checks/implicit_function_declaration/macosx10.6.sdk.list:at_quick_exit
checks/implicit_function_declaration/macosx10.7.sdk.list:at_quick_exit
checks/implicit_function_declaration/macosx10.8.sdk.list:at_quick_exit
checks/implicit_function_declaration/macosx10.9.sdk.list:at_quick_exit

Thank you, Clemens, for your help!

comment:7 Changed 6 months ago by JDLH (Jim DeLaHunt)

I filed upstream ticket 43863 Configure script test for at_quick_exit (C11 feature) causes undesirable -Wimplicit-function-declaration error on macOS to ask the Freeciv project to change their configuration checks so that they don't generate -Wimplicit-function-declaration errors. I expect it will take quite some time for them to make such a change, if they do at all. Probably Freeciv versions 2.6.x and 3.0.x will continue to generate these errors.

The whitelisting of at_quick_exit in MacPorts should protect users from inconvenience for the immediate next Freeciv versions.

Note: See TracTickets for help on using tickets.