Created autoconf/ast_check_raii.m4: contains AST_CHECK_RAII which checks compiler requirements for RAII: gcc: -fnested-functions support clang: -fblocks (and if required -lBlocksRuntime) The original check was implemented in configure.ac and now has it's own file. This function also sets C_COMPILER_FAMILY to either gcc or clang for use by makefile Created autoconf/ast_check_strsep_array_bounds.m4 (contains AST_CHECK_STRSEP_ARRAY_BOUNDS): which checks if clang is able to handle the optimized strsep & strcmp functions (linux). If not, the standard libc implementation should be used instead. Clang + the optimized macro's work with: strsep(char *, char []), but not with strsepo(char *, char *). Instead of replacing all the occurences throughout the source code, not using the optimized macro version seemed easier See 'define __strcmp_gc(s1, s2, l2) in bits/string2.h': llvm-comment: Normally, this array-bounds warning are suppressed for macros, so that unused paths like the one that accesses __s1[3] are not warned about. But if you preprocess manually, and feed the result to another instance of clang, it will warn about all the possible forks of this particular if statement. Instead of switching of this optimization, another solution would be to run the preproces- sing step with -frewrite-includes, which should preserve enough information so that clang should still be able to suppress the diag- nostic at the compile step later on. See also "https://llvm.org/bugs/show_bug.cgi?id=20144" See also "https://llvm.org/bugs/show_bug.cgi?id=11536" Makefile.rules: If C_COMPILER_FAMILY=clang then add two warning suppressions: -Wno-unused-value -Wno-parentheses-equality In an earlier review (reviewboard: 4550 and 4554), they were deemed a nuisace and less than benefitial. configure.ac: Added AST_CHECK_RAII() see earlier Added AST_CHECK_STRSEP_ARRAY_BOUNDS() see earlier Removed moved content ASTERISK-24917 Change-Id: I12ea29d3bda2254ad3908e279b7effbbac6a97cb
57 lines
1.7 KiB
Text
57 lines
1.7 KiB
Text
dnl check RAII requirements
|
|
dnl
|
|
dnl gcc / llvm-gcc: -fnested-functions
|
|
dnl clang : -fblocks / -fblocks and -lBlocksRuntime"
|
|
AC_DEFUN([AST_CHECK_RAII], [
|
|
AC_MSG_CHECKING([for RAII support])
|
|
AST_C_COMPILER_FAMILY=""
|
|
AC_LINK_IFELSE(
|
|
[AC_LANG_PROGRAM([], [
|
|
int main() {
|
|
#if defined(__clang__)
|
|
choke
|
|
#endif
|
|
return 0;
|
|
}
|
|
])
|
|
],[
|
|
dnl Nested functions required for RAII implementation
|
|
AC_MSG_CHECKING(for gcc -fnested-functions)
|
|
AC_COMPILE_IFELSE(
|
|
dnl Prototype needed due to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36774
|
|
[
|
|
AC_LANG_PROGRAM([], [auto void foo(void); void foo(void) {}])
|
|
],[
|
|
AST_NESTED_FUNCTIONS=""
|
|
AC_MSG_RESULT(no)
|
|
],[
|
|
AST_NESTED_FUNCTIONS="-fnested-functions"
|
|
AC_MSG_RESULT(yes)
|
|
]
|
|
)
|
|
AC_SUBST(AST_NESTED_FUNCTIONS)
|
|
AST_C_COMPILER_FAMILY="gcc"
|
|
],[
|
|
AC_MSG_CHECKING(for clang -fblocks)
|
|
if test "`echo "int main(){return ^{return 42;}();}" | ${CC} -o /dev/null -fblocks -x c - 2>&1`" = ""; then
|
|
AST_CLANG_BLOCKS_LIBS=""
|
|
AST_CLANG_BLOCKS="-Wno-unknown-warning-option -fblocks"
|
|
AC_MSG_RESULT(yes)
|
|
elif test "`echo "int main(){return ^{return 42;}();}" | ${CC} -o /dev/null -fblocks -x c -lBlocksRuntime - 2>&1`" = ""; then
|
|
AST_CLANG_BLOCKS_LIBS="-lBlocksRuntime"
|
|
AST_CLANG_BLOCKS="-fblocks"
|
|
AC_MSG_RESULT(yes)
|
|
else
|
|
AC_MSG_ERROR([BlocksRuntime is required for clang, please install libblocksruntime])
|
|
fi
|
|
AC_SUBST(AST_CLANG_BLOCKS_LIBS)
|
|
AC_SUBST(AST_CLANG_BLOCKS)
|
|
AST_C_COMPILER_FAMILY="clang"
|
|
]
|
|
)
|
|
if test -z "${AST_C_COMPILER_FAMILY}"; then
|
|
AC_MSG_ERROR([Compiler ${CC} not supported. Mminimum required gcc-4.3 / llvm-gcc-4.3 / clang-3.3 + libblocksruntime-dev])
|
|
fi
|
|
AC_SUBST(AST_C_COMPILER_FAMILY)
|
|
])
|