[m-rev.] for review: fix build problems with Visual Studio 2013
Julien Fischer
jfischer at opturion.com
Mon Jan 27 04:38:40 AEDT 2014
For review by anyone -- the main thing that needs to reviewed here is the
changes to README.MS-VisualC.
-----------------------------------
Make Mercury compile with Visual Studio 2013 (MSVC 12.0).
Fix some problems that were preventing the system from compiling properly with
MSVC.
(1) Visual Studio 2013 no longer includes the files NtWin32.Mak and Win32.Mak
which are required for building the Boehm GC with MSVC. (This appears to be an
issue with upstream Boehm as well.) The workaround here is to reference the
copies of this files included with the Windows 7 SDK. (This appears to be the
official Microsoft workaround for dealing with this problem for now.)
(2) Disable support for `--c-debug' when using MSVC. Using this option causes
MSVC to emit .pdb (Program Data Base), that contain the symbol information for
an object files. This causes a variety of problems:
(i) parallel builds are contending for the vc*.pdb file shared by all the
object files in a directory causing compilation to abort. (Compiling with
the -FS option is another solution to this -- it causes the compiler to
serialize access to the .pdb file -- but at the cost of slowing down
compilation.)
(ii) .pdb files are not cleaned up by realclean; compilation will abort
if a pdb file generated by a different version of MSVC is encountered.
(iii) we don't install the .pdb files alongside the libraries anyway.
This can be a source of linker warnings. (And shutting up the Microsoft
linker seems to be very difficult indeed ...)
(iv) compiling with -Zi (apparently) inhibits some C compiler optimizations.
Compiling with the older -Z7 (MSVC 7 style debugging info) option is another
alternative. Using that option causes MSVC to include symbol information in
the object files, instead of in a separate file.
For now (i.e. the 14.01 release), disabling `--c-debug' for MSVC is the
simplest way of addressing the above issues.
README.MS-VisualC:
Describe the problem with NtWin32.Mak and Visual Studio 2013 and
provide two possible workarounds.
Mention that `--c-debug' is not currently supported with MSVC and how
to re-enable it.
Simplify some of the instructions for setting up the build environment.
configure.ac:
scripts/mgnuc.in:
Disable `--c-debug' with MSVC.
scripts/prepare_install_dir.in:
Copy all makefile fragments for nmake into the boehm_gc directory for
the library grade installation. (This is in case the user copies
NtWin32.Mak etc into the boehm_gc directory as per the second of
the workarounds in README.MS-VisualC.)
slice/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
mfilterjavac/Mmakefile:
profiler/Mmakefile:
slice/Mmakefile:
Clean up any .pdb files. Note that one is generated for each
executable (regardless of whether -Zi is given to cl or not).
In addition, if -Zi is given to cl, there will be file named
vc<version>.pdb generated (where <version> is the version of MSVC being
used.)
Julien.
diff --git a/README.MS-VisualC b/README.MS-VisualC
index fbda35e..7d02dad 100644
--- a/README.MS-VisualC
+++ b/README.MS-VisualC
@@ -3,9 +3,9 @@
BUILDING WITH MICROSOFT VISUAL C++
Mercury has been ported to use the Microsoft Visual C++ compiler.
-It has been tested with both version 9.0 (2008) and version 10.0 (2010).
-Version 8.0 (2005) should also work but we have not tested that with
-Mercury recently.
+It has been tested with versions 9.0 (2008) through 12.0 (2013).
+Version 8.0 (2005) should also work but we have not tested that with Mercury
+recently.
-----------------------------------------------------------------------------
@@ -21,19 +21,15 @@ has been installed.
To make MSVC and its supporting tools available under the Cygwin or MSYS shells
do the following:
-(1) Open the Windows Command Prompt.
- (Start -> All Programs -> Accessories -> Command Prompt on Windows XP)
- (Start -> Accessories -> Command Prompt on Windows 7)
+(1) Open the Visual Studio Command Prompt.
+ This can typically be found in
+
+ Start -> Visual Studio YYYY -> Visual Studio Tools
-(2) Enter the following command:
+ although the name and location vary between different versions and editions
+ of Visual Studio. (YYYY is the year.)
- C:\> "%VS90COMNTOOLS%"\vsvars32.bat
-
- This command sets up the environment for MSVC version 9.0 (2008).
- For MSVC version 10.0 (2010) the corresponding environment variable
- is VS100COMNTOOLS.
-
-(3) Enter the following command to start the MSYS shell:
+(2) Enter the following command to start the MSYS shell:
C:\> C:\MinGW\MSYS\1.0\msys.bat
@@ -47,6 +43,22 @@ In order to install the C#, Erlang or Java grades you will require a C#,
Erlang or Java compiler to be included in the Windows PATH.
(See the relevant README files for further details, e.g. README.Java etc)
+
+*** IMPORTANT NOTE FOR USERS OF VISUAL STUDIO 2013 ***
+
+The Makefile for the Boehm garbage collector requires the files NtWin32.Mak and
+Win32.Mak to be present in the build environment. These files are *not*
+included with Visual Studio 2013 and must be copied or included from the
+Windows 7 (or 7.1) SDK.
+
+To include the above files, append the SDK directory to the end of the INCLUDE
+environment variable, for example (with the Windows 7.1 SDK):
+
+ C:\> set INCLUDE=%INCLUDE%;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1a\Include
+
+Alternatively, you can just copy the NtWin32.Mak and Win32.Mak files into the
+"boehm_gc" directory of the Mercury source tree.
+
-----------------------------------------------------------------------------
CONFIGURATION AND INSTALLATION
@@ -135,6 +147,14 @@ The MSVC port currently has a number of limitation:
* Creation of shared libraries (DLLs) is not currently supported.
+* The '--c-debug' option currently has no effect with MSVC since enabling
+ it disables some C compiler optimizations and also breaks parallel builds.
+
+ If you *really* want to enable support for C level debugging, then enable the
+ commented out definition of DEBUG_OPTS in scripts/mgnuc.in (in the "cl" case)
+ and also enable the commented out definition of CFLAGS_FOR_DEBUG in
+ configure.ac (in the "msvc*" case).
+
-----------------------------------------------------------------------------
POST-INSTALLATION CONFIGURATION
diff --git a/compiler/Mmakefile b/compiler/Mmakefile
index 045d8f5..da266bd 100644
--- a/compiler/Mmakefile
+++ b/compiler/Mmakefile
@@ -31,6 +31,8 @@ MAIN_TARGET=all
MERCURY_MAIN_MODULES = top_level
+PDBS = $(patsubst %,%.pdb,$(MERCURY_MAIN_MODULES))
+
VPATH = \
$(LIBRARY_DIR) \
$(MDBCOMP_DIR) \
@@ -238,6 +240,7 @@ clean_local:
realclean_local:
rm -f tags $(MC_PROG).stats Mercury.modules \
COMP_FLAGS COMP_FLAGS.date mercury_compile$(EXT_FOR_EXE)
+ rm -f $(PDBS) vc*.pdb
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
diff --git a/configure.ac b/configure.ac
index d3e552c..5a7e323 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4661,7 +4661,9 @@ case "$mercury_cv_cc_type" in
# Suppress the MSVC banner message.
CFLAGS_FOR_WARNINGS="-nologo"
CFLAGS_FOR_OPT=
- CFLAGS_FOR_DEBUG="-Zi"
+ # XXX See README.MS-Visual C for details of why we disable this.
+ #CFLAGS_FOR_DEBUG="-Zi"
+ CFLAGS_FOR_DEBUG
CFLAGS_FOR_NO_STRICT_ALIASING=
# Using the MSVC compiler implies that we must use
diff --git a/deep_profiler/Mmakefile b/deep_profiler/Mmakefile
index dbe94e4..51bdedf 100644
--- a/deep_profiler/Mmakefile
+++ b/deep_profiler/Mmakefile
@@ -47,6 +47,7 @@ ALL_DEEP_MODULES = \
MAIN_TARGET=all
MERCURY_MAIN_MODULES=$(ALL_DEEP_MODULES)
DEPEND=$(patsubst %,%.depend,$(ALL_DEEP_MODULES))
+PDBS=$(patsubst %,%.pdb,$(ALL_DEEP_MODULES))
ifeq ("$(ENABLE_DEEP_PROFILER)","yes")
INSTALL=install_cgi_progs
@@ -242,6 +243,7 @@ cs: $(mdprof_procrep.cs) $(cs_subdir)mdprof_procrep_init.c
realclean_local:
rm -f .deep_tags tags DEEP_FLAGS DEEP_FLAGS.date \
.mdbcomp_modules $(MDBCOMP_MODULES) mdbcomp.*.err
+ rm -f $(PDBS) vc*.pdb
#-----------------------------------------------------------------------------#
diff --git a/mfilterjavac/Mmakefile b/mfilterjavac/Mmakefile
index 57a4b68..a97a27f 100644
--- a/mfilterjavac/Mmakefile
+++ b/mfilterjavac/Mmakefile
@@ -30,6 +30,7 @@ ALL_MODULES = mfilterjavac
MAIN_TARGET=all
MERCURY_MAIN_MODULES=$(ALL_MODULES)
DEPEND=$(patsubst %,%.depend,$(ALL_MODULES))
+PDBS=$(patsubst %,%.pdb,$(ALL_MODULES))
VPATH = $(LIBRARY_DIR) $(SSDB_DIR)
@@ -125,7 +126,8 @@ cs: $(mfilterjavac.cs) $(cs_subdir)mfilterjavac_init.c
#-----------------------------------------------------------------------------#
realclean_local:
- rm -f .mfilterjavac_tags tags MFILTERJAVAC_FLAGS MFILTERJAVAC_FLAGS.date \
+ rm -f .mfilterjavac_tags tags MFILTERJAVAC_FLAGS MFILTERJAVAC_FLAGS.date
+ rm -f $(PDBS) vc*.pdb
#-----------------------------------------------------------------------------#
diff --git a/profiler/Mmakefile b/profiler/Mmakefile
index 79222e3..39a4d20 100644
--- a/profiler/Mmakefile
+++ b/profiler/Mmakefile
@@ -17,6 +17,8 @@ include Mercury.options
MAIN_TARGET=all
MERCURY_MAIN_MODULES=mercury_profile
+PDBS = $(patsubst %,%.pdb,$(MERCURY_MAIN_MODULES))
+
VPATH = $(LIBRARY_DIR) $(SSDB_DIR)
#-----------------------------------------------------------------------------#
@@ -98,6 +100,7 @@ ils: $(mercury_profile.ils)
realclean_local:
rm -f tags PROF_FLAGS PROF_FLAGS.date
+ rm -f $(PDBS) vc*.pdb
#-----------------------------------------------------------------------------#
diff --git a/scripts/mgnuc.in b/scripts/mgnuc.in
index 7ffc10a..1d8aac4 100644
--- a/scripts/mgnuc.in
+++ b/scripts/mgnuc.in
@@ -90,7 +90,9 @@ case "$CC" in
ANSI_OPTS=""
CHECK_OPTS="-nologo" # Suppress the MSVC banner message.
OPT_OPTS=""
- DEBUG_OPT="-Zi"
+ # See README.MS-VisualC for why we don't enable C level debugging.
+ #DEBUG_OPTS="-Zi"
+ DEBUG_OPTS=""
DISABLE_OPTS_OPT="-Od"
COMPILER=cl
;;
diff --git a/scripts/prepare_install_dir.in b/scripts/prepare_install_dir.in
index 0cfad03..bd1116f 100644
--- a/scripts/prepare_install_dir.in
+++ b/scripts/prepare_install_dir.in
@@ -43,7 +43,7 @@ mkdir ${installdir}/boehm_gc/cord
mkdir ${installdir}/boehm_gc/include
mkdir ${installdir}/boehm_gc/include/private
cp boehm_gc/NT_MAKEFILE ${installdir}/boehm_gc
-cp boehm_gc/gc.mak ${installdir}/boehm_gc
+cp boehm_gc/*.[Mm]ak ${installdir}/boehm_gc
cp boehm_gc/Makefile* ${installdir}/boehm_gc
cp boehm_gc/Mmake* ${installdir}/boehm_gc
cp boehm_gc/ac* ${installdir}/boehm_gc
diff --git a/slice/Mmakefile b/slice/Mmakefile
index 53e934c..77813b2 100644
--- a/slice/Mmakefile
+++ b/slice/Mmakefile
@@ -41,6 +41,7 @@ DEPENDS = $(patsubst %,%.depend,$(MERCURY_MAIN_MODULES))
INTS = $(patsubst %,%.ints,$(MERCURY_MAIN_MODULES))
INT3S = $(patsubst %,%.int3s,$(MERCURY_MAIN_MODULES))
CHECKS = $(patsubst %,%.check,$(MERCURY_MAIN_MODULES))
+PDBS = $(patsubst %,%.pdb,$(MERCURY_MAIN_MODULES))
VPATH = $(LIBRARY_DIR) $(SSDB_DIR)
@@ -204,6 +205,7 @@ ils: $(mslice.ils) $(mdice.ils) $(mtc_union.ils) $(mcov.ils) $(mtc_diff.ils)
realclean_local:
rm -f tags SLICE_FLAGS SLICE_FLAGS.date \
.mdbcomp_modules $(MDBCOMP_MODULES) mdbcomp.*.err
+ rm -f $(PDBS) vc*.pdb
#-----------------------------------------------------------------------------#
More information about the reviews
mailing list