aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-05-02 22:17:57 +0900
committerOphestra <cat@gensokyo.uk>2026-05-02 22:17:57 +0900
commit2c7ae67a67c9504f667f5463895aef2f3140a39d (patch)
tree3382fa9c6d4b6659abd2d10a4c2fa9f3a627c1bf
parent3826621b21ae2936c76d07f2ce934215dc89abd0 (diff)
internal/rosa/llvm: LIT args helper
This is useful for other projects using LIT. Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--internal/rosa/llvm.go32
1 files changed, 23 insertions, 9 deletions
diff --git a/internal/rosa/llvm.go b/internal/rosa/llvm.go
index 7f37c71d..9effb758 100644
--- a/internal/rosa/llvm.go
+++ b/internal/rosa/llvm.go
@@ -3,11 +3,33 @@ package rosa
import (
"regexp"
"runtime"
+ "slices"
"strings"
"hakurei.app/internal/pkg"
)
+// litArgs returns [LIT] arguments for optional verbosity and check skipping.
+func litArgs(verbose bool, skipChecks ...string) string {
+ args := []string{"-sv"}
+ if verbose {
+ args[0] = "--verbose"
+ }
+
+ if len(skipChecks) > 0 {
+ skipChecks = slices.Clone(skipChecks)
+ for i, s := range skipChecks {
+ s = regexp.QuoteMeta(s)
+ s = strings.ReplaceAll(s, "/", "\\/")
+ skipChecks[i] = s
+ }
+ args = append(args,
+ "--filter-out='\\''"+strings.Join(skipChecks, "|")+"'\\''")
+ }
+
+ return "'" + strings.Join(args, " ") + "'"
+}
+
func (t Toolchain) newLLVM() (pkg.Artifact, string) {
cache := []KV{
{"ENABLE_LINKER_BUILD_ID", "ON"},
@@ -96,11 +118,6 @@ func (t Toolchain) newLLVM() (pkg.Artifact, string) {
"unwind_leaffunction",
)
}
- for i, s := range skipChecks {
- s = regexp.QuoteMeta(s)
- s = strings.ReplaceAll(s, "/", "\\/")
- skipChecks[i] = s
- }
if presetOpts&OptLLVMNoLTO == 0 {
cache = append(cache, []KV{
@@ -113,10 +130,7 @@ func (t Toolchain) newLLVM() (pkg.Artifact, string) {
// symbols: clock_gettime, mallopt
{"COMPILER_RT_INCLUDE_TESTS", "OFF"},
- {"LLVM_LIT_ARGS", "'" + strings.Join([]string{
- "--verbose",
- "--filter-out='\\''" + strings.Join(skipChecks, "|") + "'\\''",
- }, " ") + "'"},
+ {"LLVM_LIT_ARGS", litArgs(true, skipChecks...)},
}...)
}