New commits:
commit f98c6eba6ea0cad1514e0f45079dc43efa2ea382
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>
devel/llvm: flang, libclc, and experimental targets
Add optional support for building the flang FORTRAN frontend. Building
flang requires also building MLIR, and likely requires openmp as a
runtime (building without openmp is currently untested).
Add support for building experimental backend targets, most notably the
SPIR-V target. Enabling the SPIR-V experimental backend will result in
llvm-spirv being built. Refactor all target selections (backend,
runtime, and experimental backend), and ensure selection happens in
PREPARE since target selection affects which sources need to be
downloaded, and which other configuration combinations are possible.
Add support for the OpenCL library implementation libclc, including
choosing which libclc targets to build. Building libclc currently
requires a workaround in that it fails to find llvm-spirv in the build
itself, and requires a pre-existing llvm-spirv command. This bug is
tracked upstream (see the reference in BUILD). The workaround
implemented here requires having LLVM with llvm-spirv support already
present on your system, which for many means casting llvm once with
libclc but the SPIR-V backend enabled, and then casting llvm a second
time with libclc enabled.
commit 52292411ef49b226dd232c1f6c964aef61ab2dc0
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>
devel/llvm: add LoongArch to list of supported build targets
commit 57e499bda114e16c6a77b8e1eb0b12bac1532d21
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>
devel/llvm: don't hardcode host tool paths
Allow the search for host compilers and linkers to iterate through $PATH
rather than directly hardcoding them.
diff --git a/devel/llvm/BUILD b/devel/llvm/BUILD
index 4ad0dc2..8d1ec03 100755
--- a/devel/llvm/BUILD
+++ b/devel/llvm/BUILD
@@ -46,6 +46,20 @@ if [[ "$LLVM_WITH_CLANG" == y ]] ;then
OPTS="$OPTS -DCLANG_INCLUDE_TESTS=OFF"
fi &&
+if [[ "$LLVM_WITH_FLANG" == y ]] ;then
+ LLVM_PROJECTS="$LLVM_PROJECTS flang"
+fi &&
+
+if [[ "$LLVM_WITH_LIBCLC" == y ]] ;then
+ LLVM_PROJECTS="$LLVM_PROJECTS libclc" &&
+ OPTS="$OPTS -DLIBCLC_TARGETS_TO_BUILD=${LLVM_LIBCLC_TARGETS// /;}"
+fi &&
+
+# workaround for https://github.com/llvm/llvm-project/issues/109537
+if [[ "$LLVM_WITH_LIBCLC" == y ]] ;then
+ OPTS="$OPTS -DLLVM_SPIRV=$(command -v llvm-spirv)"
+fi &&
+
if [[ "$LLVM_WITH_LLD" == y ]] ;then
LLVM_PROJECTS="$LLVM_PROJECTS lld" &&
OPTS="$OPTS -DLLVM_TOOL_LLD_BUILD=ON"
@@ -68,6 +82,11 @@ if [[ "$LLVM_WITH_POLLY" == y ]] ;then
OPTS="$OPTS -DLLVM_TOOL_POLLY_BUILD=ON"
fi &&
# selecting "all" runtimes in the LLVM build system will only enable libcxx,
# libcxxabi, and libunwind, instead of actually all possible supported
# runtimes, so specify them manually
-if list_find "$LLVM_RUNTIMES" "all" ;then
- LLVM_RUNTIMES="${LLVM_ALL_RUNTIMES#all }"
+if list_find "$runtimes" "all" ;then
+ LLVM_RUNTIMES="${runtimes#all }"
fi &&
local compilers=""
for compiler in clang gcc ;do
- if command -v "/usr/bin/$compiler" > /dev/null ;then
+ if command -v "$compiler" > /dev/null;then
compilers="$compilers $compiler"
fi
done
local linkers="default "
for linker in bfd gold lld mold ;do
- if command -v "/usr/bin/ld.$linker" > /dev/null ;then
+ if command -v "ld.$linker" > /dev/null;then
linkers="$linkers $linker"
fi
done
@@ -55,6 +120,21 @@ config_query LLVM_WITH_LLDB "Build the LLDB debugger
(selects libcxx and lib
config_query LLVM_WITH_POLLY "Build the polyhedral optimizer (polly)?" n
&&
config_query LLVM_WITH_LLD "Build the LLVM linker (lld)?" n &&
config_query LLVM_WITH_MLIR "Build the LLVM multi-level intermediate
representation (MLIR)?" n &&
+config_query LLVM_WITH_FLANG "Build the flang fortran frontend (selects
MLIR)?" n &&
+
+if [[ "$LLVM_WITH_CLANG" == y ]] ;then
+ config_query LLVM_WITH_LIBCLC "Build the LLVM OpenCL implementation
(libclc)?" n &&
+ if [[ "$LLVM_WITH_LIBCLC" == y ]] ;then
+ config_query_multi LLVM_LIBCLC_TARGETS \
+ "Which libclc targets to build?" \
+ $libclc_targets
+ fi &&
+ case "$LLVM_LIBCLC_TARGETS" in
+ *spirv*)
+ LLVM_WITH_SPIRV=y &&
+ ;;
+ esac
+fi &&
if [[ "$LLVM_WITH_CLANG" == y ]] ;then
for required in compiler-rt ;do
@@ -62,6 +142,16 @@ if [[ "$LLVM_WITH_CLANG" == y ]] ;then
LLVM_RUNTIMES="$LLVM_RUNTIMES $required"
fi
done
+fi
+
+if [[ "$LLVM_WITH_FLANG" == y ]] ;then
+ LLVM_WITH_MLIR=y &&
+ persistent_add LLVM_WITH_MLIR
+ for required in compiler-rt openmp ;do
+ if ! list_find "$LLVM_RUNTIMES" "$required";then
+ LLVM_RUNTIMES="$LLVM_RUNTIMES $required"
+ fi
+ done
fi &&
if [[ "$LLVM_WITH_LLD" == y ]] ;then
@@ -73,3 +163,4 @@ if [[ "$LLVM_WITH_LLD" == y ]] ;then
fi &&
persistent_add LLVM_RUNTIMES
+persistent_add LLVM_WITH_SPIRV
diff --git a/devel/llvm/PRE_BUILD b/devel/llvm/PRE_BUILD
index 9756450..efcb675 100755
--- a/devel/llvm/PRE_BUILD
+++ b/devel/llvm/PRE_BUILD
@@ -20,6 +20,16 @@ if [[ "$LLVM_WITH_CLANG" == y ]]; then
ln -s ../../clang-tools-extra clang/tools/extra
fi &&
+if [[ "$LLVM_WITH_FLANG" == y ]]; then
+ unpack_file 34 &&
+ mv flang-${VERSION}.src flang
+fi &&
+
+if [[ "$LLVM_WITH_LIBCLC" == y ]]; then
+ unpack_file 31 &&
+ mv libclc-${VERSION}.src libclc
+fi &&
+
if [[ "$LLVM_WITH_LLD" == y ]]; then
unpack_file 11 &&
mv lld-${VERSION}.src lld
@@ -68,4 +78,9 @@ fi &&
if list_find "$LLVM_RUNTIMES" "openmp"; then
unpack_file 29 &&
mv openmp-${VERSION}.src openmp
+fi &&
+
+if [[ "$LLVM_WITH_SPIRV" == y ]]; then
+ unpack_file 33 &&
+ ln -s ../../SPIRV-LLVM-Translator-$SPIRV_VERSION} llvm/tools/llvm-spirv
fi
diff --git a/devel/llvm/PRE_SUB_DEPENDS b/devel/llvm/PRE_SUB_DEPENDS
index 00c2adf..80aec61 100755
--- a/devel/llvm/PRE_SUB_DEPENDS
+++ b/devel/llvm/PRE_SUB_DEPENDS
@@ -9,11 +9,14 @@ case "$THIS_SUB_DEPENDS" in
;;
BOLT) [[ "${LLVM_WITH_BOLT}" == "y" ]] ;;
CLANG) [[ "${LLVM_WITH_CLANG}" == "y" ]] ;;
+ FLANG) [[ "$LLVM_WITH_FLANG" == "y" ]] ;;
+ LIBCLC) [[ "$LLVM_WITH_LIBCLC" == "y" ]] ;;
LLD) [[ "${LLVM_WITH_LLD}" == "y" ]] ;;
LLDB) [[ "${LLVM_WITH_LLDB}" == "y" ]] ;;
MLIR) [[ "${LLVM_WITH_MLIR}" == "y" ]] ;;
POLLY) [[ "${LLVM_WITH_POLLY}" == "y" ]] ;;
RTTI) [[ "$LLVM_WITH_RTTI" == "y" ]] ;;
+ SPIRV) [[ "$LLVM_WITH_SPIRV" == "y" ]] ;;
*)
message "${PROBLEM_COLOR}bogus sub_depends: $SPELL
$THIS_SUB_DEPENDS${DEFAULT_COLOR}"
return 1
diff --git a/devel/llvm/SUB_DEPENDS b/devel/llvm/SUB_DEPENDS
index 62c0259..449a103 100755
--- a/devel/llvm/SUB_DEPENDS
+++ b/devel/llvm/SUB_DEPENDS
@@ -17,6 +17,14 @@ case "$THIS_SUB_DEPENDS" in
message "${MESSAGE_COLOR}Building clang enforced by
sub-dependency.$DEFAULT_COLOR"
LLVM_WITH_CLANG=y
;;
+ FLANG)
+ message "${MESSAGE_COLOR}Building flang enforced by
sub-dependency.$DEFAULT_COLOR"
+ LLVM_WITH_FLANG=y
+ ;;
+ LIBCLC)
+ message "${MESSAGE_COLOR}Building libclc enforced by
sub-dependency.$DEFAULT_COLOR"
+ LLVM_WITH_LIBCLC=y
+ ;;
LLD)
message "${MESSAGE_COLOR}Building lld enforced by
sub-dependency.$DEFAULT_COLOR"
LLVM_WITH_LLD=y
@@ -37,6 +45,10 @@ case "$THIS_SUB_DEPENDS" in
message "${MESSAGE_COLOR}RTTI support enforced by
sub-dependency.$DEFAULT_COLOR"
LLVM_WITH_RTTI=y
;;
+ SPIRV)
+ message "${MESSAGE_COLOR}SPIR-V support enforced by
sub-dependency.$DEFAULT_COLOR"
+ LLVM_WITH_SPIRV=y
+ ;;
*)
message "${PROBLEM_COLOR}bogus sub_depends: $SPELL
$THIS_SUB_DEPENDS${DEFAULT_COLOR}"
return 1
[[SM-Commit] ] GIT changes to master grimoire by Justin Boffemmyer (f98c6eba6ea0cad1514e0f45079dc43efa2ea382),
Justin Boffemmyer, 01/15/2025