internal/rosa: llvm bootstrap artifacts
All checks were successful
Test / Create distribution (push) Successful in 50s
Test / Sandbox (push) Successful in 3m2s
Test / ShareFS (push) Successful in 5m10s
Test / Sandbox (race detector) (push) Successful in 5m37s
Test / Hpkg (push) Successful in 5m40s
Test / Hakurei (push) Successful in 6m9s
Test / Hakurei (race detector) (push) Successful in 8m16s
Test / Flake checks (push) Successful in 2m0s
All checks were successful
Test / Create distribution (push) Successful in 50s
Test / Sandbox (push) Successful in 3m2s
Test / ShareFS (push) Successful in 5m10s
Test / Sandbox (race detector) (push) Successful in 5m37s
Test / Hpkg (push) Successful in 5m40s
Test / Hakurei (push) Successful in 6m9s
Test / Hakurei (race detector) (push) Successful in 8m16s
Test / Flake checks (push) Successful in 2m0s
This bootstraps the LLVM toolchain across multiple artifacts. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package rosa
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -189,3 +190,115 @@ cp -r /system/include /usr/include && rm -rf /system/include
|
||||
ScriptEarly: scriptEarly, Script: script + attr.script,
|
||||
})
|
||||
}
|
||||
|
||||
// NewLLVM returns LLVM toolchain across multiple [pkg.Artifact].
|
||||
func (t Toolchain) NewLLVM() (musl, compilerRT, runtimes, clang pkg.Artifact) {
|
||||
var target string
|
||||
switch runtime.GOARCH {
|
||||
case "386", "amd64":
|
||||
target = "X86"
|
||||
|
||||
default:
|
||||
panic("unsupported target " + runtime.GOARCH)
|
||||
}
|
||||
|
||||
minimalDeps := [][2]string{
|
||||
{"LLVM_ENABLE_ZLIB", "OFF"},
|
||||
{"LLVM_ENABLE_ZSTD", "OFF"},
|
||||
{"LLVM_ENABLE_LIBXML2", "OFF"},
|
||||
}
|
||||
|
||||
compilerRT = t.newLLVM("compiler-rt", &llvmAttr{
|
||||
env: []string{
|
||||
ldflags(false),
|
||||
},
|
||||
cmake: [][2]string{
|
||||
// libc++ not yet available
|
||||
{"CMAKE_CXX_COMPILER_TARGET", ""},
|
||||
|
||||
{"COMPILER_RT_BUILD_BUILTINS", "ON"},
|
||||
{"COMPILER_RT_DEFAULT_TARGET_ONLY", "ON"},
|
||||
{"LLVM_ENABLE_PER_TARGET_RUNTIME_DIR", "ON"},
|
||||
|
||||
// does not work without libunwind
|
||||
{"COMPILER_RT_BUILD_CTX_PROFILE", "OFF"},
|
||||
{"COMPILER_RT_BUILD_LIBFUZZER", "OFF"},
|
||||
{"COMPILER_RT_BUILD_MEMPROF", "OFF"},
|
||||
{"COMPILER_RT_BUILD_PROFILE", "OFF"},
|
||||
{"COMPILER_RT_BUILD_SANITIZERS", "OFF"},
|
||||
{"COMPILER_RT_BUILD_XRAY", "OFF"},
|
||||
},
|
||||
append: []string{"compiler-rt"},
|
||||
extra: []pkg.Artifact{t.NewMusl(&MuslAttr{
|
||||
Headers: true,
|
||||
Env: []string{
|
||||
"CC=clang",
|
||||
},
|
||||
})},
|
||||
script: `
|
||||
mkdir -p "${ROSA_INSTALL_PREFIX}/lib/clang/21/lib/"
|
||||
ln -s \
|
||||
"../../../${ROSA_TRIPLE}" \
|
||||
"${ROSA_INSTALL_PREFIX}/lib/clang/21/lib/"
|
||||
|
||||
ln -s \
|
||||
"clang_rt.crtbegin-$(uname -m).o" \
|
||||
"${ROSA_INSTALL_PREFIX}/lib/${ROSA_TRIPLE}/crtbeginS.o"
|
||||
ln -s \
|
||||
"clang_rt.crtend-$(uname -m).o" \
|
||||
"${ROSA_INSTALL_PREFIX}/lib/${ROSA_TRIPLE}/crtendS.o"
|
||||
`,
|
||||
})
|
||||
|
||||
musl = t.NewMusl(&MuslAttr{
|
||||
Extra: []pkg.Artifact{compilerRT},
|
||||
Env: []string{
|
||||
ldflags(false),
|
||||
"CC=clang",
|
||||
"LIBCC=/system/lib/clang/21/lib/" +
|
||||
triplet() + "/libclang_rt.builtins.a",
|
||||
"AR=ar",
|
||||
"RANLIB=ranlib",
|
||||
},
|
||||
})
|
||||
|
||||
runtimes = t.newLLVM("runtimes", &llvmAttr{
|
||||
env: []string{
|
||||
ldflags(false),
|
||||
},
|
||||
flags: llvmRuntimeLibunwind | llvmRuntimeLibcxx | llvmRuntimeLibcxxABI,
|
||||
cmake: slices.Concat([][2]string{
|
||||
// libc++ not yet available
|
||||
{"CMAKE_CXX_COMPILER_WORKS", "ON"},
|
||||
|
||||
{"LIBCXX_HAS_ATOMIC_LIB", "OFF"},
|
||||
{"LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL", "OFF"},
|
||||
}, minimalDeps),
|
||||
append: []string{"runtimes"},
|
||||
extra: []pkg.Artifact{
|
||||
compilerRT,
|
||||
musl,
|
||||
},
|
||||
})
|
||||
|
||||
clang = t.newLLVM("clang", &llvmAttr{
|
||||
flags: llvmProjectClang | llvmProjectLld,
|
||||
env: []string{
|
||||
"CFLAGS=" + cflags,
|
||||
"CXXFLAGS=" + cxxflags(),
|
||||
ldflags(false),
|
||||
},
|
||||
cmake: slices.Concat([][2]string{
|
||||
{"LLVM_TARGETS_TO_BUILD", target},
|
||||
{"CMAKE_CROSSCOMPILING", "OFF"},
|
||||
{"CXX_SUPPORTS_CUSTOM_LINKER", "ON"},
|
||||
}, minimalDeps),
|
||||
extra: []pkg.Artifact{
|
||||
musl,
|
||||
compilerRT,
|
||||
runtimes,
|
||||
},
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user