9.3 to 10.2 migration, determining if clang is used
papowell at astart.com
Tue Oct 13 18:35:03 UTC 2015
I just started doing a 9.3 to 10.2 migration of a bunch of applications
and discovered that some of the options used
to generate the applications were slightly different. I just know that
this has been covered before, but I could not
find a definitive method or set of methods to use to determine if the
old GCC compiler or the new CLANG compiler
is being used. Could the ports wizards (and/or autoconf experts) help
me a bit?
(Aside: the clang compiler diagnostics and warnings are very thorough
and quite clear. Nicely done, especially
the addition of the information about the flag to turn this warning
off. I also like the pragmas to
control warnings and the push/pop pragma facility. This may have been
in the GCC compiler but I missed it.)
1. If the application is to be generated via the PORT infrastructure,
what do you
put in the port Makefile to determine if CLANG (10.2) or GCC (9.3)
is being used?
Something like below. Note: the examples below are a bit contrived,
but the idea is to set
some MAKE variable to different values depending on CLANG or GCC in use.
MYFLAGS+= -Wall -Werror -Wno-error=unused
MYFLAGS+= -Wall -Werror -Wno-unused
2. A simple test for configure that checks the for the CLANG compiler:
# Check for programs
# we may need to add this to the configure macro set?
if test "$ac_cv_using_clang" = yes; then
CFLAGS="$CFLAGS -Wall -Werror -Wno-error=unused"
if test "$ac_cv_c_compiler_gnu" = yes; then
CFLAGS="$CFLAGS -Wall -Werror -Wno-unused"
It could even be something simpler if the AC_PROG_CC configure macro
sets, for example,
the $ac_gcc_version shell variable with a value that indicates CLANG
in use then the following
would be useful:
if test "$ac_gcc_version" -gt 999 ; then
Patrick Powell Astart Technologies
papowell at astart.com 1530 Jamacha Rd, Suite X
Network and System San Diego, CA 92019
Consulting 858-874-6543 FAX 858-751-2435
More information about the freebsd-ports