On 14/11/2019 20:40, selva.n...@gmail.com wrote: > From: Selva Nair <selva.n...@gmail.com> > > Some compilers (e.g., clang) only issue a warning for > unsupported options unless additional flags such > as -Werror are used to convert the warning to an error. > > Add support for extra flags in ACL_CHECK_ADD_COMPILE_FLAGS. > > Note: a similar approach is used in AX_CHECK_COMPILE_FLAG > in autoconf archives.
I'm glad I didn't spend more time on thinking about this earlier today, as you have almost the same ideas as I had :) [...snip...] > > +# Usage: ACL_CHECK_ADD_COMPILE_FLAGS(flag, [extra-flags]) > +# Some compilers require extra flags to trigger an error on > +# unsupported options. E.g., clang requires -Werror. > AC_DEFUN([ACL_CHECK_ADD_COMPILE_FLAGS], [ > old_cflags="$CFLAGS" > - CFLAGS="$1 $CFLAGS" > - AC_MSG_CHECKING([whether the compiler acceppts $1]) > - AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [AC_MSG_RESULT([yes])], > + CFLAGS="$2 $1 $CFLAGS" > + AC_MSG_CHECKING([whether the compiler accepts $1]) > + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [AC_MSG_RESULT([yes])]; > CFLAGS="$1 $old_cflags", My idea was just to add -Werror right in the line above, and not extend the ACL_CHECK_ADD_COMPILE_FLAGS macro with another argument. But I stopped when I realized that GCC has some quirks as well, as I needed to ponder about this a bit. Clang is fairly consistent: * first with an unknown -Wno-* argument $ clang-6.0 -o test test.c -Wall -Wno-non-existing-flag warning: unknown warning option '-Wno-non-existing-flag'; did you mean '-Wno-non-virtual-dtor'? [-Wunknown-warning-option] $ clang-6.0 -o test test.c -Wall -Wno-non-existing-flag -Werror error: unknown warning option '-Wno-non-existing-flag'; did you mean '-Wno-non-virtual-dtor'? [-Werror,-Wunknown-warning-option] * then with an unknown -W* argument (without the no- prefix) $ clang-6.0 -o test test.c -Wall -Wnon-existing-flag warning: unknown warning option '-Wnon-existing-flag'; did you mean '-Wnon-virtual-dtor'? [-Wunknown-warning-option] $ clang-6.0 -o test test.c -Wall -Wnon-existing-flag -Werror error: unknown warning option '-Wnon-existing-flag'; did you mean '-Wnon-virtual-dtor'? [-Werror,-Wunknown-warning-option] This is consistent and I can live with this behavior, using -Werror to bail out on warnings. So lets running the same tests with GCC: * first with an unknown -Wno-* argument $ gcc -o test test.c -Wall -Wno-non-existing-flag (no error nor warning) $ gcc -o test test.c -Wall -Wno-non-existing-flag -Werror (no error nor warning) * then with an unknown -W* argument (without the no- prefix) $ gcc -o test test.c -Wall -Wnon-existing-flag gcc: error: unrecognized command line option ‘-Wnon-existing-flag’ I think you said it pretty well in your mail: > Darn compilers and darn -Werror So your change does improve Clang ... I dunno what we will do with GCC. -- kind regards, David Sommerseth OpenVPN Inc
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel