• Stars
    star
    182
  • Rank 211,154 (Top 5 %)
  • Language
    Ada
  • Created about 5 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

LLVM based GNAT compiler

GNAT LLVM

This is an Ada compiler based on LLVM, connecting the GNAT front-end to the LLVM code generator to generate LLVM bitcode for Ada and to open the LLVM ecosystem to Ada.

Note that we are not planning on replacing any existing GNAT port that's based on GCC: this project is meant to provide additional, not replacement, GNAT ports.

You are welcome to experiment with this technology and provide feedback on successes, usages, limitations, pull requests, etc.

Building

To build GNAT LLVM from sources, follow these steps:

  • First do a checkout of this repository and go to this directory:

    $ git clone https://github.com/AdaCore/gnat-llvm.git
    $ cd gnat-llvm
    
  • Then obtain a check out of the latest GNAT sources from gcc.gnu.org under the llvm-interface directory:

    $ git clone git://gcc.gnu.org/git/gcc.git llvm-interface/gcc
    

    then under non Windows systems:

    $ ln -s gcc/gcc/ada llvm-interface/gnat_src
    

    under Windows systems:

    $ mv llvm-interface/gcc/gcc/ada llvm-interface/gnat_src
    
  • Install (and put in your PATH) a recent GNAT, e.g GNAT Community 2021 or GCC 11.

  • Install LLVM and Clang 16.0.x

    The recommended way to build GNAT LLVM is to use an existing LLVM and clang package installed via e.g. "brew install llvm" on Mac OS or "sudo apt-get install llvm-dev" on Ubuntu. You can also build llvm yourself with the options that suit your needs. After installing/building, make sure the llvm bin directory containing llvm-config and clang is in your PATH.

    An alternative only suitable for core GNAT LLVM development on x86 native configurations is to use the following command, assuming you have cmake version >= 3.13.4 in your path:

    $ make llvm
    

    Note that there's currently a bug in LLVM's aliasing handling. We check for it and generate slightly pessimized code in that case, but a patch to be applied to LLVM's lib/Analyze directory is in the file llvm/patches/LLVMStructTBAAPatch.diff.

  • Finally build GNAT LLVM:

    $ make
    

This creates a "ready to use" set of directories "bin" and "lib" under llvm-interface which you can put in your PATH:

PATH=$PWD/llvm-interface/bin:$PATH
  • If you want in addition to generate bitcode for the GNAT runtime, you can do:

    $ make gnatlib-bc
    

    This will generate libgnat.bc and libgnarl.bc in the adalib directory, along with libgnat.a and libgnarl.a.

Usage

  • To run the compiler and produce a native object file:

    $ llvm-gcc -c file.adb
    
  • To debug the compiler:

    $ gdb -args llvm-gnat1 -c file.adb
    
  • To build a complete native executable:

    $ llvm-gnatmake main.adb
    
  • To build a whole project:

    $ gprbuild --target=llvm -Pprj ...
    
  • To generate LLVM bitcode (will generate a .bc file):

    $ llvm-gcc -c -emit-llvm file.adb
    
  • To generate LLVM assembly (will generate a .ll file):

    $ llvm-gcc -c -S -emit-llvm file.adb
    
  • To generate native assembly file (will generate a .s file):

    $ llvm-gcc -S file.adb
    

License

The GNAT LLVM tool is licensed under the GNU General Public License version 3 or later; see file COPYING3 for details.

More Repositories

1

gnatstudio

GNAT Studio is a powerful and lightweight IDE for Ada and SPARK.
Ada
402
star
2

spark2014

SPARK 2014 is the new version of SPARK, a software development technology specifically designed for engineering high-reliability applications.
Ada
245
star
3

Ada_Drivers_Library

Ada source code and complete sample GNAT projects for selected bare-board platforms supported by GNAT.
Ada
241
star
4

ada_language_server

Server implementing the Microsoft Language Protocol for Ada and SPARK
Ada
230
star
5

libadalang

Ada semantic analysis library.
Ada
146
star
6

aws

AWS is a complete framework to develop Web based applications in Ada.
Ada
127
star
7

gsh

A POSIX shell for Windows.
C
103
star
8

learn

Sources for learn.adacore.com
Ada
93
star
9

gtkada

Ada bindings for the GTK+ graphical library.
Ada
88
star
10

langkit

Language creation framework.
Python
79
star
11

gprbuild

GPRbuild is an advanced build system designed to help automate the construction of multi-language systems.
Ada
65
star
12

svd2ada

An Ada binding generator from SVD descriptions for bare board ARM devices.
Ada
64
star
13

bb-runtimes

Source repository for the GNAT Bare Metal BSPs
Ada
64
star
14

ada-spark-rfcs

Platform to submit RFCs for the Ada & SPARK languages
63
star
15

VSS

High level string and text processing library
Ada
53
star
16

gnatcoll-core

GNAT Components Collection – Core packages
Ada
45
star
17

gnatcoverage

GNATcoverage: Coverage Analysis Tool
Ada
36
star
18

Certyflie

Ada
32
star
19

ada-traits-containers

Generic Ada Library for Algorithms and Containers
Ada
29
star
20

why3

SPARK 2014 repository for the Why3 verification platform.
OCaml
29
star
21

startup-gen

A startup code generator for embedded projects
Ada
28
star
22

e3-core

Core framework for developing portable automated build systems
Python
26
star
23

git-hooks

Git hooks Python-based scripts
Python
24
star
24

xmlada

The XML/Ada toolkit.
Ada
22
star
25

Ada-IntelliJ

Support for Ada and SPARK languages in IntelliJ IDEA
Java
21
star
26

OPAVES

Open Platform for Autonomous VEhicle Systems
C
21
star
27

training_material

Ada
20
star
28

PolyORB

PolyORB provides a uniform solution to build distributed applications relying either on middleware standards
Ada
20
star
29

Ada-SPARK-Crate-Of-The-Year

19
star
30

gnat_community_install_script

Script to automate the installation of the GNAT Community Installers
Shell
18
star
31

cuda

Ada
18
star
32

win32ada

Ada API to the Windows library
Ada
17
star
33

spawn

Ada
16
star
34

Robotics_with_Ada

Robotics with Ada, ARM, and Lego
Ada
16
star
35

gpr

The framework for analyzing the GNAT Project (GPR) files
Ada
16
star
36

libadalang-tools

Libadalang-based tools
Ada
16
star
37

gnat-gdb-scripts

GDB scripts for Ada programs built with GNAT
Python
16
star
38

gnatcoll-bindings

GNAT Components Collection – Bindings to C libraries
Ada
14
star
39

embedded-runtimes

runtimes that add support for various boards to the GNAT GPL compiler for ARM
Ada
14
star
40

adareducer

Python
13
star
41

qemu

C
12
star
42

gnatcoll-db

GNAT Components Collection – Database packages
C
11
star
43

sparkformal

The project SPARK Formal aims at developing a complete semantics of the SPARK language in Coq.
Coq
11
star
44

UnityAdaTetris

Ada
10
star
45

markdown

Markdown parser
Ada
9
star
46

labs-material

Support Libraries for AdaCore University Labs
Ada
7
star
47

templates-parser

AWS templates engine.
Ada
7
star
48

florist

Ada
6
star
49

ada-py-bind

Ada
6
star
50

e3-testsuite

e3 testsuite driver
Python
6
star
51

spdm-recordflux

6
star
52

RC_Car_Demo

An embedded Ada/SPARK demo
Ada
6
star
53

RESSAC_Use_Case

A Collaborative Development Assurance Lab
Ada
6
star
54

aunit

Ada
6
star
55

SPARK_Railway_Simulation_Demo

Ada
5
star
56

Http_Cyclone

C
5
star
57

Compile_And_Prove_Demo

Demo project for new web site: Compile It! / Prove It!
Ada
5
star
58

program_proofs_in_spark

This repository contains some programs from Rustan Leino's book "Program Proofs" verified with SPARK.
Ada
5
star
59

gnat-docker

Python
5
star
60

gnatdashboard

Analyse a project.
Python
4
star
61

AdaSAT

Ada
4
star
62

e3-aws

High level interface for CloudFormation
Python
4
star
63

Platinum_Reusable_Stack

Ada
4
star
64

wposix

Ada Windows POSIX binding
Ada
4
star
65

code_examples_server

prototype server for creating interactive "try SPARK / try Ada" webpages
Python
3
star
66

lmod_manager

lmod based management tool for GNAT and SPARK installations
Python
3
star
67

SPARK_PDI_Demo

Use of SPARK to implement Parameter Data Items
Ada
3
star
68

langkit-query-language

query language for Libadalang and Langkit
Ada
3
star
69

gprconfig_kb

GPR configuration knowledge base
3
star
70

tictactoe

A tictactoe game written and proven in SPARK
Ada
3
star
71

language-examples

Examples of common software engineering constructs written in Ada and SPARK
Ada
3
star
72

ada_coding_standards

Ada
2
star
73

cheri-examples

Ada
2
star
74

style_checker

The AdaCore style checker
C
2
star
75

gpr-unit-provider

GPR2 based unit provider for Libadalang
Ada
2
star
76

gnatdoc

GNAT Documentation Generator
Ada
2
star
77

Lunar_Lander_Rotation_Demo

Demonstration program that interacts with the AdaFruit BNO055 breakout board in order to send orientation data to a host computer
Ada
2
star
78

RecordFlux-parser

Python
2
star
79

training_labs_radar

Ada
2
star
80

RecordFlux

Formal specification and generation of verifiable binary parsers, message generators and protocol state machines
2
star
81

uwrap

Ada
1
star
82

z3

SPARK 2014 repository for the Z3 SMT solver.
C++
1
star
83

lal-checkers

Libadalang-based code checking infrastructure
Python
1
star
84

spark_translator

SPARK 2005 to 2014 translator
Python
1
star
85

Lumos_Maxima

Lumos_Maxima repository for VerifyThis challenge
Ada
1
star
86

training_labs_solar_system

Ada
1
star
87

training_labs_standalone

Ada
1
star
88

gnatcoll

GNAT Components Collection (obsolete)
1
star
89

sphinxcontrib-adadomain

Python
1
star
90

alt-ergo

SPARK 2014 repository for the Alt-Ergo SMT solver.
OCaml
1
star
91

lsif-ada

Ada
1
star
92

prettier-ada

Ada
1
star
93

SPARK-to-C_Tetris_Demo

Ada
1
star
94

lal-refactor

Ada
1
star
95

RecordFlux-devutils

1
star