Skip to content

Building with clang 16 #10947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andypost opened this issue Mar 26, 2023 · 3 comments
Closed

Building with clang 16 #10947

andypost opened this issue Mar 26, 2023 · 3 comments

Comments

@andypost
Copy link
Contributor

andypost commented Mar 26, 2023

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

@andypost
Copy link
Contributor Author

Providing -Wno-error=implicit-function-declaration flag still leaves difference in result script

-ac_cv_c_undeclared_builtin_options='none needed'
+ac_cv_c_undeclared_builtin_options='-fno-builtin'

@andypost
Copy link
Contributor Author

andypost commented Mar 26, 2023

The cause is

The -Wimplicit-function-declaration and -Wimplicit-int warnings now default

https://releases.llvm.org/16.0.0/tools/clang/docs/ReleaseNotes.html

algitbot pushed a commit to alpinelinux/aports that referenced this issue Mar 26, 2023
- remove _mv in favour of amove, fpm/status.html moved to share
- as clang16 is the default added -Wno-error=implicit-function-declaration php/php-src#10947
@andypost
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants