On Mon, Apr 13, 2015 at 09:12:52PM -0400, Noah Misch wrote: > On Sun, Mar 08, 2015 at 12:13:44AM -0500, Noah Misch wrote: > > The Clang compiler furnishes implicit declarations for built-in functions, > > even when the identifier in question is not used as a function designator. > > This thwarts AC_CHECK_DECLS: > > > > configure:11565: checking whether strlcpy is declared > > configure:11565: clang -c -Wall -Wmissing-prototypes -Wpointer-arith > > -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute > > -Wformat-security -fno-strict-aliasing -fwrapv -g -O2 -D_GNU_SOURCE > > -I/usr/include/libxml2 conftest.c >&5 > > conftest.c:166:10: warning: implicitly declaring library function 'strlcpy' > > with type 'unsigned long (char *, const char *, unsigned long)' > > (void) strlcpy; > > ^ > > conftest.c:166:10: note: please include the header <string.h> or explicitly > > provide a declaration for 'strlcpy' > > 1 warning generated. > > configure:11565: $? = 0 > > configure:11565: result: yes > > > > > > Full config.log: > > http://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=treepie&dt=2015-03-07%2006%3A22%3A38&stg=config > > > > Clang has always behaved this way, but strlcpy() and strlcat() were > > unaffected > > until Clang 3.0 added them as builtins. To fix this, I plan to introduce > > ac_c_decl_warn_flag by analogy to ac_c_preproc_warn_flag. With no explicit > > declarations, a typical compiler (ac_c_decl_warn_flag='') reports an error > > for > > "(void) strchr;". Clang (ac_c_decl_warn_flag=yes) reports a warning, but > > adding a declaration silences the warning. A compiler that emits some > > warning > > with or without a declaration is unusable. > > Here is the patch. There's a risk that incidental warnings will make > AC_CHECK_DECL wrongly report a declaration missing. If, for example, an > AC_CHECK_DECL test includes a header that elicits a deprecation warning, that > test will report any declaration missing. The Autoconf test suite does pass > under "clang -Weverything -Wno-unused-macros -Wno-main" or "clang -Wno-main". > "-Wno-unused-macros" suppresses warnings about unused confdefs.h macros like > PACKAGE_URL, warnings which would otherwise snag on one of the new sanity > checks. (Unrelated to AC_CHECK_DECL, the "C unit tests" group needs > "-Wno-main".) I considered -fno-builtin instead of checking for warnings, but > the loss of realism outweighs the benefit of mitigating this risk.
In the absence of objections, I will commit this next week.
