Skip to content

Commit 412a8c3

Browse files
committed
Document compilation; remove OpenBSD debugging.
1 parent c638800 commit 412a8c3

File tree

11 files changed

+110
-319
lines changed

11 files changed

+110
-319
lines changed

ReadMe.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ default libraries complying with the Oakwood Guidelines for Oberon-2 compilers.
1414
### Contents
1515

1616
&nbsp;&nbsp;&nbsp;&nbsp;[**Installation**](#installation)<br>
17-
&nbsp;&nbsp;&nbsp;&nbsp;[**A 'Hello' application**](#a-hello-application)<br>
18-
&nbsp;&nbsp;&nbsp;&nbsp;[**Licensing**](#licensing)<br>
17+
&nbsp;&nbsp;&nbsp;&nbsp;[**Compiling a 'Hello' application**](#a-hello-application)<br>
18+
&nbsp;&nbsp;&nbsp;&nbsp;[**License**](#license)<br>
1919
&nbsp;&nbsp;&nbsp;&nbsp;[**Platform support and porting**](#platform-support-and-porting)<br>
2020
&nbsp;&nbsp;&nbsp;&nbsp;[**Language support and libraries**](#language-support-and-libraries)<br>
2121
&nbsp;&nbsp;&nbsp;&nbsp;[**History**](#history)<br>
@@ -138,6 +138,7 @@ executable binary.
138138

139139
Execute as usual on Linux (`./hello`) or Windows (`hello`).
140140

141+
For more details on compilation, see [**Compiling**](/doc/Compiling.md).
141142

142143
### Viewing the interfaces of included modules.
143144

@@ -163,7 +164,7 @@ END Out.
163164
```
164165

165166

166-
## Licensing
167+
## License
167168

168169
Vishap Oberon's frontend and C backend engine is a fork of Josef Templ’s Ofront, which has been released
169170
under the FreeBSD License. Unlike Ofront, Vishap Oberon does not include the Oberon v4 GUI environment.

doc/Compiling.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
## Compiling
2+
3+
An Oberon command line program is built from one or more modules. One module must be designated a main module.
4+
5+
### Files generated
6+
7+
From each non-main module the following files are generated in the current directory:
8+
9+
| Filename | Purpose |
10+
| ---------- | --------------------------------------------------------------------- |
11+
| ```module.sym``` | Oberon symbols required to ```IMPORT``` this module in another compilation.|
12+
| ```module.c``` | C source code for compilation by gcc, clang or msc. |
13+
| ```module.h``` | C header files required by C compiler when importing this module. |
14+
15+
Note that the filename of the .sym, .c and .h files is the name of the module from the ```MODULE``` statement at the start of the source file. It is not the name of the .mod file.
16+
17+
If the compilation is successful, the Oberon compiler will automatically invoke the C compiler. The compiler option ```-V``` will cause the compiler to display the C compiler command used.
18+
19+
### Successful compilation report
20+
21+
For a successful compilation, the compiler displays a single line comprising
22+
23+
* The name of the file being compiled
24+
* The name of the module from the ```MODULE``` statment
25+
* Compiler configuration (only if the ```-V``` verbose option is selected)
26+
* A possible symbol update status message
27+
* The number of characters compiled
28+
29+
If a symbols file already exists, the compiler will check whether the new compilation changes the symbols, and if so whether the change is just an extension, or a more serious compatability threatening modification. If there is a change the compiler displays either ```Extended symbol file``` or ```New symbol file```.
30+
31+
For example:
32+
33+
```
34+
$ voc test.mod
35+
test.mod Compiling test. New symbol file. 364 chars.
36+
```
37+
38+
### Symbol file changes
39+
40+
By default the compiler will refuse to compile a module if its symbols are different from those in the .sym file present from a previous compilation. To allow the compiler to change the symbols, one of the following options must be used.
41+
42+
| Compiler option | Use |
43+
| :-------------: | --------------------------- |
44+
| ```-e``` | Allow extension of symbols. Do not allow changes to existing symbols. |
45+
| ```-s``` | Allow changes to and extensions of symbols. |
46+
| ```-F``` | Force generation of new symbol file.* |
47+
48+
\* A new symbol file may be forced to guarantee that a symbol file is generated for a module that has the same name as an installed library module.
49+
50+
### Main module
51+
52+
The main module should be the last module compiled as it imports all other modules.
53+
54+
The program logic should be started from the main module's initialisation code.
55+
56+
The following options designate the main module:
57+
58+
| Compiler option | Use |
59+
| :-------------: | --------------------------- |
60+
| ```-m``` | Generate loadable binary using dynamic library loading (on systems that support it). |
61+
| ```-M``` | Generate loadable binary with all library references statically linked. |
62+
63+
For a main module, no .sym or .h files are generated, and the C compiler is called with additional parameters to generate the execututable binary, linking the object files needed for imported modules.
64+
65+
### Separate compilation
66+
67+
Each module may be compiled by a separate command line, although the imports of a module must be compiled before the module is compiled. All three generated files (.sym, .c and .h) must be retained at least until all modules dependent on this module have been compiled.
68+
69+
Multiple modules may be compiled on a single compiler command line.
70+
71+
Options on the command line that preceed all module file names will be used as global settings: each module will be compiled with these settings except as overriden on a per file basis.
72+
73+
Options on the command line that follow a module file name are specific to that module.
74+
75+
For example:
76+
77+
```
78+
voc -s alpha.mod beta.mod main.mod -m
79+
```
80+
81+
Will apply the ```-s``` option to all modules (allow changes to and extension of symbols), and will apply the ```-m``` option (main program) only to ```main.mod```.
82+

doc/Features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### Features
1+
## Features
22

33
#### 32 bit and 64 bit systems vs integer, set and address size.
44

src/compiler/Compiler.Mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ MODULE Compiler; (* J. Templ 3.2.95 *)
9999
Strings.Append(fn, objectnames)
100100
ELSE
101101
(* Found symbol file but no object file. *)
102-
OPM.LogVT100(VT100.Yellow);
102+
OPM.LogVT100(VT100.LightRed);
103103
OPM.LogWStr("Link warning: a local symbol file is present for module "); OPM.LogWStr(l.name);
104104
OPM.LogWStr(", but local object file '"); OPM.LogWStr(fn); OPM.LogWStr("' is missing.");
105105
OPM.LogVT100(VT100.ResetAll); OPM.LogWLn

src/compiler/OPM.Mod

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,18 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
137137
END
138138
END LogVT100;
139139

140+
PROCEDURE LogCompiling*(modname: ARRAY OF CHAR);
141+
BEGIN
142+
LogWStr("Compiling "); LogWStr(modname);
143+
IF verbose IN Options THEN
144+
LogWStr(", s:"); LogWNum(ShortintSize*8,1);
145+
LogWStr( " i:"); LogWNum(IntegerSize*8,1);
146+
LogWStr( " l:"); LogWNum(LongintSize*8,1);
147+
LogWStr( " adr:"); LogWNum(AddressSize*8,1);
148+
LogWStr( " algn:"); LogWNum(Alignment*8,1)
149+
END;
150+
LogW(".");
151+
END LogCompiling;
140152

141153

142154
(* Integer size support *)
@@ -299,20 +311,6 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
299311
END OpenPar;
300312

301313

302-
PROCEDURE VerboseListSizes;
303-
BEGIN
304-
LogWLn;
305-
LogWStr("Type Size"); LogWLn;
306-
LogWStr("SHORTINT "); LogWNum(ShortintSize, 4); LogWLn;
307-
LogWStr("INTEGER "); LogWNum(IntegerSize, 4); LogWLn;
308-
LogWStr("LONGINT "); LogWNum(LongintSize, 4); LogWLn;
309-
LogWStr("SET "); LogWNum(LongintSize, 4); LogWLn;
310-
LogWStr("ADDRESS "); LogWNum(AddressSize, 4); LogWLn;
311-
LogWLn;
312-
LogWStr("Alignment: "); LogWNum(Alignment, 4); LogWLn;
313-
END VerboseListSizes;
314-
315-
316314
PROCEDURE InitOptions*; (* get the options for one translation *)
317315
VAR s: ARRAY 256 OF CHAR; searchpath, modules: ARRAY 1024 OF CHAR;
318316
MODULES: ARRAY 1024 OF CHAR;
@@ -336,7 +334,7 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
336334
ELSE ShortintSize := 1; IntegerSize := 2; LongintSize := 4
337335
END;
338336

339-
IF verbose IN Options THEN VerboseListSizes END;
337+
(*IF verbose IN Options THEN VerboseListSizes END;*)
340338

341339
ResourceDir := InstallDir;
342340
IF ResourceDir[0] # 0X THEN
@@ -392,14 +390,6 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
392390
curpos := Texts.Pos(inR);
393391
Texts.Read(inR, ch);
394392

395-
(* OpenBSD intermittent file read error debugging. *)
396-
IF (curpos = 0) & inR.eot THEN
397-
LogWLn; LogWStr("DEBUG: OPM.Get returned inR.eot at curpos = 0, ch = ");
398-
LogWNum(ORD(ch),1); LogW(".");
399-
Texts.DumpReader(inR);
400-
LogWLn; LogWStr("Heap dump:"); LogWLn;
401-
Out.DumpHeap
402-
END;
403393
(* TODO, remove curpos var, and provide fn returning Texts.Pos(inR) - 1. *)
404394
(* Or, better still, record symbol position in OPS. *)
405395

src/compiler/OPP.Mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ MODULE OPP; (* NW, RC 6.3.89 / 10.2.94 *) (* object model 4.12.93 *)
10071007
OPS.Init; LoopLevel := 0; level := 0; OPS.Get(sym);
10081008
IF sym = OPS.module THEN OPS.Get(sym) ELSE err(16) END;
10091009
IF sym = OPS.ident THEN
1010-
OPM.LogWStr("compiling "); OPM.LogWStr(OPS.name); OPM.LogW(".");
1010+
OPM.LogCompiling(OPS.name);
10111011
OPT.Init(OPS.name, opt); OPS.Get(sym); CheckSym(OPS.semicolon);
10121012
IF sym = OPS.import THEN OPS.Get(sym);
10131013
LOOP

src/compiler/extTools.Mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ PROCEDURE Assemble*(moduleName: ARRAY OF CHAR);
4949
Strings.Append("-c ", cmd);
5050
Strings.Append(moduleName, cmd);
5151
Strings.Append(".c", cmd);
52-
execute("Assemble: ", cmd);
52+
execute("C compile: ", cmd);
5353
END Assemble;
5454

5555

@@ -73,7 +73,7 @@ PROCEDURE LinkMain*(VAR moduleName: ARRAY OF CHAR; statically: BOOLEAN; addition
7373
Strings.Append('-O', cmd);
7474
Strings.Append(OPM.Model, cmd);
7575
Strings.Append(Configuration.libext, cmd);
76-
execute("Assemble and link: ", cmd);
76+
execute("C compile and link: ", cmd);
7777
END LinkMain;
7878
7979

src/runtime/Files.Mod

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -70,44 +70,6 @@ MODULE Files; (* J. Templ 1.12. 89/12.4.95 Oberon files mapped onto Unix files
7070
SearchPath: POINTER TO ARRAY OF CHAR;
7171

7272

73-
(* Debugging intermittent OpenBSD failure. *)
74-
75-
PROCEDURE Spaces(i: INTEGER); BEGIN WHILE i>0 DO Out.String(" "); DEC(i) END END Spaces;
76-
77-
PROCEDURE DumpFile*(f: File; indent: INTEGER);
78-
BEGIN
79-
Spaces(indent); Out.String("workName: "); Out.String(f.workName); Out.Ln;
80-
Spaces(indent); Out.String("registerName: "); Out.String(f.registerName); Out.Ln;
81-
Spaces(indent); Out.String("tempFile: "); IF f.tempFile THEN Out.String("TRUE") ELSE Out.String("FALSE") END; Out.Ln;
82-
Spaces(indent); Out.String("identity: "); Out.String("..."); Out.Ln; (* TBD *)
83-
Spaces(indent); Out.String("fd: "); Out.Int(f.fd,1); Out.Ln;
84-
Spaces(indent); Out.String("len, "); Out.Int(f.len,1); Out.Ln;
85-
Spaces(indent); Out.String("pos: "); Out.Int(f.pos,1); Out.Ln;
86-
Spaces(indent); Out.String("bufs: "); Out.String("..."); Out.Ln; (* TBD *)
87-
Spaces(indent); Out.String("swapper: "); Out.Int(f.swapper,1); Out.Ln;
88-
Spaces(indent); Out.String("state: "); Out.Int(f.state,1); Out.Ln;
89-
Spaces(indent); Out.String("next: "); Out.Hex(SYSTEM.VAL(SYSTEM.ADDRESS,f.next),1); Out.Ln;
90-
END DumpFile;
91-
92-
PROCEDURE DumpBuffer*(b: Buffer; indent: INTEGER);
93-
BEGIN
94-
Spaces(indent); Out.String("chg: "); IF b.chg THEN Out.String("TRUE") ELSE Out.String("FALSE") END; Out.Ln;
95-
Spaces(indent); Out.String("org: "); Out.Int(b.org,1); Out.Ln;
96-
Spaces(indent); Out.String("size: "); Out.Int(b.size,1); Out.Ln;
97-
Spaces(indent); Out.String("data: "); Out.Ln; Out.HexDump(b.data);
98-
Spaces(indent); Out.String("f: "); IF b.f = NIL THEN Out.String("<NIL>"); Out.Ln ELSE Out.Ln; DumpFile(b.f, indent+1) END;
99-
END DumpBuffer;
100-
101-
PROCEDURE DumpRider*(r: Rider; indent: INTEGER);
102-
BEGIN
103-
Spaces(indent); Out.String("res: "); Out.Int(r.res,1); Out.Ln;
104-
Spaces(indent); Out.String("eof: "); IF r.eof THEN Out.String("TRUE") ELSE Out.String("FALSE") END; Out.Ln;
105-
Spaces(indent); Out.String("org: "); Out.Int(r.org,1); Out.Ln;
106-
Spaces(indent); Out.String("offset: "); Out.Int(r.offset,1); Out.Ln;
107-
Spaces(indent); Out.String("buf: "); IF r.buf = NIL THEN Out.String("<NIL>"); Out.Ln ELSE Out.Ln; DumpBuffer(r.buf, indent+1) END;
108-
END DumpRider;
109-
110-
11173
PROCEDURE -IdxTrap "__HALT(-1)";
11274

11375
PROCEDURE^ Finalize(o: SYSTEM.PTR);
@@ -203,13 +165,6 @@ MODULE Files; (* J. Templ 1.12. 89/12.4.95 Oberon files mapped onto Unix files
203165
error: Platform.ErrorCode;
204166
err: ARRAY 32 OF CHAR;
205167
BEGIN
206-
(*
207-
Out.String("Files.Create fd = "); Out.Int(f.fd,1);
208-
Out.String(", registerName = "); Out.String(f.registerName);
209-
Out.String(", workName = "); Out.String(f.workName);
210-
Out.String(", state = "); Out.Int(f.state,1);
211-
Out.Ln;
212-
*)
213168
IF f.fd = NoDesc THEN
214169
IF f.state = create THEN
215170
(* New file with enough data written to exceed buffers, so we need to
@@ -248,19 +203,9 @@ MODULE Files; (* J. Templ 1.12. 89/12.4.95 Oberon files mapped onto Unix files
248203
f: File;
249204
(* identity: Platform.FileIdentity; *)
250205
BEGIN
251-
(*
252-
Out.String("Files.Flush buf.f.registername = "); Out.String(buf.f.registerName);
253-
Out.String(", buf.f.fd = "); Out.Int(buf.f.fd,1);
254-
Out.String(", buffer at $"); Out.Hex(SYSTEM.ADR(buf.data));
255-
Out.String(", size "); Out.Int(buf.size,1); Out.Ln;
256-
*)
257206
IF buf.chg THEN f := buf.f; Create(f);
258207
IF buf.org # f.pos THEN
259208
error := Platform.Seek(f.fd, buf.org, Platform.SeekSet);
260-
(*
261-
Out.String("Seeking to "); Out.Int(buf.org,1);
262-
Out.String(", error code "); Out.Int(error,1); Out.Ln;
263-
*)
264209
END;
265210
error := Platform.Write(f.fd, SYSTEM.ADR(buf.data), buf.size);
266211
IF error # 0 THEN Err("error writing file", f, error) END;
@@ -271,11 +216,9 @@ MODULE Files; (* J. Templ 1.12. 89/12.4.95 Oberon files mapped onto Unix files
271216
END
272217
END Flush;
273218

274-
275219
PROCEDURE Close* (f: File);
276220
VAR
277-
i: LONGINT;
278-
error: Platform.ErrorCode;
221+
i: LONGINT; error: Platform.ErrorCode;
279222
BEGIN
280223
IF (f.state # create) OR (f.registerName # "") THEN
281224
Create(f); i := 0;
@@ -429,13 +372,6 @@ MODULE Files; (* J. Templ 1.12. 89/12.4.95 Oberon files mapped onto Unix files
429372
VAR org, offset, i, n: LONGINT; buf: Buffer; error: Platform.ErrorCode;
430373
BEGIN
431374
IF f # NIL THEN
432-
(*
433-
Out.String("Files.Set rider on fd = "); Out.Int(f.fd,1);
434-
Out.String(", registerName = "); Out.String(f.registerName);
435-
Out.String(", workName = "); Out.String(f.workName);
436-
Out.String(", state = "); Out.Int(f.state,1);
437-
Out.Ln;
438-
*)
439375
IF pos > f.len THEN pos := f.len ELSIF pos < 0 THEN pos := 0 END;
440376
offset := pos MOD BufSize; org := pos - offset; i := 0;
441377
WHILE (i < NumBufs) & (f.bufs[i] # NIL) & (org # f.bufs[i].org) DO INC(i) END;
@@ -597,10 +533,6 @@ Especially Length would become fairly complex.
597533
oldidentity, newidentity: Platform.FileIdentity;
598534
buf: ARRAY 4096 OF CHAR;
599535
BEGIN
600-
(*
601-
Out.String("Files.Rename old = "); Out.String(old);
602-
Out.String(", new = "); Out.String(new); Out.Ln;
603-
*)
604536
error := Platform.IdentifyByName(old, oldidentity);
605537
IF error = 0 THEN
606538
error := Platform.IdentifyByName(new, newidentity);
@@ -798,11 +730,6 @@ Especially Length would become fairly complex.
798730
VAR f: File; res: LONGINT;
799731
BEGIN
800732
f := SYSTEM.VAL(File, o);
801-
(*
802-
Out.String("Files.Finalize f.fd = "); Out.Int(f.fd,1);
803-
Out.String(", f.registername = "); Out.String(f.registerName);
804-
Out.String(", f.workName = "); Out.String(f.workName); Out.Ln;
805-
*)
806733
IF f.fd >= 0 THEN
807734
CloseOSFile(f);
808735
IF f.tempFile THEN res := Platform.Unlink(f.workName) END

0 commit comments

Comments
 (0)