-
Notifications
You must be signed in to change notification settings - Fork 3
GCC Toolchain
The following example assumes that the Oberon LLVM frontend is used to compile the Sort.Mod
module. Compilation from Oberon source code to a binary executable is accomplished in three steps. First the Oberon LLVM frontend translates the module into the LLVM IR (intermediate representation). Then the LLVM tools opt
and llc
are used to optimize and compile the LLVM IR, respectively. Finally, gcc
is used to link and generate the executable.
-
Invoke the Oberon LLVM frontend
oberon-lang
using the following command to translate moduleSort.Mod
to LLVM IR.> oberon-lang --filetype=ll Sort.Mod
This will create a new file called
Sort.ll
containing the serialized LLVM IR in textual format. -
In the next step, the LLVM Optimizer and LLVM Static Compiler are used to optimize the LLVM IR and translate it into an assembly file.
> opt -S -O3 Sort.ll | llc --relocation-model=pic -O3 -o Sort.s
In the example above, optimization level
O3
is applied, which performs a preconfigured sequence of LLVM’s optimization or analysis passes. For additional configuration options, please refer to the documentation ofopt
andllc
linked above. In order to compile and link the generate assembly file withgcc
, a position independent code file has to be created. -
The final step is to link and generate the executable binary from the
Sort.s
assembly file. In order to accomplish this,gcc
can be used as shown below.> gcc Sort.s -o Sort
This creates the Sort
executable binary that can be invoked from the command line.
Building the Frontend
Using the Compiler
- Apple Clang Toolchain
- GCC Toolchain
- Microsoft MSVC Toolchain
- Just-in-Time Compilation
- Embedded Devices
Oberon Compatibility
Miscellaneous