Opened 2 years ago

Last modified 2 years ago

#64551 assigned defect

freeciv @2.6.6: X11 config tests gives -Wimplicit-function-declaration warning on exit, strcmp

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 functions named strcmp and exit. These appear to be true positives. The configuration code which the port uses fails to include <string.h> and <stdlib.h>.

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
%

I plan to make patches to the config code to include those headers, as part of the #62984 rewrite. I also plan to submit those patches to the upstream code base.

Change History (3)

comment:1 Changed 2 years ago by JDLH (Jim DeLaHunt)

The config.log entries related to exit and strcmp are:

… [snip] …
configure:31317: checking whether Xfuncproto was supplied
configure:31345: result: no
configure:31349: checking for compilable FUNCPROTO definition
configure:31382: /usr/bin/clang -c -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 -DLOCALEDIR="\"${datarootdir}/locale\"" -DBINDIR="\"${exec_prefix}/bin\"" conftest.c >&5
conftest.c:111:1: warning: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Wimplicit-function-declaration]
exit (0)
^
conftest.c:111:1: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit'
1 warning generated.
configure:31382: $? = 0
configure:31401: result: yes, determined: 15
configure:31407: checking for workable NARROWPROTO definition
configure:31491: /usr/bin/clang -o conftest -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -arch x86_64    -lSM -lICE -lXaw -lXt -lX11  -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -DLOCALEDIR="\"${datarootdir}/locale\"" -DBINDIR="\"${exec_prefix}/bin\"" -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -arch x86_64 conftest.c -liconv -pthread >&5
conftest.c:149:7: warning: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Wimplicit-function-declaration]
      exit (0);
      ^
conftest.c:149:7: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit'
1 warning generated.
… [snip] …
configure:31491: /usr/bin/clang -o conftest -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -arch x86_64    -lSM -lICE -lXaw -lXt -lX11  -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -DLOCALEDIR="\"${datarootdir}/locale\"" -DBINDIR="\"${exec_prefix}/bin\"" -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -arch x86_64 conftest.c -liconv -pthread >&5
conftest.c:149:7: warning: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Wimplicit-function-declaration]
      exit (0);
      ^
conftest.c:149:7: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit'
1 warning generated.
… [snip] …
configure:31516: result: no, cannot determine
configure:31519: checking whether Xfuncproto was determined
configure:31522: result: yes:  FUNCPROTO=15
… [snip, and the line numbers of configure may change a little] …
configure:36937: checking for working vsnprintf
configure:36993: /usr/bin/clang -o conftest -std=c11 -I/opt/local/include -DLOCALEDIR="\"${datarootdir}/locale\"" -DBINDIR="\"${exec_prefix}/bin\"" -L/opt/local/libexec/qt5/lib -L/opt/local/lib conftest.c -liconv -pthread >&5
conftest.c:176:5: warning: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Wimplicit-function-declaration]
    exit(1);
    ^
conftest.c:176:5: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit'
conftest.c:185:7: warning: implicitly declaring library function 'strcmp' with type 'int (const char *, const char *)' [-Wimplicit-function-declaration]
  if (strcmp(buffer, "1234"))
      ^
conftest.c:185:7: note: include the header <string.h> or explicitly provide a declaration for 'strcmp'
2 warnings generated.
configure:36993: $? = 0
configure:36993: ./conftest
configure:36993: $? = 0
configure:37004: result: yes
configure:37012: checking for vsnprintf
configure:37012: /usr/bin/clang -o conftest -std=c11 -I/opt/local/include -DLOCALEDIR="\"${datarootdir}/locale\"" -DBINDIR="\"${exec_prefix}/bin\"" -L/opt/local/libexec/qt5/lib -L/opt/local/lib conftest.c -liconv -pthread >&5
conftest.c:174:6: warning: incompatible redeclaration of library function 'vsnprintf' [-Wincompatible-library-redeclaration]
char vsnprintf ();
     ^
conftest.c:174:6: note: 'vsnprintf' is a builtin with type 'int (char *, unsigned long, const char *, struct __va_list_tag *)'
1 warning generated.
configure:37012: $? = 0
configure:37012: result: yes

Searching for the telltale strings "compilable FUNCPROTO definition" and "workable NARROWPROTO definition" takes us to m4/x.m4:251,266.

Reading the macros in m4/x.m4, it appears that both these configuration steps get skipped if we either a) supply an argument --with-x-funcproto=DEFS (e.g.: --with-x-funcproto='FUNCPROTO=15 NARROWPROTO'), or b) define a variable PROTO_DEFINES and have the xmkmf utility which creates a Makefile . a) is feasible for us to do in a Portfile. b) appears to be an ancient 1998-vintage Solaris thing.

When these configuration steps get run, they run macro FC_CHECK_X_PROTO_FUNCPROTO_COMPILE in lines 296:334, and then macro FC_CHECK_X_PROTO_NARROWPROTO_WORKS in lines 336:431. Each macros contains the line, #include <X11/Xfuncproto.h>. Inserting #include <stdlib.h> before this line will stop the -Wimplicit-function-declaration warning.

Searching for the telltale string "working vsnprintf" takes us to m4/vsnprintf.m4:13 . This macro, FC_FUNC_VSNPRINTF in lines 2:69, has a single C program which generates two -Wimplicit-function-declaration warnings. Inserting, after the existing #include <stdarg.h> line, the new lines:

#include <stdlib.h>
#include <string.h>

eliminates these two warnings.

comment:2 Changed 2 years ago by JDLH (Jim DeLaHunt)

comment:3 Changed 2 years ago by JDLH (Jim DeLaHunt)

The Freeciv project fixed this bug upstream in their S2_6, S3_0, S3_1, and master branches. We will see the fix in the 2.6.7 and 3.0 releases. However, for 2.6.6, I will patch m4/x.m4 and m4/vsnprint.m4 .

Note: See TracTickets for help on using tickets.