Giter Club home page Giter Club logo

crt-old's Introduction

Compiler Repository Toolkit

The Compiler Repository Toolkit is a set of bazel rules meant to make building a C/C++ toolchain easier.

This was inspired by bazel-embedded; I hope I've managed to improve things.

Features

  • Simplified toolchain setup.
  • A bazel-ish approach to compiler features and flags.
  • More concise target device configuration.
  • Emulator configuration for executing target code

Simplified toolchain setup

Each of the toolchains is configured in //toolchains/... by two files.

  • repository.bzl describes the path or URL to the compiler archive.
  • BUILD.bzl initializes the toolchains for each target device. Most of the configuration comes from the individual device configurations (more on that later). The other elemets of the BUILD.bazel file describe the files which make up the compiler and the various include paths needed by the compiler.

A bazel-ish approach to compiler features and flags

Compiler featurs and flags are defined by a feature_set which aggregates compiler flags for activating different features, such as optimization modes or warning levels. The feature_set aggregates a collection of feature rules together and provides a facility for supplying substitutions to those flags so that minor variations in configuration don't require an entire new configuration. Feature sets may be chained together; features supplied later in the chain override features earlier in the chain. Substitutions may be supplied at any point in the feature_set chain or by the device configuration.

More concise target device configuration

Target devices are defined in //platforms/<arch>/devices.bzl. Each device configuration creates a device struct containing the architecture, constraints, feature set and substitutions to supply to the feature set.

Each target device should correspond to a bazel platform definition. Bazel will use the platform constraints to select the toolchain for the device with the same constraints.

Emulator configuration for target code

In addition to defining the toolchains, crt also defines an exec_config that can be used to execute target code under a system emulator. Sample configurtions using qemu are supplied.

How to use

In your WORKSPACE file, add:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "crt",
    url = "https://github.com/cfrantz/crt/archive/refs/tags/v0.3.0.tar.gz",
    sha256 = "...",
    strip_prefix = "crt-0.3.0",
)

load("@crt//:repos.bzl", "crt_repos")
crt_repos()
load("@crt//:deps.bzl", "crt_deps")
crt_deps()

load("@crt//config:registration.bzl", "crt_register_toolchains")
crt_register_toolchains(
    arm = True,     # Pick the toolchains you want.
    m6502 = True,
    riscv32 = True,
    win64 = True,
)

Releasing CRT

To perform a release of CRT:

The release process assumes you have your git and GitHub CLI credentials in $HOME/.git and $HOME/.config/gh repsectively.

  1. Commit your changes.
  2. Create a tag locally, but don't push it to your remote.
  3. Run the util/release_in_container.sh script. This script executes bazel run :release inside of an ubuntu-20.04 container.

crt-old's People

Contributors

cfrantz avatar luismarques avatar timothytrippel avatar

Stargazers

Rahul Butani avatar Jevin Sweval avatar Tianjiao Nie avatar  avatar  avatar

Watchers

Jevin Sweval avatar  avatar Ted Pudlik avatar Rahul Butani avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.