Skip to content

Commit f9cbeaa

Browse files
orlitzkyGirgias
authored andcommitted
ext/imap/config.m4: -Werror=implicit-function-declaration compatibility.
The recent clang-16 throws errors for implicitly defined functions by default. In many ./configure tests, an undefined function (which is "implicitly defined" when you try to call it) is undefined because it really does not exist. But in one case, utf8_to_mutf7() is undefined because we forgot to include the header that defines it. This commit updates the test for utf8_to_mutf7: * We now include the header (c-client.h) that defines it. * A "checking... yes/no" message was added to the test. * The test was switched from PHP_IMAP_TEST_BUILD to AC_COMPILE_IFELSE. This was the easiest way to avoid a return-type mismatch that runs afoul of -Werror=implicit-int. * CPPFLAGS is temporarily amended with the -I flag needed to find c-client.h. Fixes GH-10947. Closes GH-10948 Signed-off-by: George Peter Banyard <[email protected]>
1 parent 4e0bd03 commit f9cbeaa

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ PHP NEWS
3232
. Fixed bug GH-10521 (ftp_get/ftp_nb_get resumepos offset is maximum 10GB).
3333
(nielsdos)
3434

35+
- IMAP:
36+
. Fix build failure with Clang 16. (orlitzky)
37+
3538
- MySQLnd:
3639
. Fixed bug GH-8979 (Possible Memory Leak with SSL-enabled MySQL
3740
connections). (nielsdos)

ext/imap/config.m4

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ AC_DEFUN([IMAP_LIB_CHK],[
1717
])
1818

1919
dnl PHP_IMAP_TEST_BUILD(function, action-if-ok, action-if-not-ok, extra-libs, extra-source)
20+
dnl
21+
dnl The UW-IMAP c-client library was not originally designed to be a
22+
dnl shared library. The mm_foo functions are callbacks, and are required
23+
dnl to be implemented by the program that is linking to c-client. This
24+
dnl macro does the work of defining them all to no-ops for you. Note
25+
dnl that PHP_TEST_BUILD is a link test; the undefined symbols will only
26+
dnl cause problems if you actually try to link with c-client. For
27+
dnl example, if your test is trivial enough to be optimized out, and if
28+
dnl you link with --as-needed, the test/library may be omitted entirely
29+
dnl from the final executable. In that case linking will of course
30+
dnl succeed, but your luck won't necessarily apply at lower optimization
31+
dnl levels or systems where --as-needed is not used.
2032
AC_DEFUN([PHP_IMAP_TEST_BUILD], [
2133
PHP_TEST_BUILD([$1], [$2], [$3], [$4], [$5]
2234
[
@@ -229,15 +241,23 @@ if test "$PHP_IMAP" != "no"; then
229241
AC_DEFINE(HAVE_IMAP_AUTH_GSS, 1, [ ])
230242
], [], $TST_LIBS)
231243

232-
dnl Check if utf8_to_mutf7 exists. We need to do some gymnastics because
233-
dnl utf8_to_mutf7 takes an argument and will segfault without it. We
234-
dnl therefore test another function utf8_to_mutf7_php() which calls
235-
dnl the utf8_to_mutf7() function with the empty string as an argument.
236-
PHP_IMAP_TEST_BUILD(utf8_to_mutf7_php, [
237-
AC_DEFINE(HAVE_IMAP_MUTF7, 1, [ ])
238-
], [], $TST_LIBS, [
239-
char utf8_to_mutf7_php(){ return utf8_to_mutf7(""); }
240-
])
244+
dnl Check if utf8_to_mutf7 exists.
245+
old_CPPFLAGS="${CPPFLAGS}"
246+
CPPFLAGS="${CPPFLAGS} -I${IMAP_INC_DIR}"
247+
AC_LANG_PUSH(C)
248+
AC_CACHE_CHECK(for utf8_to_mutf7, ac_cv_utf8_to_mutf7,
249+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <c-client.h>]],[[
250+
unsigned char c = '\0';
251+
utf8_to_mutf7(&c);
252+
]])],[
253+
AC_DEFINE(HAVE_IMAP_MUTF7, 1, [ ])
254+
ac_cv_utf8_to_mutf7=yes
255+
],[
256+
ac_cv_utf8_to_mutf7=no
257+
])
258+
)
259+
AC_LANG_POP
260+
241261

242262
AC_MSG_CHECKING(whether rfc822_output_address_list function present)
243263
PHP_TEST_BUILD(foobar, [

0 commit comments

Comments
 (0)