MSVC has a '-O2' compiler optimization flag which makes code run
fast and is the recommended option for released code. For e.g.,
running "./tests/ovstest.exe test-cmap benchmark 1000000 3 1"
shows a 3x improvement for some cmap micro-benchmarks.

In the Visual Studio world, there is a concept of "release" build
(fast code, harder to debug) and a "debug" build (easier to debug).
The IDE provides this option and the IDE users expect something similar
for command line build.

So this commit, introduces a "--with-debug" configure option for Windows
and does not use '-O2' as a compiler option when specified. This can
be extended further if there are more compiler options that distinguish
a "release" build vs "debug" build.

Signed-off-by: Gurucharan Shetty <gshe...@nicira.com>
---
 INSTALL.Windows   |    3 +++
 Makefile.am       |    1 +
 build-aux/cccl    |    4 ++++
 m4/openvswitch.m4 |    8 ++++++++
 4 files changed, 16 insertions(+)

diff --git a/INSTALL.Windows b/INSTALL.Windows
index abe665d..dcab069 100644
--- a/INSTALL.Windows
+++ b/INSTALL.Windows
@@ -63,6 +63,9 @@ or from a distribution tar ball.
     --prefix="C:/openvswitch/usr" --localstatedir="C:/openvswitch/var" \
     --sysconfdir="C:/openvswitch/etc" --with-pthread="C:/pthread"
 
+    By default, the above enables compiler optimization for fast code.
+    For non-optimized code, pass the "--with-debug" configure option.
+
 * Run make for the ported executables in the top source directory, e.g.:
 
   % make
diff --git a/Makefile.am b/Makefile.am
index 3c2ae89..5ef9555 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,6 +16,7 @@ if WIN32
 AM_CPPFLAGS += -I $(top_srcdir)/include/windows
 AM_CPPFLAGS += -I $(top_srcdir)/datapath-windows/include
 AM_CPPFLAGS += $(PTHREAD_INCLUDES)
+AM_CPPFLAGS += $(RELEASE_CFLAGS)
 AM_LDFLAGS += $(PTHREAD_LDFLAGS)
 endif
 
diff --git a/build-aux/cccl b/build-aux/cccl
index c18629a..7074acd 100644
--- a/build-aux/cccl
+++ b/build-aux/cccl
@@ -89,6 +89,10 @@ EOF
         linkopt="$linkopt ${slash}DEBUG"
         ;;
 
+    -O2)
+        clopt="$clopt ${slash}O2"
+        ;;
+
     -L*)
         path=`echo "$1" | sed 's/-L//'`
         linkopt="$linkopt ${slash}LIBPATH:$path"
diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
index e918f25..2044e6b 100644
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -86,6 +86,14 @@ AC_DEFUN([OVS_CHECK_WIN32],
             AC_MSG_ERROR([pthread directory not specified])
          ]
       )
+      AC_ARG_WITH([debug],
+         [AS_HELP_STRING([--with-debug],
+            [Build without compiler optimizations])],
+         [ ], [
+            RELEASE_CFLAGS="-O2"
+            AC_SUBST([RELEASE_CFLAGS])
+         ]
+      )
 
       AC_DEFINE([WIN32], [1], [Define to 1 if building on WIN32.])
       AH_BOTTOM([#ifdef WIN32
-- 
1.7.9.5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to