forked from Mercury-Language/mercury
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.MS-VisualC
251 lines (165 loc) · 9.39 KB
/
README.MS-VisualC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
-----------------------------------------------------------------------------
BUILDING WITH MICROSOFT VISUAL C++
Mercury has been ported to use the Microsoft Visual C++ compiler.
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.
-----------------------------------------------------------------------------
SETTING UP THE BUILD ENVIRONMENT
A Unix-like environment is required for building and installing Mercury.
Either Cygwin <http://www.cygwin.com/> or MSYS <http://www.mingw.org/> will
suffice for this purpose.
A Unix-like environment is *not* required in order to use Mercury once it
has been installed.
To make MSVC and its supporting tools available under the Cygwin or MSYS shells
do the following:
(1) Open the Visual Studio Command Prompt.
This can typically be found in
Start -> Visual Studio YYYY -> Visual Studio Tools
although the name and location vary between different versions and editions
of Visual Studio. (YYYY is the year.)
(2) Enter the following command to start the MSYS shell:
C:\> C:\MinGW\MSYS\1.0\msys.bat
or this one to start the Cygwin shell:
C:\> C:\CYGWIN\cygwin.bat
(We assume the default installation locations for MinGW/MSYS and Cygwin above.)
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
The MSVC port of Mercury is compatible with the prebuilt C files contained in
the Mercury source distribution. The 'asm_fast' and 'reg' grades will not work
with MSVC (see below). When using the prebuilt C files the compiler will be
built in the 'none.gc' grade.
Alternatively, if you have an existing Mercury installation that uses the MinGW
or Cygwin GCC ports, or clang then you can checkout the Mercury source from the
CVS repository and use your existing installation to cross-compile the MSVC
port. In this case the compiler will be built using the more efficient
'hlc.gc' grade.
In either case, to use MSVC as the C compiler with Mercury, invoke configure
as follows:
$ ./configure --with-cc=cl [--with-msvcrt] [<any other options>]
The `--with-msvcrt' flag causes executables built with this install of Mercury
to be linked with the MS Visual C runtime, instead of the standard libC
runtime.
On Cygwin, configure and mmake will do translation of Unix style paths, so you
may specify the installation directory using either a Unix- or Window-style
path. On MSYS, you must use a full Windows-style path with a drive letter,
except that you must use '/' instead of `\' as a directory separator.
For example, this is acceptable:
$ ./configure --prefix="c:/where/to/install/mercury"
whereas the following is not:
$ ./configure --prefix="c:\where\to\install\mercury"
Once configure has successfully finished, then you should do
$ make
$ make install
as normal.
-----------------------------------------------------------------------------
LIMITATIONS
The MSVC port currently has a number of limitation:
* The 'asm_fast' and 'reg' grades do not work with MSVC.
Both use GNU extensions to C that MSVC does not provide.
* Time profiling does not (currently) work with MSVC.
Time profiling grades (those whose name contains the 'prof' grade component)
will not be installed.
Note that memory profiling _does_ work with MSVC. (Memory profiling grades
are those whose name contains the 'memprof' grade component.)
* Parallel grades (those whose name contains the `par' component) do not
currently work with MSVC.
In parallel grades the Mercury runtime currently requires the use of POSIX
threads; it has not currently been ported to use Windows threads.
(It might be possible to use the pthreads-win32 library with MSVC to
provide POSIX threads but we have not tested that yet.)
* Deep profiling, e.g. the *.profdeep grades, does not (currently) work
with MSVC. (In principle, it should work if the clock tick metric is
disabled.)
* The deep profiling tool (mdprof_cgi) does not currently work with MSVC.
This is due to it containing a number of Unix dependencies. (Other
tools that work with deep profiles should be fine.)
* Generation of 64-bit code using Mercury and MSVC is not yet supported.
To generate native 64-bit executables on Windows you will need to use
the MinGW64 port (see README.MinGW for details).
* When used directly from the Windows command prompt, mmake will not work.
You should use `mmc --make' instead. (mmake requires a POSIX-like shell
and GNU make; it will however work with the Cygwin or MSYS shells.)
Note that we have no intention of ever supporting mmake directly on
Windows.
* Creation of shared libraries (DLLs) is not currently supported.
* The '--c-debug' option currently has no effect with MSVC since enabling
it breaks parallel builds and disables some C compiler optimizations.
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). You will then need to regenerate
the configure script and rebuild the Mercury system. (See INSTALL.git for
details of how to do this.)
-----------------------------------------------------------------------------
POST-INSTALLATION CONFIGURATION
The above instructions create a Mercury installation that targets MSVC that
works from within the Cygwin or MSYS shells. If you want to be able to run the
Mercury compiler directly from the Windows command prompt (e.g. cmd.exe)
then you need to manually edit some configuration files in the installation.
(In future releases, this will all hopefully be automated.)
All references to files in the following are within the Mercury installation
directory
* By default, the Mercury compiler will attempt to use the "cp" command to
install files. Since Windows does not provide this, you will need to provide
an alternative (see the next section for details of how to do this).
We recommend installing the UnxUtils port of "cp" and using that with
Mercury. See: <http://sourceforge.net/projects/unxutils/>.
* In the file lib/mercury/conf/Mercury.config:
+ Replace any Unix-style paths with their Windows-style equivalent.
+ Modify the values of the options --host-env-type and --target-env-type
in the value of the variable DEFAULT_MCFLAGS so that their values are as
follows:
--host-env-type "windows"
--target-env-type "windows"
+ To specify the commands used to install files and directories include
the following options in the value of the variable DEFAULT_MCFLAGS
--install-command <cp>
--install-command-dir-option <opt>
(NOTE: if you are using the UnxUtils port of "cp" then you don't need to
do anything here; the default settings will suffice.)
* In the file lib/mercury/mdb/mdbrc
+ The backslash character, `\`, is used as an escape character in mdbrc
files. You need to escape it if it occurs in any paths used in argument
of source commands, e.g.
source c:\mercury-11.07\lib\mercury\mdb\mdb_doc
needs to be replaced with:
source c:\\mercury-11.07\\lib\\mercury\\mdb\\mdb_doc
+ Delete the aliases for the "open" and "grep" commands.
The scripts that implement these commands assume a Unix-style environment.
* The bin directory contains batch files equivalent to the mmc, mdb and prof
scripts. Note that the batch file equivalent to the mmc script is named
mercury.bat in order to avoid clashing with the executable for the
Microsoft Management Console.
* The following scripts do not currently have a Windows equivalent.
+ mprof_merge_runs
+ mtc
* The other shell scripts in the bin directory do not have (or need) Windows
equivalents. (Most of them are part of the implementation of mmake which
is not supported on Windows systems.)
-----------------------------------------------------------------------------
INSTALLING ON NETWORK DRIVES (Cygwin only)
If you want to install on the machine, foo, in the directory \usr\local
you need to add `--prefix //foo/usr/local' as an option to configure.
Then ensure that the directory that you wish to install into is mounted
somewhere, i.e.
mount //foo/usr/local /temp_mount_point
and then use that mount point as the location to install into
make install INSTALL_PREFIX=/temp_mount_point
This avoids the problem that
mkdir -p //foo/usr/local/xxx
fails.
-----------------------------------------------------------------------------