internal/rosa/llvm: remove unused field
All checks were successful
Test / Create distribution (push) Successful in 1m20s
Test / Sandbox (push) Successful in 4m18s
Test / Sandbox (race detector) (push) Successful in 6m53s
Test / ShareFS (push) Successful in 7m0s
Test / Hakurei (race detector) (push) Successful in 10m52s
Test / Hakurei (push) Successful in 6m57s
Test / Flake checks (push) Successful in 1m34s

This change also renames confusingly named flags field and corrects its doc comment.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-04-10 02:13:26 +09:00
parent 7319c7adf9
commit 68a2f0c240

View File

@@ -13,8 +13,8 @@ import (
// llvmAttr holds the attributes that will be applied to a new [pkg.Artifact] // llvmAttr holds the attributes that will be applied to a new [pkg.Artifact]
// containing a LLVM variant. // containing a LLVM variant.
type llvmAttr struct { type llvmAttr struct {
// Passed through to PackageAttr.Flag. // Enabled projects and runtimes.
flags int pr int
// Concatenated with default environment for PackageAttr.Env. // Concatenated with default environment for PackageAttr.Env.
env []string env []string
@@ -24,8 +24,6 @@ type llvmAttr struct {
append []string append []string
// Passed through to PackageAttr.NonStage0. // Passed through to PackageAttr.NonStage0.
nonStage0 []pkg.Artifact nonStage0 []pkg.Artifact
// Passed through to PackageAttr.Paths.
paths []pkg.ExecPath
// Concatenated with default fixup for CMakeHelper.Script. // Concatenated with default fixup for CMakeHelper.Script.
script string script string
@@ -75,19 +73,18 @@ func llvmFlagName(flag int) string {
// newLLVMVariant returns a [pkg.Artifact] containing a LLVM variant. // newLLVMVariant returns a [pkg.Artifact] containing a LLVM variant.
func (t Toolchain) newLLVMVariant(variant string, attr *llvmAttr) pkg.Artifact { func (t Toolchain) newLLVMVariant(variant string, attr *llvmAttr) pkg.Artifact {
if attr == nil { if attr == nil {
panic("LLVM attr must be non-nil") panic("LLVM attr must be non-nil")
} }
var projects, runtimes []string var projects, runtimes []string
for i := 1; i < llvmProjectAll; i <<= 1 { for i := 1; i < llvmProjectAll; i <<= 1 {
if attr.flags&i != 0 { if attr.pr&i != 0 {
projects = append(projects, llvmFlagName(i)) projects = append(projects, llvmFlagName(i))
} }
} }
for i := (llvmProjectAll + 1) << 1; i < llvmRuntimeAll; i <<= 1 { for i := (llvmProjectAll + 1) << 1; i < llvmRuntimeAll; i <<= 1 {
if attr.flags&i != 0 { if attr.pr&i != 0 {
runtimes = append(runtimes, llvmFlagName(i)) runtimes = append(runtimes, llvmFlagName(i))
} }
} }
@@ -126,7 +123,7 @@ func (t Toolchain) newLLVMVariant(variant string, attr *llvmAttr) pkg.Artifact {
}...) }...)
} }
if attr.flags&llvmProjectClang != 0 { if attr.pr&llvmProjectClang != 0 {
cache = append(cache, []KV{ cache = append(cache, []KV{
{"CLANG_DEFAULT_LINKER", "lld"}, {"CLANG_DEFAULT_LINKER", "lld"},
{"CLANG_DEFAULT_CXX_STDLIB", "libc++"}, {"CLANG_DEFAULT_CXX_STDLIB", "libc++"},
@@ -134,30 +131,30 @@ func (t Toolchain) newLLVMVariant(variant string, attr *llvmAttr) pkg.Artifact {
{"CLANG_DEFAULT_UNWINDLIB", "libunwind"}, {"CLANG_DEFAULT_UNWINDLIB", "libunwind"},
}...) }...)
} }
if attr.flags&llvmProjectLld != 0 { if attr.pr&llvmProjectLld != 0 {
script += ` script += `
ln -s ld.lld /work/system/bin/ld ln -s ld.lld /work/system/bin/ld
` `
} }
if attr.flags&llvmRuntimeCompilerRT != 0 { if attr.pr&llvmRuntimeCompilerRT != 0 {
if attr.append == nil { if attr.append == nil {
cache = append(cache, []KV{ cache = append(cache, []KV{
{"COMPILER_RT_USE_LLVM_UNWINDER", "ON"}, {"COMPILER_RT_USE_LLVM_UNWINDER", "ON"},
}...) }...)
} }
} }
if attr.flags&llvmRuntimeLibunwind != 0 { if attr.pr&llvmRuntimeLibunwind != 0 {
cache = append(cache, []KV{ cache = append(cache, []KV{
{"LIBUNWIND_USE_COMPILER_RT", "ON"}, {"LIBUNWIND_USE_COMPILER_RT", "ON"},
}...) }...)
} }
if attr.flags&llvmRuntimeLibcxx != 0 { if attr.pr&llvmRuntimeLibcxx != 0 {
cache = append(cache, []KV{ cache = append(cache, []KV{
{"LIBCXX_HAS_MUSL_LIBC", "ON"}, {"LIBCXX_HAS_MUSL_LIBC", "ON"},
{"LIBCXX_USE_COMPILER_RT", "ON"}, {"LIBCXX_USE_COMPILER_RT", "ON"},
}...) }...)
} }
if attr.flags&llvmRuntimeLibcxxABI != 0 { if attr.pr&llvmRuntimeLibcxxABI != 0 {
cache = append(cache, []KV{ cache = append(cache, []KV{
{"LIBCXXABI_USE_COMPILER_RT", "ON"}, {"LIBCXXABI_USE_COMPILER_RT", "ON"},
{"LIBCXXABI_USE_LLVM_UNWINDER", "ON"}, {"LIBCXXABI_USE_LLVM_UNWINDER", "ON"},
@@ -193,7 +190,6 @@ index 9da357a7ebb9..b2931510c1ae 100644
"ROSA_LLVM_RUNTIMES=" + strings.Join(runtimes, ";"), "ROSA_LLVM_RUNTIMES=" + strings.Join(runtimes, ";"),
}, attr.env), }, attr.env),
Paths: attr.paths,
Flag: TExclusive, Flag: TExclusive,
}, &CMakeHelper{ }, &CMakeHelper{
Variant: variant, Variant: variant,
@@ -294,7 +290,7 @@ ln -s \
env: stage0ExclConcat(t, []string{}, env: stage0ExclConcat(t, []string{},
"LDFLAGS="+earlyLDFLAGS(false), "LDFLAGS="+earlyLDFLAGS(false),
), ),
flags: llvmRuntimeLibunwind | llvmRuntimeLibcxx | llvmRuntimeLibcxxABI, pr: llvmRuntimeLibunwind | llvmRuntimeLibcxx | llvmRuntimeLibcxxABI,
cmake: slices.Concat([]KV{ cmake: slices.Concat([]KV{
// libc++ not yet available // libc++ not yet available
{"CMAKE_CXX_COMPILER_WORKS", "ON"}, {"CMAKE_CXX_COMPILER_WORKS", "ON"},
@@ -310,7 +306,7 @@ ln -s \
}) })
clang = t.newLLVMVariant("clang", &llvmAttr{ clang = t.newLLVMVariant("clang", &llvmAttr{
flags: llvmProjectClang | llvmProjectLld, pr: llvmProjectClang | llvmProjectLld,
env: stage0ExclConcat(t, []string{}, env: stage0ExclConcat(t, []string{},
"CFLAGS="+earlyCFLAGS, "CFLAGS="+earlyCFLAGS,
"CXXFLAGS="+earlyCXXFLAGS(), "CXXFLAGS="+earlyCXXFLAGS(),