LLVM-R2.ECLASS

Section: eclass-manpages (5)
Updated: Mar 2025
Index Return to Main Contents

NAME

llvm-r2.eclass - Provide LLVM_SLOT to build against slotted LLVM

DESCRIPTION

An eclass to reliably depend on a set of LLVM-related packages in a matching slot. To use the eclass:

1. Set LLVM_COMPAT to the list of supported LLVM slots.

2. Use llvm_gen_dep and/or LLVM_USEDEP to add appropriate
   dependencies.

3. Use llvm-r2_pkg_setup, llvm_chost_setup, llvm_cbuild_setup,
   get_llvm_prefix or LLVM_SLOT.

The eclass sets IUSE and REQUIRED_USE. The flag corresponding to the newest supported stable LLVM slot (or the newest testing, if no stable slots are supported) is enabled by default.

Note that the eclass aims for a best-effort support of CHOST builds (i.e. compiling/linking against LLVM) and CBUILD use (i.e. calling LLVM tools at build time). You need to determine what the package in question needs, and put the appropriate packages in DEPEND and/or BDEPEND appropriately.

Example: LLVM_COMPAT=( {16..18} )

inherit llvm-r2

DEPEND="
  dev-libs/libfoo[${LLVM_USEDEP}]
  $(llvm_gen_dep '
    llvm-core/clang:${LLVM_SLOT}=
    llvm-core/llvm:${LLVM_SLOT}=
  ') "

SUPPORTED EAPIS

8

TRANSITIVELY PROVIDED ECLASSES

llvm-utils

FUNCTIONS

llvm_gen_dep <dependency>
Output a dependency block, repeating "<dependency>" conditionally to all llvm_slot_* USE flags. Any occurences of '${LLVM_SLOT}' within the block will be substituted for the respective slot.

Example: DEPEND="
  $(llvm_gen_dep '
    llvm-core/clang:${LLVM_SLOT}=
    llvm-core/llvm:${LLVM_SLOT}=
  ') "

get_llvm_prefix [-b|-d]
Output the path to the selected LLVM slot.

With no option or "-d", the path is prefixed by ESYSROOT. LLVM dependencies should be in DEPEND then.

With "-b" option, the path is prefixed by BROOT. LLVM dependencies should be in BDEPEND then.

generate_llvm_config
Output a llvm-config compatible script that yields paths specific to the requested LLVM version.
llvm_cbuild_setup
Prepend the PATH for selected LLVM version in CBUILD.

This function is meant to be used when the package in question uses LLVM tools at build time. It is called automatically by llvm-r2_pkg_setup if LLVM is found installed in BROOT.

Note that llvm-config from this path must not be used to build against LLVM, as that will break cross-compilation.

llvm_chost_setup
Set the environment for finding selected LLVM slot installed for CHOST. Create llvm-config wrappers to satisfy legacy lookups.

This function is meant to be used when the package in question uses LLVM compiles against and links to LLVM. It is called automatically by llvm-r2_pkg_setup if LLVM is found installed in ESYSROOT.

Note that the generated llvm-config may refer to CBUILD installation of LLVM via --bindir, if it is found available.

llvm-r2_pkg_setup
Handle all supported setup actions automatically. If LLVM is found installed for CBUILD, call llvm_cbuild_setup. If it is found installed for CHOST, call llvm_chost_setup.

This function is a no-op when installing a binary package.

Note that this function is not exported if LLVM_OPTIONAL is set. In that case, it needs to be called manually.

ECLASS VARIABLES

LLVM_COMPAT (REQUIRED) (SET BEFORE INHERIT)
A list of LLVM slots supported by the package, oldest to newest.

Example: LLVM_COMPAT=( {15..17} )

LLVM_OPTIONAL (SET BEFORE INHERIT)
If set to a non-empty value, disables setting REQUIRED_USE and exporting pkg_setup. You have to add LLVM_REQUIRED_USE and call pkg_setup manually, with appropriate USE conditions.
LLVM_REQUIRED_USE (GENERATED BY ECLASS)
An eclass-generated REQUIRED_USE string that enforces selecting exactly one slot. It LLVM_OPTIONAL is set, it needs to be copied into REQUIRED_USE, under appropriate USE conditions. Otherwise, it is added automatically.
LLVM_USEDEP (GENERATED BY ECLASS)
An eclass-generated USE dependency string that can be applied to other packages using the same eclass, to enforce a LLVM slot match.

AUTHORS

Michał Górny <[email protected]>

MAINTAINERS

Michał Górny <[email protected]>

REPORTING BUGS

Please report bugs via https://bugs.gentoo.org/

FILES

llvm-r2.eclass

SEE ALSO

ebuild(5)
https://gitweb.gentoo.org/repo/gentoo.git/log/eclass/llvm-r2.eclass


Index

NAME
DESCRIPTION
SUPPORTED EAPIS
TRANSITIVELY PROVIDED ECLASSES
FUNCTIONS
ECLASS VARIABLES
AUTHORS
MAINTAINERS
REPORTING BUGS
FILES
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 03:27:01 GMT, March 25, 2025