llvm-g++
Compile C++ code using the LLVM compiler
TLDR
View documentation for the original command
SYNOPSIS
llvm-g++ [options] <source files> [-o <output file>]
PARAMETERS
-c
Compile or assemble the source files, but do not link. Generates object files (.o).
-S
Compile only; do not assemble or link. Generates assembly files (.s).
-E
Preprocess only; do not compile, assemble, or link. Outputs preprocessed source code.
-o <file>
Place the output into the specified <file> (e.g., executable, object file).
-I<dir>
Add the specified <dir> to the list of directories to search for include files.
-L<dir>
Add the specified <dir> to the list of directories to search for libraries.
-l<lib>
Link with the specified library <lib> (e.g., -lm for math library).
-Wall
Enable all common compiler warning messages.
-Wextra
Enable additional compiler warning messages not covered by -Wall.
-O<level>
Set the optimization level (e.g., -O0 for no optimization, -O1, -O2, -O3 for increasing optimization, -Os for size, -Oz for smallest size).
-g
Produce debugging information suitable for use with debuggers like GDB or LLDB.
-std=<c++std>
Specify the C++ standard to use (e.g., c++11, c++17, c++20).
-pthread
Link with the POSIX threads library. Required for multithreaded applications.
DESCRIPTION
llvm-g++ is typically a wrapper script or symbolic link designed to invoke a C++ compiler (often g++ or clang++) while ensuring that the underlying LLVM toolchain components are utilized for optimization, code generation, or specific build environments.
It serves as a bridge, allowing existing build systems configured for g++ to leverage LLVM's advanced compilation capabilities. Unlike g++ (which is part of the GNU Compiler Collection) or clang++ (the native C++ frontend for LLVM), llvm-g++ itself is not a distinct compiler but rather a convenience command. In modern development, clang++ is the direct and preferred command for compiling C++ with LLVM. llvm-g++ might be encountered in legacy build systems or specific distributions aiming to integrate LLVM more seamlessly into a GCC-like command structure.
CAVEATS
llvm-g++ is not a standardized command across all Linux distributions or LLVM installations. Its exact behavior depends on how it's configured; it might be an alias for clang++, or a wrapper for a g++ instance specifically configured to use LLVM components. The primary and recommended C++ compiler for the LLVM ecosystem is clang++. Relying on llvm-g++ might lead to portability issues across different build environments.
LLVM TOOLCHAIN INTEGRATION
LLVM (Low Level Virtual Machine) is a collection of modular and reusable compiler and toolchain technologies. Compilers like clang++ (and by extension, llvm-g++ when it acts as a wrapper) leverage various LLVM components: a frontend parses the source code into an LLVM Intermediate Representation (IR), which then undergoes optimization passes by the LLVM optimizer (opt), and finally, code generation for the target architecture by the LLVM backend (llc). This modular design allows for powerful cross-platform optimization and code generation capabilities.
HISTORY
The concept of llvm-g++ emerged in the early days of LLVM's development as an attempt to make LLVM's powerful backend and optimizer available through a familiar g++ interface. Before clang (LLVM's native frontend for C, C++, Objective-C) matured, developers often experimented with using g++ as the frontend but leveraging LLVM's llc (LLVM static compiler) and opt (LLVM optimizer) for the backend processing.
llvm-g++ could have been a wrapper for such a setup or an alias to a g++ build configured to use LLVM's Link-Time Optimization (LTO) capabilities via LLVM's linker plugins. With the significant evolution and adoption of clang and clang++ as full-fledged, high-performance LLVM frontends, the need for an llvm-g++ wrapper has largely diminished, making clang++ the primary command for LLVM-based C++ compilation today.