[nginx] svn commit: r4763 - trunk/auto/cc

ru at nginx.com ru at nginx.com
Tue Jul 24 15:17:04 UTC 2012


Author: ru
Date: 2012-07-24 15:17:03 +0000 (Tue, 24 Jul 2012)
New Revision: 4763
URL: http://trac.nginx.org/nginx/changeset/4763/nginx

Log:
Added the Clang compiler support.

The -Werror is commented out to not break builds on Linux.


Added:
   trunk/auto/cc/clang
Modified:
   trunk/auto/cc/conf
   trunk/auto/cc/name

Added: trunk/auto/cc/clang
===================================================================
--- trunk/auto/cc/clang	                        (rev 0)
+++ trunk/auto/cc/clang	2012-07-24 15:17:03 UTC (rev 4763)
@@ -0,0 +1,98 @@
+
+# Copyright (C) Nginx, Inc.
+
+
+# clang
+
+
+NGX_CLANG_VER=`$CC -v 2>&1 | grep 'clang version' 2>&1 \
+                           | sed -e 's/^.*clang version \(.*\)/\1/'`
+
+echo " + clang version: $NGX_CLANG_VER"
+
+have=NGX_COMPILER value="\"clang $NGX_CLANG_VER\"" . auto/define
+
+
+CC_TEST_FLAGS="-pipe"
+
+
+# optimizations
+
+#NGX_CLANG_OPT="-O2"
+#NGX_CLANG_OPT="-Oz"
+NGX_CLANG_OPT="-O"
+
+case $CPU in
+    pentium)
+        # optimize for Pentium
+        CPU_OPT="-march=pentium"
+        NGX_CPU_CACHE_LINE=32
+    ;;
+
+    pentiumpro | pentium3)
+        # optimize for Pentium Pro, Pentium II and Pentium III
+        CPU_OPT="-march=pentiumpro"
+        NGX_CPU_CACHE_LINE=32
+    ;;
+
+    pentium4)
+        # optimize for Pentium 4
+        CPU_OPT="-march=pentium4"
+        NGX_CPU_CACHE_LINE=128
+    ;;
+
+    athlon)
+        # optimize for Athlon
+        CPU_OPT="-march=athlon"
+        NGX_CPU_CACHE_LINE=64
+    ;;
+
+    opteron)
+        # optimize for Opteron
+        CPU_OPT="-march=opteron"
+        NGX_CPU_CACHE_LINE=64
+    ;;
+
+esac
+
+CC_AUX_FLAGS="$CC_AUX_FLAGS $CPU_OPT"
+
+
+CFLAGS="$CFLAGS -pipe $CPU_OPT"
+
+if [ ".$PCRE_OPT" = "." ]; then
+    PCRE_OPT="-O2 -pipe $CPU_OPT"
+else
+    PCRE_OPT="$PCRE_OPT -pipe"
+fi
+
+if [ ".$MD5_OPT" = "." ]; then
+    MD5_OPT="-O2 -pipe $CPU_OPT"
+else
+    MD5_OPT="$MD5_OPT -pipe"
+fi
+
+if [ ".$ZLIB_OPT" = "." ]; then
+    ZLIB_OPT="-O2 -pipe $CPU_OPT"
+else
+    ZLIB_OPT="$ZLIB_OPT -pipe"
+fi
+
+
+# warnings
+
+CFLAGS="$CFLAGS $NGX_CLANG_OPT -Wall -Wextra -Wpointer-arith"
+#CFLAGS="$CFLAGS -Wmissing-prototypes"
+
+# we have a lot of unused function arguments
+CFLAGS="$CFLAGS -Wno-unused-parameter"
+
+# stop on warning
+#CFLAGS="$CFLAGS -Werror"
+
+# debug
+CFLAGS="$CFLAGS -g"
+
+if [ ".$CPP" = "." ]; then
+    CPP="$CC -E"
+fi

Modified: trunk/auto/cc/conf
===================================================================
--- trunk/auto/cc/conf	2012-07-24 15:16:09 UTC (rev 4762)
+++ trunk/auto/cc/conf	2012-07-24 15:17:03 UTC (rev 4763)
@@ -56,6 +56,12 @@
             . auto/cc/gcc
         ;;
 
+        clang)
+            # Clang C compiler
+
+            . auto/cc/clang
+        ;;
+
         icc)
             # Intel C++ compiler 7.1, 8.0, 8.1
 

Modified: trunk/auto/cc/name
===================================================================
--- trunk/auto/cc/name	2012-07-24 15:16:09 UTC (rev 4762)
+++ trunk/auto/cc/name	2012-07-24 15:17:03 UTC (rev 4763)
@@ -67,6 +67,10 @@
     NGX_CC_NAME=gcc
     echo " + using GNU C compiler"
 
+elif `$CC -v 2>&1 | grep 'clang version' >/dev/null 2>&1`; then
+    NGX_CC_NAME=clang
+    echo " + using Clang C compiler"
+
 elif `$CC -V 2>&1 | grep 'Sun C' >/dev/null 2>&1`; then
     NGX_CC_NAME=sunc
     echo " + using Sun C compiler"



More information about the nginx-devel mailing list