Home

Awesome

compiler-rt (meson port)

This project wraps the llvm compiler-rt repository and enables users to use it in meson-based projects.

Currently, this project is used to supply built-in functions for x86, x86_64, arm, and arm64 platforms.

If you are interested in contributing to this project, please read the CONTRIBUTING guide.

Table of Contents

  1. About the Project
  2. Project Status
  3. Getting Started
    1. Requirements
    2. Getting the Source
    3. Building
    4. Usage
  4. Configuration Options
  5. Versioning
  6. How to Get Help
  7. Contributing
  8. License
  9. Authors

About the Project

This project wraps the llvm compiler-rt repository and enables users to use it in meson-based projects.

Modifications to the compiler-rt implementations are not anticipated, but if needed alternative implementations can be supplied by this project.

Back to top

Project Status

This project builds the full suite of compiler-rt functions for x86, x86_64, arm, and arm64 processors.

Back to top

Getting Started

Requirements

git-lfs

This project stores some files using git-lfs.

To install git-lfs on Linux:

sudo apt install git-lfs

To install git-lfs on OS X:

brew install git-lfs

Additional installation instructions can be found on the git-lfs website.

Meson Build System

The [Meson][meson] build system depends on python3 and ninja-build.

To install on Linux:

sudo apt-get install python3 python3-pip ninja-build

To install on OSX:

brew install python3 ninja

Meson can be installed through pip3:

pip3 install meson

If you want to install Meson globally on Linux, use:

sudo -H pip3 install meson

Getting the Source

This project uses git-lfs, so please install it before cloning. If you cloned prior to installing git-lfs, simply run git lfs pull after installation.

This project is hosted on GitHub. You can clone the project directly using this command:

git clone --recursive git@github.com:embeddedartistry/compiler-rt.git

If you don't clone recursively, be sure to run the following command in the repository or your build will fail:

git submodule update --init

Building

The library can be built by issuing the following command:

make

This will build all targets for your current architecture.

You can clean builds using:

make clean

You can eliminate the generated buildresults folder using:

make purify

You can also use the meson method for compiling.

Create a build output folder:

meson buildresults

Then change into that folder and build targets by running:

ninja

At this point, make would still work.

Cross-compiling

Cross-compilation is handled using meson cross files. Example files are included in the build/cross folder. You can write your own cross files for your specific platform (or open an issue and we can help you).

Cross-compilation must be configured using the meson command when creating the build output folder. For example:

meson buildresults --cross-file build/cross/gcc/arm/gcc_arm_cortex-m4.txt

Following that, you can run make (at the project root) or ninja (within the build output directory) to build the project.

Tests will not be cross-compiled. They will be built for the native platform.

Usage

If you don't use meson for your project, the best method to use this project is to build it separately and copy the headers and library contents into your source tree.

Example linker flags:

-Lpath/to/libcompiler_rt.a -lcompiler_rt

If you're using meson, you can use compiler-rt as a subproject. Place it into your subproject directory of choice and add a subproject statement:

compiler_rt = subproject('compiler-rt')

You will need to promote the subproject dependencies to your project:

compiler_rt_builtins_dep = compiler_rt.get_variable('compiler_rt_builtins_dep')
compiler_rt_builtins_native_dep = compiler_rt.get_variable('compiler_rt_builtins_native_dep')

You can use the dependency for your target library configuration in your executable declarations(s) or other dependencies. For example:

blinky_nrf52dk_platform_dep = declare_dependency(
    include_directories: blinky_nrf52dk_platform_inc,
    dependencies: [
        nf52dk_blinky_hw_platform_dep,
        blinky_demo_platform_dep,
        libmemory_freelist_dep,
        libc_dep,
        libcxxabi_dep,
        libcxx_full_dep,
        compiler_rt_builtins_dep, # <------- compiler-rt dependency added
    ],
    link_args: [
        '-L' + meson.current_source_dir(),
        '-Tblinky_gcc_nrf52.ld',
    ],
    sources: files('platform.cpp'),
)

Configuration Options

The following meson project options can be set for this library when creating the build results directory with meson, or by using meson configure:

Options can be specified using -D and the option name:

meson buildresults -Denable-werror=true

The same style works with meson configure:

cd buildresults
meson configure -Denable-werror=true

Versioning

This project itself is unversioned and simply pulls in the latest compiler-rt commits periodically.

How to Get Help

Provide any instructions or contact information for users who need to get further help with your project.

Contributing

Provide details about how people can contribute to your project. If you have a contributing guide, mention it here. e.g.:

We encourage public contributions! Please review CONTRIBUTING.md for details on our code of conduct and development process.

Back to top

License

This build project is licensed under the MIT license.

Compiler-rt (and the llvm project in general) are released under a modified Apache 2.0 license.

Authors

Back to top