Singeli compile commands

This commit is contained in:
dzaima 2024-11-12 10:14:22 +02:00
parent 0a4925e84f
commit f3094295dd
3 changed files with 58 additions and 26 deletions

3
.gitignore vendored
View File

@ -42,9 +42,10 @@ cbqn-jit.bqn
/local/
perf.data*
# clangd
# clangd / compile commands
compile_commands.json
.cache/
.singeli_compile_commands.json
# things not used anymore, but still may be present in existing clones
/SingeliClone/

View File

@ -689,10 +689,10 @@ AddRule ← { 𝕊 cache‿cacheKey‿dst‿GetCMD‿disp‿deps:
res
}
clangd {¬po.clangd? {_add{𝕨𝔽_𝕣𝕩:@} Files⇐}; AtRoot •Import "clangd.bqn"}
clangd {¬po.clangd? {_addC{𝕨𝔽_𝕣𝕩:@} AddSingeli⇐{𝕊:@} SingeliInit CFiles⇐}; AtRoot •Import "clangd.bqn"}
MakeCCInv { 𝕊 GetArgsInitcacheidsrccustomDeps: # src should be CBQN-base-dir-relative, so that cache doesn't store full paths
GetArgs clangd._add src
GetArgs clangd._addC src
dst cache.File id".o"
GetCMD { 𝕊:
Init @
@ -703,6 +703,7 @@ MakeCCInv ← { 𝕊 GetArgs‿Init‿cache‿id‿src‿customDeps: # src shoul
}
MakeSingeliInv { 𝕊 argsInitcacheidsrccustomDeps: # src should be CBQN-base-dir-relative, so that cache doesn't store full paths
args clangd.AddSingeli src
dst cache.File id".c"
GetCMD { 𝕊:
Init @
@ -733,7 +734,7 @@ cachedBin‿linkerCache ← {
"src/jit/", "nvm.c"
"src/utils/", "ryu.c", "utf.c", "hash.c", "file.c", "mut.c", "each.c", "bits.c"
cbqnSrc cbqnSrc clangd.Files "src"
cbqnSrc cbqnSrc clangd.CFiles "src"
singeliMap 1¨ ({ ({"X86_64":'x'; "AARCH64":'a'; "RV64":'g'; "NONE":'g'} po.arch) 𝕩}¨ ¨)/
"xa.""src/builtins/arithm.c""monarith", "xa.""src/builtins/compare.c""equal",
"xa.""src/builtins/arithd.c""dyarith", "xa.""src/builtins/cmp.c""cmp",
@ -781,6 +782,7 @@ cachedBin‿linkerCache ← {
("slow-pdep"< po.has) / "-c", "SLOW_PDEP=1"
{po.native? ; "-a" 1 ','¨ po.singeliArch}
clangd.SingeliInit po.singeliDir, po.arch
{𝕊: "Singeli args: "•Repr singeliArgs} _verboseLog @
{𝕊: "Singeli-determined C arch: "•Repr po.singeliCFlags; @} _verboseLog @
singeliObjs {MakeSingeliInv singeliArgs, {𝕊:UpdateSubmodule po.singeliDir}, singeliCache, 𝕩, "src/singeli/src/"•file.At 𝕩".singeli", (𝕩"dyarith")/gaRule}¨ 1¨singeliMap

View File

@ -6,21 +6,39 @@ Esc←{
𝕩 i out((i<out)/) 𝕩 # Replace
(i<in) /"\"¨ 𝕩 # Insert \
}
n@+10
lf@+10
JStr {"""",Esc 𝕩,""""}
JArr {'['']'˜2𝕨¨ 𝕩}
JObj {'{',n,¯2(JStr¨𝕨) {" ",𝕨,": ",𝕩,',',n}¨ 𝕩, n,'}'}
JArr {'['']'˜ (𝕨) 𝕨¨ 𝕩}
JObj {'{',lf,¯2(JStr¨𝕨) {" ",𝕨,": ",𝕩,',',lf}¨ 𝕩, lf,'}'}
precompFiles "bytecodeLocal""bytecodeSubmodule" {"../build/",𝕨,"/gen/",𝕩} "compiles""explain""formatter""runtime0""runtime1""runtime1x"
Files {
RecursiveFiles {
res
{'d'=•file.Type AtRoot 𝕩? 𝕊¨ 𝕩•file.At¨ •file.List AtRoot 𝕩; res <𝕩} 𝕩
{(<¯2𝕩)".c"".h"}¨/ res
res
}
CFiles {
res RecursiveFiles 𝕩
res {(<¯2𝕩)".c"".h"}¨/
res 𝕩•file.At¨ precompFiles
}
cObjects
_addC {cObjects <𝕩, (𝔽@)<𝕩}
singeliState @
singeliObjects
AddSingeli {
singeliObjects <𝕨𝕩
}
SingeliInit {
singeliState 𝕩
}
ModifyCBQNFlags {
filenames 4¨ ¨ 𝕩
flagK
@ -87,24 +105,35 @@ ModifyCBQNFlags ← {
𝕩 {nf 𝕊 f2: n, f"-Wno-undefined-internal", "-DCLANGD"f2}¨ (gfk•file.At¨ filenames)gfv <
}
objects
Finish { 𝕊 write:
objects ModifyCBQNFlags(({"src/"4𝕩}¨ objects)/)
_doWrite {
𝕩 •FCharswrite 𝕗
•Out {write? "Wrote "; "Would write "}, 𝕨, " to ", •file.At 𝕩
}
TLArr (","lf)JArr
{
cObjects ModifyCBQNFlags(({"src/"4𝕩}¨ cObjects)/)
FileObj { nameflags:
"file""directory""arguments" JObj JStr name, JStr AtRoot "", ", " JArr JStr¨ flags
}
res (","n) JArr FileObj¨ objects
res TLArr FileObj¨ cObjects
{
•Out {write? "Removing"; "Would remove"} " old "𝕩
•file.Removewrite 𝕩
}•file.Exists AtRoot "compile_commands.json"
resPath AtRoot "build/compile_commands.json"
"clangd compile commands" res _doWrite AtRoot "build/compile_commands.json"
}
{
write?
resPath •FChars res
•Out "Wrote clangd compile commands to "•file.At resPath
;
•Out "Would write clangd compile commands to "•file.At resPath
singeliState@? @;
dirarch singeliState
cmd0 "-a", arch, "-l", "="AtRoot dir •file.At "include"
res TLArr { cmdname:
"file""arguments" JObj JStr AtRoot name, ", " JArr JStr¨ cmd0 cmd
}¨ singeliObjects
"Singeli compile commands" res _doWrite AtRoot "build/.singeli_compile_commands.json"
}
}
_add {objects <𝕩, (𝔽@)<𝕩}