LinuxCommandLibrary

llvm-gcc

Compile C and C++ code using LLVM

TLDR

View documentation for the original command

$ tldr clang
copy

SYNOPSIS

llvm-gcc [options] file...

PARAMETERS

-c
    Compile or assemble the source files, but do not link. The output will be LLVM bitcode object files (.o or .bc).

-S
    Compile or assemble the source files, but do not assemble or link. The output will be LLVM assembly files (.ll).

-o file
    Place the output into file.

-g
    Produce debugging information in the operating system's native format (e.g., DWARF).

-Olevel
    Optimize the output. level can be 0 (no optimization), 1, 2, 3, or s (optimize for size) for increasing optimization levels.

-Wall
    Enable all common warning messages.

-Idir
    Add the directory dir to the list of directories to be searched for header files.

-Ldir
    Add the directory dir to the list of directories to be searched for libraries.

-llib
    Link with the library lib.

Notes:
    llvm-gcc supports most of the standard GCC compilation and linking options, interpreting them to generate or process LLVM IR.

DESCRIPTION

The llvm-gcc command was a special version of the GNU Compiler Collection (GCC) designed to produce LLVM Intermediate Representation (IR) bytecode instead of native machine code or traditional assembly language. It served as a crucial bridge during the early development of the LLVM project, enabling developers to compile existing C, C++, and other GCC-supported languages into a form that could be processed by LLVM's optimizers and back-ends.

Unlike Clang, which is a native front-end built specifically for LLVM, llvm-gcc operated by integrating LLVM as a backend into the GCC compilation pipeline. This allowed it to leverage GCC's mature front-ends (parsers, semantic analyzers for C, C++, etc.) while outsourcing the code generation phase to LLVM. The output could be LLVM bitcode (.bc files), LLVM assembly (.ll files), or even directly linked and executed using LLVM's Just-In-Time (JIT) compilation capabilities.

Its primary purpose was to provide a familiar GCC interface for users wanting to experiment with or migrate to the LLVM toolchain before Clang became a stable and feature-rich alternative. It was a vital component for bootstrapping the LLVM ecosystem and proving its capabilities with real-world codebases.

CAVEATS

llvm-gcc is largely deprecated and no longer actively maintained by the LLVM project or GNU. Its functionality has been superseded by Clang, which is the preferred and native front-end for LLVM, offering better performance, modern language feature support, and tighter integration with the LLVM infrastructure. Users are strongly advised to use Clang for new development and migration of existing projects to LLVM.

OUTPUT FORMATS

When compiling with llvm-gcc, the output format depends on the options used. Using -c will typically produce an LLVM bitcode file (often with a .o or .bc extension), while -S will generate human-readable LLVM assembly (.ll extension). These intermediate files can then be processed further by other LLVM utilities like llc for native code generation or opt for optimization.

ROLE IN LLVM ECOSYSTEM

llvm-gcc played a critical role in bootstrapping the LLVM ecosystem. It enabled developers to compile existing codebases into LLVM IR, allowing LLVM's powerful optimization passes and diverse backends to be tested and improved. It was a bridge to demonstrate LLVM's capabilities before the development of a native, tightly integrated front-end like Clang.

HISTORY

The development of llvm-gcc began in the early 2000s as a foundational component of the LLVM project. At the time, GCC was the dominant open-source compiler, and LLVM aimed to provide a flexible, retargetable compilation framework. Since building a new front-end from scratch (like Clang) was a massive undertaking, llvm-gcc was created as a pragmatic solution. It allowed the LLVM project to quickly demonstrate its optimization and code generation capabilities by leveraging GCC's well-established language front-ends.

For several years, llvm-gcc was the primary way to compile C/C++/Objective-C code into LLVM IR. It was used by Apple for their Xcode development environment before they transitioned to Clang as their default compiler. As Clang matured and became a viable, high-performance alternative, the necessity and relevance of llvm-gcc diminished. It was eventually phased out, marking a significant milestone in LLVM's evolution from a backend project to a complete compiler suite.

SEE ALSO

clang(1), gcc(1), llc(1), lli(1), llvm-link(1), opt(1)

Copied to clipboard