Opened 12 months ago

Closed 11 months ago

Last modified 5 months ago

#67504 closed defect (fixed)

Implicit function declaration detection code doesn't work with newer clang

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone: MacPorts 2.9.0
Component: base Version: 2.8.1
Keywords: haspatch Cc: neverpanic (Clemens Lang)
Port:

Description (last modified by ryandesign (Ryan Carsten Schmidt))

MacPorts fails to detect implicit declaration of function errors in configure scripts when using open source clang 15 or later or clang from Xcode 14 (?) or later because the wording of the error message has changed. For example trying the pkgconfig port:

% xcodebuild -version
Xcode 13.2.1
Build version 13C100
%
% sudo port clean pkgconfig     
--->  Cleaning pkgconfig
% sudo port configure pkgconfig
--->  Computing dependencies for pkgconfig
--->  Fetching distfiles for pkgconfig
--->  Verifying checksums for pkgconfig                                              
--->  Extracting pkgconfig
--->  Applying patches to pkgconfig
--->  Configuring pkgconfig
Warning: Configuration logfiles contain indications of -Wimplicit-function-declaration; check that features were not accidentally disabled:
  pthread_cond_timedwait_monotonic_np: found in pkg-config-0.29.2/glib/config.log
  pthread_condattr_setclock: found in pkg-config-0.29.2/glib/config.log
  strcmp: found in pkg-config-0.29.2/glib/config.log
  exit: found in pkg-config-0.29.2/glib/config.log
  pthread_cond_timedwait_monotonic: found in pkg-config-0.29.2/glib/config.log
%
% sudo port clean pkgconfig     
--->  Cleaning pkgconfig
% sudo port configure pkgconfig configure.compiler=macports-clang-15
--->  Computing dependencies for pkgconfig
--->  Fetching distfiles for pkgconfig
--->  Verifying checksums for pkgconfig
--->  Extracting pkgconfig
--->  Applying patches to pkgconfig
--->  Configuring pkgconfig
%

The wording of the errors when they debuted in Xcode 12 was originally:

error: implicitly declaring library function '…' with type '…' [-Werror,-Wimplicit-function-declaration]

and

error: implicit declaration of function '…' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

but now it has changed to:

error: call to undeclared library function '…' with type '…'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

and

error: call to undeclared function '…'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

Our code currently searches only for the regular expression (?:implicit declaration of function|implicitly declaring library function) '(\[^']+)' in config.log. This will have to be extended to catch the new wording as well, noting that in the new wording the function name is not in quotation marks in one of the messages. Perhaps we should structure the regexp so that it can work whether or not the function names are in quotes, in case they change one or the other message in the future for consistency.

We probably have to update the documentation in WimplicitFunctionDeclaration too.

Change History (4)

comment:1 Changed 12 months ago by ryandesign (Ryan Carsten Schmidt)

Description: modified (diff)

Excuse me, looking at the logs I see that the function names are still in quotes.

% grep -E ' implicit|call to undeclared' config.log.*
config.log.clang15:conftest.c:62:6: warning: call to undeclared library function 'exit' with type 'void (int) __attribute__((noreturn))'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
config.log.clang15:conftest.c:150:5: warning: call to undeclared library function 'exit' with type 'void (int) __attribute__((noreturn))'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
config.log.clang15:conftest.c:144:7: warning: call to undeclared library function 'strcmp' with type 'int (const char *, const char *)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
config.log.clang15:conftest.c:145:5: warning: call to undeclared library function 'exit' with type 'void (int) __attribute__((noreturn))'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
config.log.clang15:conftest.c:167:5: warning: call to undeclared library function 'exit' with type 'void (int) __attribute__((noreturn))'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
config.log.clang15:conftest.c:174:23: warning: call to undeclared function 'pthread_condattr_setclock'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
config.log.clang15:conftest.c:174:1: warning: call to undeclared function 'pthread_cond_timedwait_monotonic'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
config.log.clang15:conftest.c:174:1: warning: call to undeclared function 'pthread_cond_timedwait_monotonic_np'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
config.log.xcode13:conftest.c:62:6: error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
config.log.xcode13:conftest.c:62:6: error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
config.log.xcode13:conftest.c:62:6: error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
config.log.xcode13:conftest.c:149:5: error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
config.log.xcode13:conftest.c:142:7: error: implicitly declaring library function 'strcmp' with type 'int (const char *, const char *)' [-Werror,-Wimplicit-function-declaration]
config.log.xcode13:conftest.c:143:5: error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
config.log.xcode13:conftest.c:164:5: error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
config.log.xcode13:conftest.c:170:23: error: implicit declaration of function 'pthread_condattr_setclock' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
config.log.xcode13:conftest.c:170:1: error: implicit declaration of function 'pthread_cond_timedwait_monotonic' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
config.log.xcode13:conftest.c:170:1: error: implicit declaration of function 'pthread_cond_timedwait_monotonic_np' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

comment:2 Changed 12 months ago by ryandesign (Ryan Carsten Schmidt)

Keywords: haspatch added
Milestone: MacPorts Future

comment:3 Changed 11 months ago by ryandesign (Ryan Carsten Schmidt)

Owner: set to ryandesign
Resolution: fixed
Status: newclosed

In 1c483e276e41f88c0ccdd4f4defb412ad9591e06/macports-base (master):

Update implicit func decl detection for new clangs

Closes: #67504

comment:4 Changed 5 months ago by jmroot (Joshua Root)

Milestone: MacPorts FutureMacPorts 2.9.0
Note: See TracTickets for help on using tickets.