[ovs-dev,v2,7/7] Add build system for compiling under MSVC x64
diff mbox

Message ID 1443029428-7768-1-git-send-email-aserdean@cloudbasesolutions.com
State Accepted
Headers show

Commit Message

Alin Serdean Sept. 23, 2015, 5:30 p.m. UTC
This patch adds the modifications needed to compile under x64 under
Windows:
- created a new macro for testing if we are compiling under x64.
this will define the linker flag: "/MACHINE:X64" as per documentation
(https://msdn.microsoft.com/en-us/library/9yb4317s.aspx).

- added x64 pthread libraries under the pthread defines

- add documentation on how to build under x64

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
---
 INSTALL.Windows.md  | 13 +++++++++++--
 Makefile.am         |  1 +
 configure.ac        |  1 +
 m4/openvswitch.m4   | 33 +++++++++++++++++++++++++++++++--
 windows/automake.mk |  2 +-
 5 files changed, 45 insertions(+), 5 deletions(-)

Comments

Gurucharan Shetty Sept. 28, 2015, 3:18 p.m. UTC | #1
On Wed, Sep 23, 2015 at 10:30 AM, Alin Serdean
<aserdean@cloudbasesolutions.com> wrote:
> This patch adds the modifications needed to compile under x64 under
> Windows:
> - created a new macro for testing if we are compiling under x64.
> this will define the linker flag: "/MACHINE:X64" as per documentation
> (https://msdn.microsoft.com/en-us/library/9yb4317s.aspx).
>
> - added x64 pthread libraries under the pthread defines
>
> - add documentation on how to build under x64
>
> Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
The change looks good to me. We still need the patch "MSVC 64 bit
compile error" to be applied before we apply this one.


> ---
>  INSTALL.Windows.md  | 13 +++++++++++--
>  Makefile.am         |  1 +
>  configure.ac        |  1 +
>  m4/openvswitch.m4   | 33 +++++++++++++++++++++++++++++++--
>  windows/automake.mk |  2 +-
>  5 files changed, 45 insertions(+), 5 deletions(-)
>
> diff --git a/INSTALL.Windows.md b/INSTALL.Windows.md
> index 889bb0b..d54bcb1 100644
> --- a/INSTALL.Windows.md
> +++ b/INSTALL.Windows.md
> @@ -34,10 +34,19 @@ will also need to install Windows Driver Kit (WDK) 8.1 Update.
>
>  It is important to get the Visual Studio related environment variables and to
>  have the $PATH inside the bash to point to the proper compiler and linker. One
> -easy way to achieve this is to get into the "Developer Command prompt for visual
> -studio" and through it enter into the bash shell available from msys by typing
> +easy way to achieve this is to get into the "VS2013 x86 Native Tools Command
> +Prompt"(I.E. in a default installation of Visual Studio 2013 this can be found
> +under the following location:
> +C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts)
> +and through it enter into the bash shell available from msys by typing
>  'bash --login'.
>
> +We also support compiling on 64 bit. To compile everything under x64 open the
> +"VS2013 x64 Native Tools Command Prompt"(if your current running OS is 64 bit)
> +or "VS2013 x64 Cross Tools Command Prompt"(if your current running OS is not 64
> +bit) instead of opening its x86 variant. This will point the compiler and the
> +linker to their 64 bit equivalent.
> +
>  If after the above step, a 'which link' inside MSYS's bash says,
>  "/bin/link.exe", rename /bin/link.exe to something else so that the
>  Visual studio's linker is used. You should also see a 'which sort' report
> diff --git a/Makefile.am b/Makefile.am
> index a659814..ab1a135 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -19,6 +19,7 @@ AM_CPPFLAGS += -I $(top_srcdir)/datapath-windows/include
>  AM_CPPFLAGS += $(PTHREAD_INCLUDES)
>  AM_CPPFLAGS += $(MSVC_CFLAGS)
>  AM_LDFLAGS += $(PTHREAD_LDFLAGS)
> +AM_LDFLAGS += $(MSVC64_LDFLAGS)
>  endif
>
>  AM_CPPFLAGS += -I $(top_srcdir)/include
> diff --git a/configure.ac b/configure.ac
> index 36387a1..fd04929 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -85,6 +85,7 @@ AC_SEARCH_LIBS([pthread_create], [pthread])
>  AC_FUNC_STRERROR_R
>
>  OVS_CHECK_ESX
> +OVS_CHECK_WIN64
>  OVS_CHECK_WIN32
>  OVS_CHECK_VISUAL_STUDIO_DDK
>  OVS_CHECK_COVERAGE
> diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
> index 087c7e5..98e5ce9 100644
> --- a/m4/openvswitch.m4
> +++ b/m4/openvswitch.m4
> @@ -70,6 +70,22 @@ AC_DEFUN([OVS_CHECK_ESX],
>        AC_DEFINE([ESX], [1], [Define to 1 if building on ESX.])
>     fi])
>
> +dnl Checks for MSVC x64 compiler.
> +AC_DEFUN([OVS_CHECK_WIN64],
> +  [AC_CACHE_CHECK(
> +    [for MSVC x64 compiler],
> +    [cl_cv_x64],
> +    [dnl "cl" writes x64 output to stdin:
> +     if (cl) 2>&1 | grep 'x64' >/dev/null 2>&1; then
> +       cl_cv_x64=yes
> +       MSVC64_LDFLAGS=" /MACHINE:X64 "
> +     else
> +       cl_cv_x64=no
> +       MSVC64_LDFLAGS=""
> +     fi])
> +     AC_SUBST([MSVC64_LDFLAGS])
> +])
> +
>  dnl Checks for WINDOWS.
>  AC_DEFUN([OVS_CHECK_WIN32],
>    [AC_CHECK_HEADER([windows.h],
> @@ -86,11 +102,24 @@ AC_DEFUN([OVS_CHECK_WIN32],
>              AC_MSG_ERROR([Invalid --with-pthread value])
>                ;;
>              *)
> -            PTHREAD_WIN32_DIR=$withval/lib/x86
> -            PTHREAD_WIN32_DIR_DLL=/${withval/:/}/dll/x86
> +            if (cl) 2>&1 | grep 'x64' >/dev/null 2>&1; then
> +              cl_cv_x64=yes
> +            else
> +              cl_cv_x64=no
> +            fi
> +            if test "$cl_cv_x64" = yes; then
> +                PTHREAD_WIN32_DIR=$withval/lib/x64
> +                PTHREAD_WIN32_DIR_DLL=/${withval/:/}/dll/x64
> +                PTHREAD_WIN32_DIR_DLL_WIN_FORM=$withval/dll/x64
> +            else
> +                PTHREAD_WIN32_DIR=$withval/lib/x86
> +                PTHREAD_WIN32_DIR_DLL=/${withval/:/}/dll/x86
> +                PTHREAD_WIN32_DIR_DLL_WIN_FORM=$withval/dll/x86
> +            fi
>              PTHREAD_INCLUDES=-I$withval/include
>              PTHREAD_LDFLAGS=-L$PTHREAD_WIN32_DIR
>              PTHREAD_LIBS="-lpthreadVC2"
> +            AC_SUBST([PTHREAD_WIN32_DIR_DLL_WIN_FORM])
>              AC_SUBST([PTHREAD_WIN32_DIR_DLL])
>              AC_SUBST([PTHREAD_INCLUDES])
>              AC_SUBST([PTHREAD_LDFLAGS])
> diff --git a/windows/automake.mk b/windows/automake.mk
> index c8165a4..fa610ec 100644
> --- a/windows/automake.mk
> +++ b/windows/automake.mk
> @@ -26,7 +26,7 @@ windows_installer: all
>         cp -f $(top_srcdir)/ovsdb/ovsdb-client.pdb windows/ovs-windows-installer/Symbols/
>         cp -f $(top_srcdir)/ovsdb/ovsdb-tool.pdb windows/ovs-windows-installer/Symbols/
>  #Third party files needed by the installer
> -       cp -f $(PTHREAD_TEMP_DIR)/../../dll/x86/*.dll windows/ovs-windows-installer/Binaries/
> +       cp -f $(PTHREAD_WIN32_DIR_DLL_WIN_FORM)/*.dll windows/ovs-windows-installer/Binaries/
>         cp -f "/c/Program Files (x86)/Common Files/Merge Modules/Microsoft_VC120_CRT_x86.msm" windows/ovs-windows-installer/Redist/Microsoft_VC120_CRT_x86.msm
>  #Forwarding extension files needed for the installer
>         cp -f $(top_srcdir)/datapath-windows/x64/Win8$(VSTUDIO_CONFIG)/package/ovsext.cat windows/ovs-windows-installer/Driver/Win8/ovsext.cat
> --
> 1.9.5.msysgit.0
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
Ben Pfaff Sept. 29, 2015, 4:42 a.m. UTC | #2
On Mon, Sep 28, 2015 at 08:18:54AM -0700, Gurucharan Shetty wrote:
> On Wed, Sep 23, 2015 at 10:30 AM, Alin Serdean
> <aserdean@cloudbasesolutions.com> wrote:
> > This patch adds the modifications needed to compile under x64 under
> > Windows:
> > - created a new macro for testing if we are compiling under x64.
> > this will define the linker flag: "/MACHINE:X64" as per documentation
> > (https://msdn.microsoft.com/en-us/library/9yb4317s.aspx).
> >
> > - added x64 pthread libraries under the pthread defines
> >
> > - add documentation on how to build under x64
> >
> > Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
> The change looks good to me. We still need the patch "MSVC 64 bit
> compile error" to be applied before we apply this one.

I applied an equivalent patch:
        https://patchwork.ozlabs.org/patch/523700/
Alin Serdean Sept. 29, 2015, 4:23 p.m. UTC | #3
Thx Ben :).

http://openvswitch.org/pipermail/dev/2015-September/060357.html can be dropped.

Could you take a look over the patch: http://openvswitch.org/pipermail/dev/2015-September/060441.html please.

Thanks,
Alin.

> -----Mesaj original-----
> De la: Ben Pfaff [mailto:blp@nicira.com]
> Trimis: Tuesday, September 29, 2015 7:42 AM
> Către: Gurucharan Shetty <shettyg@nicira.com>
> Cc: Alin Serdean <aserdean@cloudbasesolutions.com>;
> dev@openvswitch.org
> Subiect: Re: [ovs-dev] [PATCH v2 7/7] Add build system for compiling under
> MSVC x64
> 
> On Mon, Sep 28, 2015 at 08:18:54AM -0700, Gurucharan Shetty wrote:
> > On Wed, Sep 23, 2015 at 10:30 AM, Alin Serdean
> > <aserdean@cloudbasesolutions.com> wrote:
> > > This patch adds the modifications needed to compile under x64 under
> > > Windows:
> > > - created a new macro for testing if we are compiling under x64.
> > > this will define the linker flag: "/MACHINE:X64" as per
> > > documentation (https://msdn.microsoft.com/en-
> us/library/9yb4317s.aspx).
> > >
> > > - added x64 pthread libraries under the pthread defines
> > >
> > > - add documentation on how to build under x64
> > >
> > > Signed-off-by: Alin Gabriel Serdean
> > > <aserdean@cloudbasesolutions.com>
> > The change looks good to me. We still need the patch "MSVC 64 bit
> > compile error" to be applied before we apply this one.
> 
> I applied an equivalent patch:
>         https://patchwork.ozlabs.org/patch/523700/
Ben Pfaff Sept. 29, 2015, 5:41 p.m. UTC | #4
On Tue, Sep 29, 2015 at 04:23:52PM +0000, Alin Serdean wrote:
> Thx Ben :).
> 
> http://openvswitch.org/pipermail/dev/2015-September/060357.html can be dropped.
> 
> Could you take a look over the patch: http://openvswitch.org/pipermail/dev/2015-September/060441.html please.

I think that Guru already reviewed that (patch 7) and was just waiting
for the prerequisite (what I pushed) to go in.
Gurucharan Shetty Sept. 29, 2015, 6:18 p.m. UTC | #5
> I think that Guru already reviewed that (patch 7) and was just waiting
> for the prerequisite (what I pushed) to go in.
I applied this patch to master making some style changes to the documentation.
Alin Serdean Sept. 29, 2015, 6:27 p.m. UTC | #6
Ty!

> -----Mesaj original-----

> De la: Gurucharan Shetty [mailto:shettyg@nicira.com]

> Trimis: Tuesday, September 29, 2015 9:19 PM

> Către: Ben Pfaff <blp@nicira.com>

> Cc: Alin Serdean <aserdean@cloudbasesolutions.com>;

> dev@openvswitch.org

> Subiect: Re: [ovs-dev] [PATCH v2 7/7] Add build system for compiling under

> MSVC x64

> 

> > I think that Guru already reviewed that (patch 7) and was just waiting

> > for the prerequisite (what I pushed) to go in.

> I applied this patch to master making some style changes to the

> documentation.

Patch
diff mbox

diff --git a/INSTALL.Windows.md b/INSTALL.Windows.md
index 889bb0b..d54bcb1 100644
--- a/INSTALL.Windows.md
+++ b/INSTALL.Windows.md
@@ -34,10 +34,19 @@  will also need to install Windows Driver Kit (WDK) 8.1 Update.
 
 It is important to get the Visual Studio related environment variables and to
 have the $PATH inside the bash to point to the proper compiler and linker. One
-easy way to achieve this is to get into the "Developer Command prompt for visual
-studio" and through it enter into the bash shell available from msys by typing
+easy way to achieve this is to get into the "VS2013 x86 Native Tools Command
+Prompt"(I.E. in a default installation of Visual Studio 2013 this can be found
+under the following location:
+C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts)
+and through it enter into the bash shell available from msys by typing
 'bash --login'.
 
+We also support compiling on 64 bit. To compile everything under x64 open the
+"VS2013 x64 Native Tools Command Prompt"(if your current running OS is 64 bit)
+or "VS2013 x64 Cross Tools Command Prompt"(if your current running OS is not 64
+bit) instead of opening its x86 variant. This will point the compiler and the
+linker to their 64 bit equivalent.
+
 If after the above step, a 'which link' inside MSYS's bash says,
 "/bin/link.exe", rename /bin/link.exe to something else so that the
 Visual studio's linker is used. You should also see a 'which sort' report
diff --git a/Makefile.am b/Makefile.am
index a659814..ab1a135 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,6 +19,7 @@  AM_CPPFLAGS += -I $(top_srcdir)/datapath-windows/include
 AM_CPPFLAGS += $(PTHREAD_INCLUDES)
 AM_CPPFLAGS += $(MSVC_CFLAGS)
 AM_LDFLAGS += $(PTHREAD_LDFLAGS)
+AM_LDFLAGS += $(MSVC64_LDFLAGS)
 endif
 
 AM_CPPFLAGS += -I $(top_srcdir)/include
diff --git a/configure.ac b/configure.ac
index 36387a1..fd04929 100644
--- a/configure.ac
+++ b/configure.ac
@@ -85,6 +85,7 @@  AC_SEARCH_LIBS([pthread_create], [pthread])
 AC_FUNC_STRERROR_R
 
 OVS_CHECK_ESX
+OVS_CHECK_WIN64
 OVS_CHECK_WIN32
 OVS_CHECK_VISUAL_STUDIO_DDK
 OVS_CHECK_COVERAGE
diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
index 087c7e5..98e5ce9 100644
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -70,6 +70,22 @@  AC_DEFUN([OVS_CHECK_ESX],
       AC_DEFINE([ESX], [1], [Define to 1 if building on ESX.])
    fi])
 
+dnl Checks for MSVC x64 compiler.
+AC_DEFUN([OVS_CHECK_WIN64],
+  [AC_CACHE_CHECK(
+    [for MSVC x64 compiler],
+    [cl_cv_x64],
+    [dnl "cl" writes x64 output to stdin:
+     if (cl) 2>&1 | grep 'x64' >/dev/null 2>&1; then
+       cl_cv_x64=yes
+       MSVC64_LDFLAGS=" /MACHINE:X64 "
+     else
+       cl_cv_x64=no
+       MSVC64_LDFLAGS=""
+     fi])
+     AC_SUBST([MSVC64_LDFLAGS])
+])
+
 dnl Checks for WINDOWS.
 AC_DEFUN([OVS_CHECK_WIN32],
   [AC_CHECK_HEADER([windows.h],
@@ -86,11 +102,24 @@  AC_DEFUN([OVS_CHECK_WIN32],
             AC_MSG_ERROR([Invalid --with-pthread value])
               ;;
             *)
-            PTHREAD_WIN32_DIR=$withval/lib/x86
-            PTHREAD_WIN32_DIR_DLL=/${withval/:/}/dll/x86
+            if (cl) 2>&1 | grep 'x64' >/dev/null 2>&1; then
+              cl_cv_x64=yes
+            else
+              cl_cv_x64=no
+            fi
+            if test "$cl_cv_x64" = yes; then
+                PTHREAD_WIN32_DIR=$withval/lib/x64
+                PTHREAD_WIN32_DIR_DLL=/${withval/:/}/dll/x64
+                PTHREAD_WIN32_DIR_DLL_WIN_FORM=$withval/dll/x64
+            else
+                PTHREAD_WIN32_DIR=$withval/lib/x86
+                PTHREAD_WIN32_DIR_DLL=/${withval/:/}/dll/x86
+                PTHREAD_WIN32_DIR_DLL_WIN_FORM=$withval/dll/x86
+            fi
             PTHREAD_INCLUDES=-I$withval/include
             PTHREAD_LDFLAGS=-L$PTHREAD_WIN32_DIR
             PTHREAD_LIBS="-lpthreadVC2"
+            AC_SUBST([PTHREAD_WIN32_DIR_DLL_WIN_FORM])
             AC_SUBST([PTHREAD_WIN32_DIR_DLL])
             AC_SUBST([PTHREAD_INCLUDES])
             AC_SUBST([PTHREAD_LDFLAGS])
diff --git a/windows/automake.mk b/windows/automake.mk
index c8165a4..fa610ec 100644
--- a/windows/automake.mk
+++ b/windows/automake.mk
@@ -26,7 +26,7 @@  windows_installer: all
 	cp -f $(top_srcdir)/ovsdb/ovsdb-client.pdb windows/ovs-windows-installer/Symbols/
 	cp -f $(top_srcdir)/ovsdb/ovsdb-tool.pdb windows/ovs-windows-installer/Symbols/
 #Third party files needed by the installer
-	cp -f $(PTHREAD_TEMP_DIR)/../../dll/x86/*.dll windows/ovs-windows-installer/Binaries/
+	cp -f $(PTHREAD_WIN32_DIR_DLL_WIN_FORM)/*.dll windows/ovs-windows-installer/Binaries/
 	cp -f "/c/Program Files (x86)/Common Files/Merge Modules/Microsoft_VC120_CRT_x86.msm" windows/ovs-windows-installer/Redist/Microsoft_VC120_CRT_x86.msm
 #Forwarding extension files needed for the installer
 	cp -f $(top_srcdir)/datapath-windows/x64/Win8$(VSTUDIO_CONFIG)/package/ovsext.cat windows/ovs-windows-installer/Driver/Win8/ovsext.cat