vishapoberon/compiler
حول
vishap oberon compiler
لغات البرمجة وبيئات التشغيلالنمو المقاس للنجوم
- خلال 24 ساعة
- ٠
- خلال 7 أيام
- ٠
- خلال 15 يومًا
- +١
- خلال شهر
- جارٍ جمع السجل
تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.
README.md
الأصلѴishap Oberon
Ѵishap Oberon is a free and open source (GPLv3) implementation of the Oberon-2 language and libraries for use on conventional operating systems such as Linux, BSD, Android, Mac and Windows.
Vishap's Oberon Compiler (voc) uses a C backend (gcc, clang, tcc or msc) to compile Oberon programs under Unix, Mac or Windows. Vishap Oberon includes libraries from the Ulm, oo2c and Ofront Oberon compilers, as well as default libraries complying with the Oakwood Guidelines for Oberon-2 compilers.
Release notes for 5.4.3 · 5.4.2 release notes · 5.4.1 release notes · 5.4 release notes · 5.3 release notes · 5.2 release notes · 5.1 release notes · 5.0 release notes · 4.0 release history
Version 5.4.3 adds console-game keyboard input to crt, improves VT100 output,
and repairs MersenneTwister seeding, ranges and numeric conversions. See
console games and MersenneTwister.
Version 5.4.2 fixes BSD confidence-test portability. Native builds and the full confidence suite pass on NetBSD 9.3 amd64 and FreeBSD 15.1-RELEASE-p7 amd64.
Version 5.4.1 adds alternate-stack fatal-fault reporting and conservative stack-overflow diagnostics.
Version 5.4 adds default-on NIL checks, source locations for NIL and array-bounds
failures, and editor-readable compiler diagnostics. It also enforces read-only
destinations for memory loads and static independence for ALL.
Version 5.3 adds native Ed25519 signatures, incremental SHA-512 and resumable
mutual TLS 1.3 authentication with manually pinned Ed25519 keys. The none
editor provides Oberon completion and call-parameter hints, including unfinished
declarations; see the editor guide.
The experimental Oberon-V support includes SUM and PROD reductions,
multidimensional CPU ALL, and automatic vectorization.
Execution modes include sequential code, CPU OpenMP (-jP) and GPU
offloading (-jG). The distribution also includes an
IRC client library, a
channel-history client example,
and the XML, XMPP, Unicode, image and editor additions from the 4.0 series.
Hexadecimal output documents ETH-compatible
Out.Hex(i) and the unsigned, minimum-width Out.HexDigits(x, n) interface.
Runtime pointer checks describes default-on NIL checks and the separate Unix diagnostic for invalid memory accesses.
Contents
Installation
Compiling a 'Hello' application
Shared modules and the hresh shell
Experimental Oberon-V support
Source layout
License
Platform support and porting
Language support and libraries
Contributors
Origin of the name "Ѵishap Oberon"
References
Installation
Gentoo users can install dev-lang/voc from
norayr-overlay. See the
Gentoo installation commands.
It is easy to build the Oberon compiler and libraries with the following simple steps:
- Install pre-requisites such as git, gcc, static C libraries, diff utils.
- Clone the repository:
git clone https://github.com/vishaps/voc. - Optionally choose a C compiler, for example with
export CC=clang. - Run
make. - Optionally install to a system directory with
make install(might be with sudo). - Set your PATH variable to include the compiler binary.
These are detailed below:
1. Install prerequisites
| Platform | Packages |
|---|---|
| Debian/Ubuntu/Mint ... | apt-get install git |
| Fedora/RHEL/CentOS ... | yum install git gcc glibc-static (dnf instead of yum on recent Fedoras) |
| FreeBSD/OpenBSD/NetBSD | pkg install git |
| OpenSUSE | zypper install gcc git-core make glibc-devel-static |
| Cygwin | use setup-x86[_x64] to add packages git, make, diffutils and gcc-core |
| Darwin | type 'git' at the command line and accept the prompt to install it. |
More details, including for MingW and MS C, in Installation.
On FreeBSD, also install GNU make with pkg install gmake, and use gmake
in place of make in the commands below. The bundled tool makefiles use GNU
make functions; recursive builds preserve the make program you selected.
The default confidence suite requires Python 3. Its launcher tries python3,
then python, checking that the interpreter is Python 3. Set PYTHON to choose
an executable explicitly, for example gmake PYTHON=python3.9. Perl is used by
the separate scripts in src/tools/autobuild, not by the default build.
2. Clone and build the compiler and libraries
git clone https://github.com/vishaps/voccd vocmake
make is an unprivileged build. It creates an installation image under
voc/install, runs the confidence tests, and does not copy files to the host.
Choose a different C compiler with, for example, CC=clang make.
3. Optionally install to a system directory
Run make install as root to copy the voc/install image to the configured directories.
The default Unix locations are /usr/local/bin, /usr/local/share/voc, and
/usr/local/lib. Override PREFIX, BINDIR, INSTALLDIR, and LIBDIR as needed.
For a package build, use DESTDIR so the staged path is not compiled into the
compiler configuration:
make install PREFIX=/usr DESTDIR=/path/to/package-root
To keep the compiler and libraries under one directory:
make install INSTALLDIR=/opt/voc
At compiler invocation time, VOCROOT selects the headers and symbol-file root.
For a self-contained installation such as the local install image, its lib
directory supplies the libraries too. Split installations use the configured
library directory. VOCLIBDIR explicitly overrides the library directory in
either layout, including when the installation root is discovered automatically.
| System | Where make install puts the installation |
|---|---|
| Unix | /usr/local/bin, /usr/local/share/voc, /usr/local/lib |
| Windows | See Windows installation |
| Termux | /data/data/com.termux/files/opt/voc |
For a manual installation with libraries outside the standard linker paths,
use make install-system; unlike make install, it also runs ldconfig.
4. Set your PATH environment variable
Since there are so many ways that different systems and users manage their PATHs, we leave it to you to update your path to include the compiler binary.
Both make and make install display instructions on setting the path specific to your
system. A staged installation is run from its final installation paths after
the package is installed, not from its DESTDIR path.
For reference this will be:
| Installation choice | Set path |
|---|---|
Just make |
export PATH="your-repository-clone/install/bin:$PATH" |
make install on Unix |
export PATH="/usr/local/bin:$PATH" |
make install on BSD |
export PATH="/usr/local/bin:$PATH" |
make install on Windows |
See Windows installation |
make install on Termux |
export PATH="/data/data/com.termux/files/opt/voc/bin:$PATH" |
Also see Installation.
The compiler finds the rest of the installation based on the location from which it is loaded.
A 'Hello' application
Anything appended to Oberon.Log is automatically written to stdout, so the following conventional Oberon program will display 'Hello.':
MODULE hello;
IMPORT Oberon, Texts;
VAR W: Texts.Writer;
BEGIN
Texts.OpenWriter(W);
Texts.WriteString(W, "Hello."); Texts.WriteLn(W);
Texts.Append(Oberon.Log, W.buf)
END hello.
Alternatively the Oakwood module Out can be used to write directly to stdout:
MODULE hello;
IMPORT Out;
BEGIN
Out.String("Hello."); Out.Ln
END hello.
Compile as follows:
voc hello.mod -m
The -m parameter tells voc that this is a main module, and to generate an executable binary.
Execute as usual on Linux (./hello) or Windows (hello).
For more details on compilation, see Compiling.
Viewing the interfaces of included modules.
In order to see the definition of a module's interface, use the "showdef" program.
$ showdef Out
DEFINITION Out;
VAR
IsConsole-: BOOLEAN;
PROCEDURE Char(ch: CHAR);
PROCEDURE Flush;
PROCEDURE Int(x: INT64; n: INT64);
PROCEDURE Ln;
PROCEDURE LongReal(x: LONGREAL; n: INT16);
PROCEDURE Open;
PROCEDURE Real(x: REAL; n: INT16);
PROCEDURE String(str: ARRAY OF CHAR);
END Out.
Shared modules and the hresh shell
VOC can compile modules as individual shared libraries and load them when they
are needed. hresh, the Hosted Runtime Extensible Shell, calls exported Oberon
commands such as Commands.Run in one process, allowing modules to retain their
state between calls. A standalone program can use the same libraries without
the shell. Use voc -mL Main.Mod to link a main program to individual module
libraries and the shared minimal core. Uppercase -L selects module-library
linking.
Start with A gentle introduction to shared modules to write a command module, build an application, and change its implementation without rebuilding the executable. Shared modules and hresh describes the compiler options, library organisation and loading rules.
The terminal editor opens files with none.Open file in hresh or none file
as a standalone program. A full Unix build includes install/bin/none.
With an installed compiler, make none builds just the editor in
build/none/none; make none-test checks editing and terminal restoration.
make modular-library builds shared-module versions of the bundled libraries.
For X11, Cairo and raylib, install the development packages
and run make modular-library-bindings. The
library examples show both shell
commands and standalone applications. Normal -m and -M compilation uses
the combined libvoc library instead.
Experimental Oberon-V support
VOC's -j option enables the ALL statement from Robert Griesemer's
Oberon-V dissertation, Sections 2.1
and 3.7. ALL describes independent computations over a range of integer
values. The same source can describe work for sequential, multicore, or GPU
execution without naming a device architecture.
MODULE Vectors;
VAR a: ARRAY 1000 OF REAL;
BEGIN
ALL i = 0 .. 999 DO a[i] := i * 2 END
END Vectors.
| Command | Status |
|---|---|
voc -j Vectors.Mod |
Implemented: ordinary sequential C |
voc -jP Vectors.Mod |
Implemented: OpenMP CPU execution |
voc -jG Vectors.Mod |
Implemented: synchronous OpenMP GPU offloading for the supported numerical subset |
-j, -P, and -G are individual, toggleable options. -P and -G
require -j and are mutually exclusive. Options before the first filename
apply to all files; options after a filename toggle those settings for that
file only. Without -j, ALL remains an ordinary Oberon-2 identifier.
Supported syntax and semantics
The implementation accepts range declarations and an assignment sequence, including an empty sequence:
ALL r = lower .. upper DO
a[r] := b[r] * scale;
c[r] := a[r] + offset
END
The bounds are inclusive. They are integer expressions, evaluated once each,
lower bound first, before executing any assignment. If lower > upper, no
assignment runs. The range identifier is read-only and local to the body;
it may shadow an enclosing identifier. Bounds use the enclosing scope.
Its integer type is wide enough for both bounds and at least as wide as
INTEGER. The generated loop stops before incrementing the last value, so
a range ending at the largest representable integer does not overflow.
Sequential and CPU execution also accept several range identifiers:
ALL row = 0 .. LEN(matrix)-1, col = 0 .. LEN(matrix, 1)-1 DO
matrix[row, col] := row * 10 + col
END
Each combination of indices runs the assignment sequence once. Identifiers
can share bounds, as in ALL row, col = 0 .. 3 DO ... END. The bounds of
each declaration are evaluated once, lower then upper, in source order and
in the enclosing scope. Shared bounds are evaluated once for the whole
identifier group. All bounds are evaluated before any assignment, including
when a range is empty. If any range is empty, the body performs zero
assignments. WITH variables belong to one complete index combination.
CPU OpenMP distributes the outer range among workers and runs the remaining
ranges within each worker. The generated loops handle each range's integer
endpoints separately. Multidimensional GPU ALL remains further work.
Assignments within one iteration run in source order. The order between
iterations is unspecified; CPU and GPU modes may run them concurrently.
Ordinary FOR statements keep their existing meaning. Sequential and CPU
ALL use VOC's existing array representations and bounds checks. The direct
GPU mode accepts the smaller subset described in the GPU guide.
As in the dissertation's AssignmentSequence grammar, the body contains only
assignments, separated by semicolons, with no trailing semicolon. Control-flow
statements and procedure calls in the body are rejected. Numeric built-ins
such as ABS, LONG, and LEN remain available. User-defined function calls
in a body are rejected until their effects can be checked; ordinary Oberon-2
functions elsewhere keep their existing rules.
WITH declares private scalar temporaries for one iteration:
ALL r = lower .. upper WITH t: REAL DO
t := x[r] * y[r];
y[r] := t * scale
END
An iteration-local variable must be assigned before it is read.
Reduction expressions
VOC 5.1 adds SUM and PROD to combine the values
described by a one-dimensional Oberon-V array constructor:
total := SUM([i = 0 .. LEN(a)-1: a[i]]);
dot := SUM([i = 0 .. LEN(a)-1: a[i] * b[i]]);
product := PROD([i = 0 .. LEN(a)-1: a[i]])
They follow the selected -j, -jP or -jG execution mode. Empty ranges
return zero for SUM and one for PROD. Integer combination wraps at the
result type's width. Sequential floating-point reduction follows ascending
index order; parallel modes may regroup operations and change rounding.
See Adding and multiplying independent values for
types, examples, the initial supported subset and tests.
Independence
For distinct iterations, a location written by one must not be read or written
by another. This applies across the whole assignment sequence. For example,
a[r] := a[r] * 2 is independent; a[r] := a[r-1] generally requires an
ordered loop. A shared accumulator such as sum := sum + a[r] needs a
sequential loop or a reduction algorithm.
The compiler requires a static independence proof in every execution mode:
-j, -jP and -jG. Ambiguous aliasing or indexing is a compile-time error.
There is no unchecked mode or independence assertion. An ordered FOR loop
can express computations whose independence cannot be established.
For each range that may contain several values, a shared destination needs an
injective index in at least one array dimension. The supported mappings use
the range identifier with slope +1 or -1 and iteration-invariant offsets,
including widening conversions. Division, modulo, indirect indices and lossy
conversions do not establish injectivity. Other dimensions can still establish
that distinct iterations write distinct rows or cells.
The proof checks reads, writes and address/index computations across the whole assignment sequence. Matching per-iteration accesses, distinct declared storage, disjoint record fields and statically disjoint array sections can establish independence. Unknown pointer chains and potentially overlapping reference parameters are rejected, including a read-only reference that might alias an output. Repeated reads and aliases between read-only inputs are permitted when the output is provably separate.
For example, two VAR array parameters cannot be assumed disjoint merely
because their names differ. A single array parameter can support an in-place
elementwise update. Ordinary value array parameters are copied on entry and
can provide independent input snapshots. Fresh local arrays can provide output
storage independent of incoming reference parameters.
Errors distinguish recognized overlapping accesses (166), an unproved
destination mapping (180), and unproved memory independence (181). Empty and
statically single-iteration statements need no cross-iteration proof. Ordinary
bounds and type checks still apply. The proof assumes typed storage and valid
operations; forged aliases through SYSTEM or native code and concurrent
external mutation remain outside these guarantees.
Rebuild existing modules containing ALL when upgrading the compiler so their
bodies are checked under these rules.
C compiler requirements and testing
Sequential -j output uses ordinary C and the existing VOC runtime. GCC,
Clang, and TCC can compile it; linking uses the same libraries as an ordinary
Oberon-2 program.
GCC and Clang may autovectorize the generated loops with normal optimization
options.
CPU mode needs a C compiler with OpenMP support and its matching runtime at
link time. GPU mode additionally needs a compatible offload compiler, target
runtime, and device driver. CC selects the OpenMP compiler;
VOC_OPENMP_CFLAGS and VOC_OPENMP_LDFLAGS supply target-specific options.
OpenMP is a parallel-programming standard implemented by compatible C compilers.
Clang 19 optimized execution was verified on AMD gfx1036 integrated
graphics and a Radeon RX 5600 XT (gfx1010).
See A gentle introduction to parallel programming, GCC and Clang setup on Debian and Gentoo, CPU/GPU measurements, the numerical examples, and the HALD image-processing example.
After building VOC, run the regression tests with:
make -C src/test/oberonv test test-cpu
make -C src/test/oberonv test-gpu
The Unix confidence suite runs these tests in type models 2 and C; use
--model C to select the latter manually. They exercise available GCC,
Clang, and TCC installations, scope and bound evaluation, empty ranges, integer
limits, bounds-check failures, rejected dependencies, option toggling, and
Oberon-2 compatibility. src/test/oberonv/Vectorize.Mod supplies a large-array
example for inspecting C compiler vectorization reports.
The CPU scaling benchmark measures multidimensional
ALL, SUM and PROD against sequential and one-thread OpenMP baselines:
make -C src/test/oberonv benchmark-cpu
The GPU reduction benchmark measures SUM and
PROD on AMD GPUs against CPU baselines, including transfers:
make -C src/test/oberonv benchmark-gpu GPU_CC=clang
Configure the offload flags and visible device using the setup guide first.
Further Oberon-V work
Multidimensional ALL, private scalar iteration variables, and constructor-
based SUM and PROD are implemented for sequential and CPU execution.
The GPU subset supports one-dimensional ALL and reductions. Multidimensional
GPU ALL and general array value and variable constructors remain further work.
Constructors need stride-aware array views;
VOC's current open-array interface passes a base address and lengths, with
contiguous strides derived from those lengths. Adding views must preserve
the calling convention of existing Oberon-2 modules.
Section 7.2 proposed private iteration variables; VOC's WITH implements
that part of the design. GPU execution geometry, synchronization, and
asynchronous transfers remain outside the current language extension.
Source layout
| Directory | Contents |
|---|---|
src/compiler |
The Oberon-to-C compiler |
src/runtime |
Core runtime and Oakwood libraries |
src/library |
Command-line, terminal and other library modules |
src/ports |
Libraries, bindings and tools from other Oberon systems and projects |
src/examples |
Example programs, games and servers, built separately |
src/test |
Regression tests |
src/tools |
Build tools, symbol browser and hresh |
License
Vishap Oberon's frontend and C backend engine is a fork of Josef Templ’s Ofront, which has been released under the FreeBSD License. Unlike Ofront, Vishap Oberon does not include the Oberon v4 GUI environment.
The Ulm Oberon Library and the Ooc libraries are distributed under GPL. Proprietry code using these libraries may not be statically linked.
Voc tools are distributed under GPLv3.
Most of the runtime in libVishapOberon is distributed under GPLv3 with runtime exception.
The bundled Unix model-2 Kbd library from sts-q is GPLv3 without that runtime
exception; see src/ports/sts-q/oberon.
Platform support and porting
Vishap Oberon supports 32 and 64 bit little-endian architectures including Intel x86 and x86_64, 32 bit arm and aarch64.
It compiles under gcc, clang, tcc and Microsoft Visual C.
Installation supports GNU/Linux, MAC OSX, BSD and Windows (native and cygwin).
A C program (src/tools/make/configure.c) detects the details of the C compiler and operating system on which it is running.
The following systems are recognised:
- Linux, including Ubuntu and Centos derivatives.
- The BSDs, including OpenBSD and FreeBSD.
- Cygwin under Windows, MingW under Cygwin, Bash on Ubuntu on Windows.
Additionally a Windows .cmd is provided for building with Microsoft C.
For details, including how to add support for unrecognised systems, see Porting.
Language support and libraries
Vishap Oberon supports the Oberon 2 programming language, including type-bound procedures. SYSTEM.Mod includes additional functionality and some changes for 64 bit support.
Integer and set type sizes:
| Type | -O2 option (default) | -OC option |
|---|---|---|
| SHORTINT | 8 bit | 16 bit |
| INTEGER | 16 bit | 32 bit |
| LONGINT | 32 bit | 64 bit |
| SET | 32 bit | 64 bit |
Libraries
Included libraries ease porting of code from the major Oberon systems:
- Oberon V4 and S3 compatible library set.
- Ooc (optimizing oberon-2 compiler) library port.
- Ulm’s Oberon system library port.
- Oakwood standard libraries.
- Some other freely redistributable libraries.
Oakwood libraries are supported for both -O2 and -OC options, whereas the ULM, OOC and ETH system 3 libraries are only available on -O2 (default) compilations.
Vishap Oberon also supports some features of Oberon-07.
See also Features.
Contributors
Joseph Templ developed ofront as a tool to translate Oberon-2 programs into semantically equivalent C programs. It was Copyrighted in 1995, and transferred to the Free BSD license in 2012.
From Joseph's github repository:
Design and implementation of ofront is due to Josef Templ ... ofront has been based in part on Regis Crelier's PhD thesis and Stefan Gehring's diploma thesis, both at ETH Zurich, Institute for Computer Systems.
Norayr Chilingarian forked ofront in 2013, porting extensive libraries from ULM Oberon, OO2C and ETH Oberon System 3, and adding support for more platforms including 64 bit systems.
David Brown has worked on adding support for more platforms incuding windows using MSC, cygwin or mingw since January 2016. More recently he has generalised basic type support within the compiler to allow e.g. 64 bit LONGINT on 32 bit systems, and 32 bit LONGINT on 64 bit systems.
Oberon
Oberon is a programming language, an operating system and a graphical user interface. Originally designed and implemented by by Niklaus Wirth and Jürg Gutknecht at ETH Zürich in the late 1980s, it demonstrates that the fundamentals of a modern OS and GUI can be implemented in clean and simple code orders of magnitude smaller than found in contemporary systems.
The Oberon programming language is an evolution of the Pascal and Modula languages. While it adds garbage collection, extensible types and (in Oberon-2) type-bound procedures, it is also simplified following the principals of Einstein and Antoine de Saint-Exupéry:
Make it as simple as possible, but not simpler. (Albert Einstein)
Perfection is finally attained not when there is no longer anything to add, but when there is no longer anything to take away. (Antoine de Saint-Exupéry, translated by Lewis Galantière.)
Origin of the name "Ѵishap Oberon"
Vishaps are dragons inhabiting the Armenian Highlands. We decided to name the project “Vishap” because ties between compilers and dragons have ancient traditions.
Also, Vishaps are known in tales, fiction. This page refers to some technologies as “computer science fiction”. Among them to Oberon. This brings another meaning, Oberon is like aliens, ghosts. And Vishaps.
References
Oberon
- The History of Modula-2 and Oberon
- The Programming Language Oberon
- Project Oberon: The Design of an Operating System and Compiler
- Oberon - the Overlooked Jewel
Oberon 2
- Differences between Oberon and Oberon-2
- The Programming Language Oberon-2
- Programming in Oberon. Steps beyond Pascal and Modula
- The Oakwood Guidelines for Oberon-2 Compiler Developers
Oberon 07
- Difference between Oberon-07 and Oberon
- The Programming Language Oberon-07
- Programming in Oberon - a Tutorial
Links
- Niklaus Wirth's personal page at ETH Zurich
- Selected articles by Niklaus Wirth
- ETH Oberon publications page
- Joseph Templ's ofront on github
- Software Templ OG
History
See History.
استكشف مشاريع مشابهة ومرتبطة
جارٍ التحميل…