Skip to content

Assembling a Complete Toolchain

clang仅仅是一个front end,要想完全替代gcc还需要结合本文的内容。

Assembling a Complete Toolchain

Introduction

Tools

  • Preprocessor

  • Parsing

  • IR generation

  • Compiler backend

  • Assembler

  • Linker

Clang provides all of these pieces other than the linker.

Runtime libraries

A number of different runtime libraries are required to provide different layers of support for C family programs. Clang will implicitly link an appropriate implementation of each runtime library, selected based on target defaults or explicitly selected by the --rtlib= and --stdlib= flags.

NOTE: 需要做的是使用--rtlib= and --stdlib= flags来使用llvm的library。

Compiler runtime

compiler-rt (LLVM)
libgcc_s (GNU)

Atomics library

compiler-rt (LLVM)
libatomic (GNU)