Skip to content

Building with clang 16 #10947

Closed
Closed
@andypost

Description

@andypost

Description

The following code fails to pass configure check using clang 16

  • php-src/ext/imap/config.m4

    Lines 232 to 240 in 345abce

    dnl Check if utf8_to_mutf7 exists. We need to do some gymnastics because
    dnl utf8_to_mutf7 takes an argument and will segfault without it. We
    dnl therefore test another function utf8_to_mutf7_php() which calls
    dnl the utf8_to_mutf7() function with the empty string as an argument.
    PHP_IMAP_TEST_BUILD(utf8_to_mutf7_php, [
    AC_DEFINE(HAVE_IMAP_MUTF7, 1, [ ])
    ], [], $TST_LIBS, [
    char utf8_to_mutf7_php(){ return utf8_to_mutf7(""); }
    ])
    PHP_IMAP_TEST_BUILD(utf8_to_mutf7_php, [
      AC_DEFINE(HAVE_IMAP_MUTF7, 1, [ ])
    ], [], $TST_LIBS, [
      char utf8_to_mutf7_php(){ return utf8_to_mutf7(""); }
    ])

Resulted in this output:

configure:46317: clang -o conftest -O2 -fomit-frame-pointer -g -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Werror=implicit-function-declaration -fvisibility=hidden -Os -fomit-frame-pointer -D_GNU_SOURCE -Wl,--as-needed,-O1,--sort-common -Wl,-rpath,/lib -L/lib conftest.c  -lc-client -lcrypt  -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lssl -lcrypto -lrt -lm -lacl  -lxml2 -lpcre2-8 -lz >&5
conftest.c:330:40: error: call to undeclared function 'utf8_to_mutf7'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
      char utf8_to_mutf7_php(){ return utf8_to_mutf7(""); }
                                       ^
conftest.c:330:40: note: did you mean 'utf8_to_mutf7_php'?
conftest.c:330:12: note: 'utf8_to_mutf7_php' declared here
      char utf8_to_mutf7_php(){ return utf8_to_mutf7(""); }
           ^                           ~~~~~~~~~~~~~
                                       utf8_to_mutf7_php
1 error generated.
configure:46317: $? = 1
configure: failed program was:

But I expected this output instead:

configure:46317: clang -o conftest -O2 -fomit-frame-pointer -g -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wno-error=implicit-function-declaration -fvisibility=hidden -Os -fomit-frame-pointer -D_GNU_SOURCE -Wl,--as-needed,-O1,--sort-common -Wl,-rpath,/lib -L/lib conftest.c  -lc-client -lcrypt  -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lssl -lcrypto -lrt -lm -lacl  -lxml2 -lpcre2-8 -lz >&5
conftest.c:330:40: warning: call to undeclared function 'utf8_to_mutf7'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
      char utf8_to_mutf7_php(){ return utf8_to_mutf7(""); }
                                       ^
1 warning generated.
configure:46317: $? = 0
configure:46338: checking whether rfc822_output_address_list function present
configure:46381: clang -o conftest -O2 -fomit-frame-pointer -g -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wno-error=implicit-function-declaration -fvisibility=hidden -Os -fomit-frame-pointer -D_GNU_SOURCE -Wl,--as-needed,-O1,--sort-common -Wl,-rpath,/lib -L/lib conftest.c 
       -lc-client -lcrypt  -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lssl -lcrypto
     -lrt -lm -lacl  -lxml2 -lpcre2-8 -lz >&5
conftest.c:354:54: warning: non-void function does not return a value [-Wreturn-type]
      char foobar () {f = rfc822_output_address_list;}
                                                     ^
1 warning generated.
configure:46381: $? = 0
configure:46386: result: yes

Additionally comparing config.log I see another failues

configure:16558: clang -c -O2 -fomit-frame-pointer -g -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Werror=implicit-function-declaration -fvisibility=hidden  -Os -fomit-frame-pointer -D_GNU_SOURCE conftest.c >&5
conftest.c:123:8: error: call to undeclared library function 'strchr' with type 'char *(const char *, int)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
...
VS
...
configure:16558: clang -c -O2 -fomit-frame-pointer -g -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wno-error=implicit-function-declaration -fvisibility=hidden  -Os -fomit-frame-pointer -D_GNU_SOURCE conftest.c >&5
conftest.c:123:8: warning: call to undeclared library function 'strchr' with type 'char *(const char *, int)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
(void) strchr;
       ^
conftest.c:123:8: note: include the header <string.h> or explicitly provide a declaration for 'strchr'
1 warning generated.
configure:16558: $? = 0
configure:16558: clang -c -O2 -fomit-frame-pointer -g -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wno-error=implicit-function-declaration -fvisibility=hidden -fno-builtin -Os -fomit-frame-pointer -D_GNU_SOURCE conftest.c >&5
conftest.c:123:8: error: use of undeclared identifier 'strchr'
(void) strchr;
       ^
1 error generated.

PHP Version

PHP 8.2.4

Operating System

Alpinelinux https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/45389#note_298190

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions