• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

doc/H25-Sep-2003-2,6572,186

lib/H05-Oct-2006-48,95540,738

man/H03-Apr-2004-529508

rsrc/OOC/H06-Feb-2003-6,9784,970

src/H05-Oct-2006-85,20975,525

stage0/H05-Oct-2006-201,946185,733

tests/H05-Oct-2006-47,33338,582

COPYINGH A D05-Dec-200217.6 KiB341281

ENV.inH A D06-Dec-2002186 76

INSTALLH A D28-Dec-20045.3 KiB152108

MakefileH A D05-Oct-20067.7 KiB188109

Makefile.config.inH A D03-May-20221.5 KiB5844

PROBLEMSH A D30-Oct-20052.5 KiB7252

READMEH A D28-Dec-20044.9 KiB147104

README.MACOSH A D26-Sep-20033 KiB8158

README.WIN32H A D04-Jun-200414.2 KiB385283

aclocal.m4H A D12-Jul-20031.9 KiB6458

configureH A D05-Oct-2006225.7 KiB8,3797,176

configure.acH A D05-Oct-20062.6 KiB9481

install-shH A D14-Nov-20015.4 KiB252153

mkinstalldirsH A D20-Aug-2000730 4123

pkginfo.xmlH A D09-Nov-2004969 3127

README

1See file INSTALL for the list of software requirements and
2installation instructions.  See file PROBLEMS if installation turns
3out to be difficult.
4
5oo2c translates Oberon-2 source code into a variant of C supported by
6the gcc family of compilers.  It uses a variant of SSA for its
7intermediate representation, and performs common optimizations like
8common subexpression elimination, invariant code motion, constant
9propagation, algebraic transformations, and dead code removal.  The
10compiler relies on Boehm's gc for garbage collection.  A summary of
11the user visible changes from oo2c-1.5.9 to oo2c-2.0.x can be found in
12directory doc/from-v1-to-v2/.
13
14Operating system, architecture, and gcc combinations that are known to
15work:
16
17  Linux 2.4.19/i386/gcc 2.95.4 & 3.2.1
18  Linux 2.6.7/x86 and x86-64/gcc 3.4.1
19  SunOS 5.6/sparc/gcc 2.95.2 (32 bit)
20  SunOS 5.8/sparcv9/gcc 3.2.1 (64 bit)
21  Mac OS X/G3/gcc 2.95.2
22  Windows 2000/i386/cygwin gcc 2.95.3-5
23
24Starting with oo2c-2.0.11, there is an interface for POSIX threads.
25For this to work, both the garbage collector and oo2c must be build
26with `--enable-threads=pthreads'.  You can check that threading works
27by running the program src/TestThread.Mod.  If it completes without
28crashing or failed assertions you can be fairly sure that
29synchronization, exceptions, and heap management work as expected.
30See lib/src/liboo2c.Mod for some caveats regarding threading and other
31library modules.  Threads have been tested with Debian 3.0 (Linux 2.4,
32glibc 2.3.1, gc6.0+ and gc6.2) and Solaris 2.6 (gc6.2).
33
34
35
36Typical installation is quite simple:
37
38  tar xfvj oo2c_32-2.0.0.tar.bz2
39  cd oo2c_32-2.0.0
40  ./configure --prefix ~/mydir
41  make install
42
43For a fast and small installation, you can do
44
45  env OFLAGS="--no-rtc" CFLAGS="-O2 -pipe" ./configure  --prefix ~/mydir
46  make install-strip
47
48More information is available in INSTALL.
49
50
51Building programs is simple as well:
52
53  mkdir /tmp/test
54  cd /tmp/test
55  mkdir src
56  cat >src/T.Mod
57    MODULE T;
58    IMPORT Out;
59    BEGIN
60    Out.String("Hello");Out.Ln;
61    END T.
62  ~/mydir/bin/oo2c --make T
63
64And then `bin/T' should say `Hello'.  For more information, please
65refer to the man page of oo2c.
66
67Please use Sourceforge
68
69  https://sourceforge.net/tracker/?atid=103539&group_id=3539
70
71to report bugs and include the version you are using in the summary
72line.  This ensures that bug reports are not lost, and provides a
73convenient central location to collect information about bugs.
74
75For miscompiled code, that is, correct input code that produces a
76broken binary, please try to create a small program that will
77reproduce the error.  Ideally this program is a single module with
78just enough lines of code to trigger the bug.  Send me this module,
79together with the information on how the bug manifests itself, how to
80trigger the bug, and the version of oo2c you are using.
81
82For input modules that hang or crash the compiler, please send me the
83module or modules that trigger the problem.  This does not need to be
84small.  Don't send me module fragments!  Getting fragments into shape
85for the compiler to compile takes time that I would rather spend on
86debugging.
87
88Reporting about bugs can be a surprisingly difficult excercise in
89communication.  There is a very nice essay "How to Report Bugs
90Effectively" at http://www.chiark.greenend.org.uk/~sgtatham/bugs.html
91It should be recommended reading for everyone who will ever write --
92or read -- a bug report.
93
94
95Build and Install Using a CVS Working Copy
96==========================================
97
98To install a compiler from the bleeding edge CVS sources, you need to
99have the latest file release compiler installed.  Then, using this
100baseline compiler, create a bootstrap compiler from the CVS sources.
101Finally, run "make install" with the bootstrap compiler.
102
103Here are the recommended steps in detail.  First, the usual setup:
104
105  ~/sf-ooc/ooc2$ make cvsclean
106  ~/sf-ooc/ooc2$ cvs update -d
107  ~/sf-ooc/ooc2$ ./configure --prefix /tmp/test
108
109Then create a compiler binary bin/oo2c from the current sources
110(~/local-ooc2/bin/oo2c is the local installation of the latest file
111release in this example):
112
113  ~/sf-ooc/ooc2$ . ENV
114  ~/sf-ooc/ooc2$ make $OOC_DEV_ROOT/oo2crc-install.xml
115  ~/sf-ooc/ooc2$ ~/local-ooc2/bin/oo2c -M --config oo2crc-install.xml oo2c
116
117Use bin/oo2c to do "make install":
118
119  ~/sf-ooc/ooc2$ make install BOOTSTRAP_COMPILER=bin/oo2c
120
121This installs the compiler's data under the configured prefix,
122`/tmp/test' from the call to ./configure above.
123
124
125How to Create a Patch
126=====================
127
128To create a patch file relative to the current state of the CVS, first
129eliminate all derived files in the local working copy:
130
131  make cvsclean
132
133Update the working copy to the current head of the CVS:
134
135  cvs update -dP
136
137Resolve conflicts caused by the update (if any) and run the diff
138command:
139
140  cvs diff -u >../mypatch
141
142If "diff -u" does not work use "diff -c" as fallback.  The resulting
143file can be applied with "patch -p0 <file".
144
145
146-- Michael van Acken <mva@users.sf.net>
147

README.MACOS

1
2Using OOC under Mac OS
3======================
4
5This document describes options for using OOC on Apple Macintosh operating
6systems.
7
8OOC works under Darwin, Apple's open-source operating system based on 4.4BSD.
9OOC also works under OS X, which is based on Darwin. Earlier versions of Mac OS
10are not supported.
11
12OOC requires the GNU C compiler (gcc) which is available as part of the
13"Developer Tools" package available from Apple.
14
15Issues:
16======
17
181) Apple's distribution of gcc defaults to ANSI with precompiled headers. OOC
19requires GNU extensions. Precompiled headers often go wrong. The
20"-no-cpp-precomp" option must be specified to gcc.  This seems to fix both
21problems.
22
232) OOC requires Hans Boehm's conservative garbage collector. Until version 6.2,
24there were issues with dynamic loading and thread safety under Darwin. Also,
25earlier versions of the GC would only work reliably on specific versions of OS
26X. Users should install version 6.2 or later. If using threads, the argument
27"-DGC_DARWIN_THREADS" must be specified, both to build the GC and to build any
28clients of the GC library.
29
303) Apple supplies a version of libtool which is incompatible with the standard
31GNU libtool. OOC may detect this version, but it will not work. For dynamic
32library support, users should install GNU libtool. This is available as part of
33the "Fink" project (fink.sf.net). Alternatively, dynamic linking can be
34disabled by specifying "--disable-libs" during configuration.
35
36Installation:
37============
38
39- Install the developer tools from developer.apple.com. Download is free for
40  ADC (Apple Developer Connection) members. Free membership of ADC is
41  available. Developer tools are also available on CD.
42
43- Install version 6.2 (or later) of the GC. Specify "-DGC_DARWIN_THREADS" if
44  using threads.
45
46- If dynamic library support is required, install glibtool.
47
48- Follow the regular instructions. Common configurations are outlined below.
49
50  For static linking:
51    env "CFLAGS=-O2" "CPPFLAGS=-no-cpp-precomp" ./configure --disable-libs
52
53  For dynamic linking:
54    env "CFLAGS=-O2" "CPPFLAGS=-no-cpp-precomp" ./configure
55
56  For dynamic linking with threads:
57    env "CFLAGS=-O2" "CPPFLAGS=-no-cpp-precomp -DGC_DARWIN_THREADS" \
58      ./configure --enable-threads=pthreads
59
60Problems?
61========
62
631) While linking, the compiler complains about undefined GC_pthread_sigmask?
64   Make sure that you specify "-DGC_DARWIN_THREADS" in CPPFLAGS when
65   configuring OOC.
66
672) You installed programs or libraries with "Fink", but OOC cannot find them?
68   Fink does not install its components in the regular places (eg. /usr/local)
69   so the default searches will not work. As documented by Fink, you should
70   set the symbols CFLAGS, CXXFLAGS, CPPFLAGS and LDFLAGS to point to your
71   Fink installation. Normally, this is done in .cshrc using:
72     setenv CFLAGS -I/sw/include
73     setenv LDFLAGS -L/sw/lib
74     setenv CXXFLAGS $CFLAGS
75     setenv CPPFLAGS $CXXFLAGS
76     source /sw/bin/init.csh
77
78-- Stewart Greenhill <sgreenhill@users.sf.net>
79
80
81

README.WIN32

1
2Using OOC under Win32
3=====================
4
5This document describes options for using OOC on Windows systems.
6
7Currently, OOC requires the GNU C compiler (gcc). There are a couple of
8implementations of gcc under Windows:
9
101) Mingw32  (www.mingw.org)
112) Cygwin   (www.cygwin.com)
12
13Mingw32 is a "minimalist" implementation of gcc for Win32 systems. Mingw32
14applications link to Microsoft's own C run-time library (MSVCRTL.DLL),
15which is installed as part of every Windows system. Some features of
16Mingw32:
17- Mingw32 environment is compact.
18- Mingw32 applications are compact.
19- Run-time library functions have "Windows" semantics.
20- Some "Unix" functionality is not available.
21
22Cygwin is an implementation of the Unix API for Windows. Cygwin
23applications use GCC's run-time library as well as additional "emulation"
24functions in a separate library (CYGWIN.DLL). Some features of Cygwin:
25- Cygwin environment is very large.
26- Cygwin applications require an additional large DLL.
27- Run-time library functions have "Unix" semantics.
28- Cygwin is only free for GPL code. Use with non-GPL code requires a
29  special contract with the vendors.
30
31In many cases, Unix source code can run unmodified under Cygwin. Cygwin is
32typically distributed with a large collection of Unix utilities, including:
33- C compiler
34- Bash shell
35- ssh and cvs
36- XWindows client libraries
37- XWindows server
38- inetd and friends (supporting ftp and telnet into Windows systems).
39
40In addition, Cygwin supports the generation of Mingw applications via the
41"-mno-cygwin" option.
42
43OOC supports the following options:
44
45- Cygwin
46- Mingw stand-alone  (with MSYS)
47- Mingw under Cygwin
48
49Note: Some of these configurations have not been extensively tested. Please
50report any problems.
51
52Path virtualisation
53===================
54
55The C compiler and associated utilities are Unix applications that have
56been ported to run under Windows. Unix applications cannot be allowed to
57see DOS file names, or they would fail to handle files properly. Each
58application has its own file management procedures that assume Unix syntax.
59To port such applications to Windows, the run-time environment MUST map all
60DOS file paths to Unix syntax.
61
62Applications compiled with Cygwin will see Unix-style paths. Applications
63compiled with Mingw (or -mno-cygwin under Cygwin) will see Windows paths.
64
65OOC will see different styles of paths according to which environment is
66has been compiled under. However, the C compiler always sees virtual Unix
67paths. For OOC and gcc to play nicely together:
68
69  It is ESSENTIAL that OOC and gcc SEE THE SAME PATHS TO SOURCE FILES.
70
71Keep this in mind when installing the system.
72
73Note that OOC does not quote file names that are passed as arguments to the
74C compiler, so:
75
76  PATHS TO SOURCE FILES MAY NOT INCLUDE WHITESPACE.
77
78This may be an issue on Windows systems, in which the user's default working
79directory is called something like "Documents and Settings/myname". To use OOC
80under Windows, you will need a working directory that does not have spaces in
81its name (eg. C:/users/myname").
82
83Note that OOC uses an absolute path to name the "install" program. This means
84that the path detected by "configure" may not be usable by the generated
85compiler under mingw. To remedy this problem, specify the absolute path using
86the INSTALL environment variable.
87
88Installing the GC
89=================
90
91To do any serious work with OOC, you will need to install a garbage collector.
92This is a separate library used by the compiler and OOC applications for
93memory management. OOC uses Hans Boehm's GC, available here:
94  http://www.hpl.hp.com/personal/Hans_Boehm/gc/
95
96Follow the installation instructions for the GC. The following discussion
97applies for modern releases. It is recommended to use at least version
986.3alpha2.
99
1001) Build the GC library.
101
102  ./configure
103  make
104
1052) Ensure that the GC is working correctly.
106
107  Under Cygwin:
108    make gctest
109    ./gctest
110
111  Under MingW32, the test application is a Win32 application and writes its
112  output to a file "gc.log" rather than standard output.
113    make gctest.exe
114    ./gctest
115    cat gc.log
116
1173) Install the GC library
118
119  make install
120
1214) Review possible configuration settings for OOC
122
123Path issues:
124
125  Unless you specify another location to "configure" via the --prefix option,
126  the libraries will be installed in /usr/local/{lib,include}. Depending on
127  your local settings, this may not be the C compiler's search path. To ensure
128  that OOC finds the GC, you may need to use these settings:
129    CPPFLAGS=-I/usr/local/include
130    LDFLAGS=-L/usr/local/lib
131  It appears that these are necessary for MingW32/MSYS.
132
133Threading issues:
134
135  Versions of the GC differ in how threads are handled under Win32.
136
137  For modern releases of the GC, "configure" builds a threaded GC under
138  MingW32. This requires locks to be statically allocated by the GC. Under
139  Win32, this only works correctly if client code defines the symbol:
140    GC_WIN32_THREADS
141
142In summary, for MingW32/MSYS the following options are likely to be required
143by the GC in order to build OOC:
144	"CPPFLAGS=-I/usr/local/include -DGC_WIN32_THREADS" \
145	LDFLAGS=-L/usr/local/lib
146
147Installation
148============
149
1501) Make a directory `c:\usr\local\src', and extract the oo2c files here.
151
1522) Under MSYS or Cygwin, ensure that `c:\usr\local' is mapped to the
153   logical path `/usr/local'. Normally, one would do:
154
155     mount c:/usr/local /usr/local
156
157   If you encounter problems with the "mount" tool, see additional comments
158   below.
159
1603) `cd' to the directory containing the compiler source code.
161
1624) Configure the package.
163
164    For Cygwin:
165
166      env CFLAGS=-O2 ./configure --disable-libs
167
168
169    For stand-alone Mingw32 (adjust path to "install.exe"):
170
171	  env \
172	    "INSTALL=c:/msys/1.0/bin/install.exe" \
173	    LDFLAGS=-L/usr/local/lib \
174	    CFLAGS=-O2 \
175		"CPPFLAGS=-I/usr/local/include -DGC_WIN32_THREADS" \
176        ./configure --disable-libs
177
178    For Mingw32 under Cygwin:
179
180	  env CPPFLAGS=-mno-cygwin CFLAGS=-O2 LDFLAGS=-mno-cygwin \
181	    ./configure --disable-libs
182
183      (depending on path settings, INSTALL path may be required as above)
184
1855) Type `make' to compile the package.
186
1876) Type `make install' to install the programs and any data files and
188   documentation.  `make install-strip' will additionally remove any
189   debug information from the installed executables.
190
1917) You can remove the program binaries and object files from the
192   source code directory by typing `make clean'.  To also remove the
193   files that `configure' created (so you can compile the package for
194   a different kind of computer), type `make distclean'.
195
196Problems?
197=========
198
1991) In at least one version of MSYS it looks like the "mount" tool is
200   broken.  If you keep getting "Function not implemented", you may need to
201   manually edit the MSYS fstab file (eg. C:\MSYS\1.0\etc\fstab). It should
202   look something like this:
203
204     c:/MinGW /mingw
205     c:/usr/local /usr/local
206
207   Note that MSYS must be restarted for any changes to take effect.
208
2092) OOC couldn't find "install" during "make install"? Depending on path
210   settings, the detected path to "install" may not be valid for mingw
211   executables. See the explanation in "Path Virtualisation" and try setting
212   the INSTALL path before running "configure". For a quick fix, manually
213   adjust the "install" entries in the generated "rsrc/OOC/oo2crc.xml" and
214   re-run "make install".
215
2163) While building OOC under MingW32, stage0/oo2c crashes abruptly? Most likely
217   you have a threaded GC, and have not defined "-DGC_WIN32_THREADS" during
218   configure. The crash is due to an uninitialised mutex in the GC. See
219   the section "Installing the GC".
220
2214) You installed the GC under MingW32, but OOC did not find it? By default
222   mingw32/MSYS does not search in /usr/local/{lib,include} where the GC is
223   normally installed. You will need to explicitly specify these locations
224   to the compiler via the LDPATH and CPPFLAGS environment variables. See
225   the section "Installing the GC".
226
2275) You have installed both cygwin and mingw32 toolchains, and the C compiler
228   is behaving strangely? Take care that you have the correct search paths
229   configured. As a general rule, you should not allow the MSYS shell to see
230   the cygwin compiler, and vice versa. The object files generated by the two
231   compilers are similar, but depend on different run-time libraries. If the
232   compiler sees the wrong object files at link-time you can expect to see
233   many undefined symbols.
234
235Platform-specific issues
236========================
237
238This section discusses features of OOC relevant to the Win32 platform.
239
240- Alignment. Many Win32 structure specify particular alignments. OOC
241  provides the following record flags to control the alignment of fields
242  within a record: ALIGN1 ALIGN2 ALIGN4 ALIGN8
243
244  Example:
245
246    tagMCI_WAVE_OPEN_PARMSA_struct* = RECORD [ALIGN1]
247      dwCallback* : DWORD;
248      wDeviceID* : MCIDEVICEID;
249      lpstrDeviceType* : LPCSTR;
250      lpstrElementName* : LPCSTR;
251      lpstrAlias* : LPCSTR;
252      dwBufferSeconds* : DWORD
253    END;
254
255- Calling Conventions. Most functions in the Win32 API are declared to use
256  "Pascal" (or "stdcall") calling convention. For Pascal calls, the callee
257  removes any parameters from the stack before returning from the
258  procedure.  In "C" calling convention (or "cdecl"), the caller removes
259  the parameters which permits the use of variable argument lists.
260
261  The "fastcall" calling convention is implemented by Microsoft's C compiler as
262  well as recent versions of GCC. Specifying "Fastcall" causes arguments to
263  functions to be passed in registers "where possible". For the x86, the first
264  two LONGINT or smaller arguments are passed (left to right) in the ECX and
265  EDX registers; all other arguments are passed right to left on the stack. The
266  callee removes arguments from the stack. On modern machines, the speed
267  benefits of fastcall are probably negligible, but it is occasionally used in
268  third-party application binary interfaces (ABIs) so it is included here for
269  compatibility with these libraries.
270
271  OOC allows calling convention to be specified in both Module declarations
272  and procedure declarations. For example, an interface module for a Win32
273  library is usually declared "Pascal":
274
275    MODULE WinApi [ INTERFACE "Pascal";
276      LINK LIB "kernel32"; LIB "user32"; LIB "gdi32" END];
277
278  Procedures or procedure types declared within the interface module will
279  inherit the specified calling convention.
280
281    WNDPROC* = PROCEDURE (p0 : HWND;
282	   p1 : UINT; p2 : WPARAM; p3 : LPARAM) : LRESULT;
283
284  In the above example, WinApi.WNDPROC inherits the "Pascal" convention
285  declared in the module header.  Exceptions from the module convention may
286  be declared per procedure. For example:
287
288    PROCEDURE wsprintfA* [ "C" ] (p0 : LPSTR; p1 : LPCSTR; ...) : LONGINT;
289
290  Regular Oberon-2 modules use the default calling convention, which is
291  compatible with "C". Oberon-2 functions to be used as Win32 call-backs
292  must therefore be explicitly declared "Pascal". For example:
293
294    IMPORT W := WinApi;
295
296    PROCEDURE MessageHandler ["Pascal"] (wnd : W.HWND;
297      msg : W.UINT; wParam : W.WPARAM; lParam : W.LPARAM) : W.LRESULT;
298
299- C string assignment. Libraries written for the "C" language generally
300  represent text strings using the "char *" data type. The Oberon-2
301  equivalent is "POINTER TO ARRAY OF CHAR", which is not normally
302  compatible with Oberon strings types. The CSTRING pointer flag specifies
303  that "C"-style string assignments should be permitted. The following are
304  fragments from the Win32 API.
305
306    PCHAR* = POINTER [ CSTRING ] TO ARRAY OF CHAR;
307	...
308    LPCSTR* = PCHAR;
309	...
310    PROCEDURE MessageBoxA* (hWnd : HWND;
311	  lpText : LPCSTR; lpCaption : LPCSTR; uType : UINT) : LONGINT;
312
313  The declaration of WinApi.MessageBoxA allows strings or character arrays
314  to be passed as the second and third parameters. For example:
315
316    IMPORT W := WinApi;
317
318    PROCEDURE TestMessage;
319    VAR result : LONGINT;
320    BEGIN
321      result := W.MessageBoxA(0, "Hello!", "This is a test Message", 0);
322    END TestMessage;
323
324    PROCEDURE MessageBox(title, message : ARRAY OF CHAR);
325	VAR result : LONGINT;
326	BEGIN
327	  result := W.MessageBoxA(0, title, message, 0);
328	END;
329
330Implementation Issues
331=====================
332
3331) File rename.
334
335Windows file semantics do not allow open files to be renamed, or files to
336be renamed over existing files. Cygwin emulates Unix behaviour, but not on
337Win9X platforms.
338
339- Files.File.Register uses unlink/rename/re-open
340
341- IO:FileChannel uses the Win32 kernel function MoveFileEx to guarantee an
342  atomic rename operation. It is not clear which versions of Windows
343  support MoveFileEx.
344
3452) ftruncate()
346
347The ftruncate function is unavailable under Windows. This means that
348PosixFileDescr.Truncate will always return an error.
349
3503) Windows networking.
351
352Windows networking functions are in a separate library, WSOCK32.DLL, which
353is included if the relevant IO modules are used.  The networking library is
354configured as part of the initialisation for module IO:Socket. Note that
355Windows sockets are not file descriptors and require a separate set of
356functions to operate. For portable code, IO:SocketChannel should always be
357used for sockets.
358
3594) system()
360
361There are many issues associated with the system() run-time function.
362Under Unix, system() calls the Unix shell as its command interpreter.
363Under windows, system() calls the Windows command interpreter. These
364interpreters differ in their syntax and semantics. In addition, the
365Microsoft C start-up code has its own rules for interpreting the command
366line.
367
368There appear to be some limitations in the Windows command interpreter that
369prevent OOC passing long command lines to the C compiler (eg. as are
370required for static linking). Therefore, OS:ProcessManagement.system does
371not use the run-time library system() command. Instead, the command-line is
372passed directly to the command using the Win32 kernel CreateProcess
373function. This means that it is not possible to:
374- use piping redirection with a system command
375- specify substitutions using environment variables
376
377An option exists to use an external shell `/bin/sh' for the system command.
378This can be enabled by defining USE_SHELL in lib/src/OS/ProcessManagement.c.
379With an external shell, such as `bash' installed in `C:\bin', system()
380behaves the same as the Unix system() call. This configuration is necessary
381to use the test framework from the OOC CVS repository.
382
383-- Stewart Greenhill <sgreenhill@users.sf.net>
384
385