rearrange linker command generation

This commit is contained in:
dzaima 2024-05-09 20:14:25 +03:00
parent 4a40739398
commit 604b751994

View File

@ -18,6 +18,7 @@ opts ← ⟨
1, "NO_LDL", 0, @ 1, "NO_LDL", 0, @
1, "no_fPIC", 0, @ 1, "no_fPIC", 0, @
0, "v", "", "Version string to report by --version; v=0 to disable"
0, "j", @, "Number of parallel jobs" 0, "j", @, "Number of parallel jobs"
1, "verbose", 0, "Log more things" 1, "verbose", 0, "Log more things"
2, "rebuild", , "Forcibly rebuild cbqn/replxx/singeli/linker" 2, "rebuild", , "Forcibly rebuild cbqn/replxx/singeli/linker"
@ -43,8 +44,7 @@ opts ← ⟨
2, "sf", , "Singeli flags" 2, "sf", , "Singeli flags"
2, "LDFLAGS", , @ 2, "LDFLAGS", , @
2, "rm_f", , "Forcibly remove C compiler flag(s)" 2, "rm_f", , "Forcibly remove C compiler flag(s)"
2, "rm_lf", , "Forcibly remove linker flag(s)" 2, "rm_lf", , "Forcibly remove linker flag(s)"@+10
0, "v", "", "Version string to report by --version; v=0 to disable"@+10
1, "shared", 0, "Build a shared library" 1, "shared", 0, "Build a shared library"
1, "static-lib", 0, "Build a static library" 1, "static-lib", 0, "Build a static library"
@ -378,19 +378,20 @@ po ← { # parsed options
replxxc args replxxc args
} }
singeliFlags GetOpt "sf" singeliFlags GetOpt "sf"
Linker { 𝕊: linker {
bin @
args args
{ {
staticLib? staticLib?
args "ar" DOpt "LD" bin "ar" DOpt "LD"
args GetOpt "lf" args GetOpt "lf"
args GetOpt "LDFLAGS" args GetOpt "LDFLAGS"
args "-rcs" args "-rcs"
; ;
rdynamic (¬wasi) exportSymbols ¬windows rdynamic (¬wasi) exportSymbols ¬windows
args {replxx? cxx; cc} DOpt "LD" bin {replxx? cxx; cc} DOpt "LD"
args defLibs / "-lm" args defLibs / "-lm"
args DOpt "LD_LIBS" args DOpt "LD_LIBS"
args ((¬GetOpt "NO_LDL") defLibs ffi ¬bsd) / "-ldl" args ((¬GetOpt "NO_LDL") defLibs ffi ¬bsd) / "-ldl"
@ -409,12 +410,12 @@ po ← { # parsed options
args ( windows) / "-lpthread" args ( windows) / "-lpthread"
args ( staticBin) / "-static" args ( staticBin) / "-static"
args args (¬/) GetOpt "rm_lf" args args (¬/) GetOpt "rm_lf"
{"linker: "•Repr 𝕩} _verboseLog args
} }
linker args {"key":binargs; srcsdst: bin, "-o", dst srcs args}
} }
{"linker: "•Repr Linker "src1""src2""...", "dst"} _verboseLog@
{𝕊: CBQNc@ REPLXXcreplxx @ Linker@} verbose {𝕊: CBQNc@ REPLXXcreplxx @} verbose
} }
Hash {(32"0a"+¨1026)˜{𝕨+2×𝕩}˝5321•bit._cast(4)•Hash¨<𝕩} Hash {(32"0a"+¨1026)˜{𝕨+2×𝕩}˝5321•bit._cast(4)•Hash¨<𝕩}
@ -667,8 +668,7 @@ MakeSingeliInv ← { 𝕊 args‿Init‿cache‿id‿src‿customDeps: # src sho
MakeLinkerInv { 𝕊 GetArgscachenamesrcs: MakeLinkerInv { 𝕊 GetArgscachenamesrcs:
dst cache.File name dst cache.File name
GetCMD { 𝕊: GetCMD { 𝕊:
args GetArgs@ cmd "sh", rootDir, GetArgs {𝕩.dst}¨ srcs, dst, @
cmd "sh", rootDir, args, "-o", dst({𝕩.dst}¨ srcs)1args, @
{po.staticLib? "staticlib", AtRoot dst, cmd; cmd} {po.staticLib? "staticlib", AtRoot dst, cmd; cmd}
} }
AddRule cache, name, dst, GetCMD, "link", srcs AddRule cache, name, dst, GetCMD, "link", srcs
@ -756,7 +756,7 @@ cachedBin‿linkerCache ← {
} }
linkerDeps @¨/ cbqnCache, replxxCache, singeliCache linkerDeps @¨/ cbqnCache, replxxCache, singeliCache
linkerCache GetCache "linker", "linker cached result location", po.Linker@, {𝕩.folderHash}¨ linkerDeps linkerCache GetCache "linker", "linker cached result location", po.Linker "key", {𝕩.folderHash}¨ linkerDeps
{ {
po.versionName@? @; po.versionName@? @;
srcFile linkerCache.File "versionInfo.c" srcFile linkerCache.File "versionInfo.c"