summaryrefslogtreecommitdiff
path: root/eclass/llvm.eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2024-02-10 17:34:25 +0000
committerV3n3RiX <venerix@koprulu.sector>2024-02-10 17:34:25 +0000
commit0bb42730e8fc9c8e571f12e3189c6c6f8d532c24 (patch)
treecba6032fbed30be2b0764494607c3ec9dda0c18a /eclass/llvm.eclass
parentcc901a8ce7c6bfe97e3b4f048619693d360ae348 (diff)
gentoo auto-resync : 10:02:2024 - 17:34:25
Diffstat (limited to 'eclass/llvm.eclass')
-rw-r--r--eclass/llvm.eclass117
1 files changed, 4 insertions, 113 deletions
diff --git a/eclass/llvm.eclass b/eclass/llvm.eclass
index 91cc68d966fe..e297fe992c9f 100644
--- a/eclass/llvm.eclass
+++ b/eclass/llvm.eclass
@@ -7,6 +7,7 @@
# @AUTHOR:
# Michał Górny <mgorny@gentoo.org>
# @SUPPORTED_EAPIS: 7 8
+# @PROVIDES: llvm-utils
# @BLURB: Utility functions to build against slotted LLVM
# @DESCRIPTION:
# The llvm.eclass provides utility functions that can be used to build
@@ -64,6 +65,8 @@ esac
if [[ ! ${_LLVM_ECLASS} ]]; then
_LLVM_ECLASS=1
+inherit llvm-utils
+
# make sure that the versions installing straight into /usr/bin
# are uninstalled
DEPEND="!!sys-devel/llvm:0"
@@ -174,95 +177,6 @@ get_llvm_prefix() {
echo "${prefix}/usr/lib/llvm/$(get_llvm_slot "${@}")"
}
-# @FUNCTION: llvm_tuple_to_target
-# @USAGE: [<tuple>]
-# @DESCRIPTION:
-# Translate a tuple into a target suitable for LLVM_TARGETS.
-# Defaults to ${CHOST} if not specified.
-llvm_tuple_to_target() {
- debug-print-function ${FUNCNAME} "${@}"
-
- case ${1:-${CHOST}} in
- aarch64*) echo "AArch64";;
- amdgcn*) echo "AMDGPU";;
- arc*) echo "ARC";;
- arm*) echo "ARM";;
- avr*) echo "AVR";;
- bpf*) echo "BPF";;
- csky*) echo "CSKY";;
- loong*) echo "LoongArch";;
- m68k*) echo "M68k";;
- mips*) echo "Mips";;
- msp430*) echo "MSP430";;
- nvptx*) echo "NVPTX";;
- powerpc*) echo "PowerPC";;
- riscv*) echo "RISCV";;
- sparc*) echo "Sparc";;
- s390*) echo "SystemZ";;
- x86_64*|i?86*) echo "X86";;
- xtensa*) echo "Xtensa";;
- *) die "Unknown LLVM target for tuple ${1:-${CHOST}}"
- esac
-}
-
-# @FUNCTION: llvm_fix_clang_version
-# @USAGE: <variable-name>...
-# @DESCRIPTION:
-# Fix the clang compiler name in specified variables to include
-# the major version, to prevent PATH alterations from forcing an older
-# clang version being used.
-llvm_fix_clang_version() {
- debug-print-function ${FUNCNAME} "${@}"
-
- local shopt_save=$(shopt -p -o noglob)
- set -f
- local var
- for var; do
- local split=( ${!var} )
- case ${split[0]} in
- *clang|*clang++|*clang-cpp)
- local version=()
- read -r -a version < <("${split[0]}" --version)
- local major=${version[-1]%%.*}
- if [[ -n ${major//[0-9]} ]]; then
- die "${var}=${!var} produced invalid --version: ${version[*]}"
- fi
-
- split[0]+=-${major}
- if ! type -P "${split[0]}" &>/dev/null; then
- die "${split[0]} does not seem to exist"
- fi
- declare -g "${var}=${split[*]}"
- ;;
- esac
- done
- ${shopt_save}
-}
-
-# @FUNCTION: llvm_fix_tool_path
-# @USAGE: <variable-name>...
-# @DESCRIPTION:
-# Fix the LLVM tools referenced in the specified variables to their
-# current location, to prevent PATH alterations from forcing older
-# versions being used.
-llvm_fix_tool_path() {
- debug-print-function ${FUNCNAME} "${@}"
-
- local shopt_save=$(shopt -p -o noglob)
- set -f
- local var
- for var; do
- local split=( ${!var} )
- local path=$(type -P ${split[0]} 2>/dev/null)
- # if it resides in one of the LLVM prefixes, it's an LLVM tool!
- if [[ ${path} == "${BROOT}/usr/lib/llvm"* ]]; then
- split[0]=${path}
- declare -g "${var}=${split[*]}"
- fi
- done
- ${shopt_save}
-}
-
# @FUNCTION: llvm_pkg_setup
# @DESCRIPTION:
# Prepend the appropriate executable directory for the newest
@@ -298,30 +212,7 @@ llvm_pkg_setup() {
llvm_fix_tool_path LLVM_CONFIG
fi
- local prefix=${ESYSROOT}
- local llvm_path=${prefix}/usr/lib/llvm/${LLVM_SLOT}/bin
- local IFS=:
- local split_path=( ${PATH} )
- local new_path=()
- local x added=
-
- # prepend new path before first LLVM version found
- for x in "${split_path[@]}"; do
- if [[ ${x} == */usr/lib/llvm/*/bin ]]; then
- if [[ ${x} != ${llvm_path} ]]; then
- new_path+=( "${llvm_path}" )
- elif [[ ${added} && ${x} == ${llvm_path} ]]; then
- # deduplicate
- continue
- fi
- added=1
- fi
- new_path+=( "${x}" )
- done
- # ...or to the end of PATH
- [[ ${added} ]] || new_path+=( "${llvm_path}" )
-
- export PATH=${new_path[*]}
+ llvm_prepend_path "${LLVM_SLOT}"
fi
}