Commit a721b565 authored by Camil Staps's avatar Camil Staps 🚀

Add EnvironmentByteCodePrelink and PrelinkByteCode options to prelink bytecode...

Add EnvironmentByteCodePrelink and PrelinkByteCode options to prelink bytecode for use with the WebAssembly interpreter
parent 77053aa3
Pipeline #20762 passed with stage
in 52 seconds
......@@ -67,6 +67,7 @@ getCurrentAbcOpt :: !*GeneralSt -> (!String,!*GeneralSt)
getCurrentBCgen :: !*GeneralSt -> (!String,!*GeneralSt)
getCurrentBClink :: !*GeneralSt -> (!String,!*GeneralSt)
getCurrentBCstrip :: !*GeneralSt -> (!String,!*GeneralSt)
getCurrentBCprelink :: !*GeneralSt -> (!String,!*GeneralSt)
getCurrentLink :: !*GeneralSt -> (!String,!*GeneralSt)
getCurrentDynl :: !*GeneralSt -> (!String,!*GeneralSt)
getCurrentVers :: !*GeneralSt -> (!Int,!*GeneralSt)
......
......@@ -198,6 +198,11 @@ getCurrentBCstrip ps
# (ct,ps) = accPLoc (\p=:{pm_targets,pm_curtarg}->(pm_targets!!pm_curtarg,p)) ps
= (ct.target_bcstrip,ps)
getCurrentBCprelink :: !*GeneralSt -> (!String,!*GeneralSt)
getCurrentBCprelink ps
# (ct,ps) = accPLoc (\p=:{pm_targets,pm_curtarg}->(pm_targets!!pm_curtarg,p)) ps
= (ct.target_bcprelink,ps)
getCurrentLink :: !*GeneralSt -> (!String,!*GeneralSt)
getCurrentLink ps
# (ct,ps) = accPLoc (\p=:{pm_targets,pm_curtarg}->(pm_targets!!pm_curtarg,p)) ps
......
......@@ -183,6 +183,7 @@ getCurrentAbcOpt :: !*(PSt *General) -> (!String,!*PSt *General)
getCurrentBCgen :: !*(PSt *General) -> (!String,!*PSt *General)
getCurrentBClink :: !*(PSt *General) -> (!String,!*PSt *General)
getCurrentBCstrip :: !*(PSt *General) -> (!String,!*PSt *General)
getCurrentBCprelink :: !*(PSt *General) -> (!String,!*PSt *General)
getCurrentLink :: !*(PSt *General) -> (!String,!*PSt *General)
getCurrentDynl :: !*(PSt *General) -> (!String,!*PSt *General)
getCurrentVers :: !*(PSt *General) -> (!Int,!*PSt *General)
......
......@@ -460,6 +460,11 @@ getCurrentBCstrip ps
# (ct,ps) = accPLoc (\p=:{pm_targets,pm_curtarg}->(pm_targets!!pm_curtarg,p)) ps
= (ct.target_bcstrip,ps)
getCurrentBCprelink :: !*(PSt *General) -> (!String,!*PSt *General)
getCurrentBCprelink ps
# (ct,ps) = accPLoc (\p=:{pm_targets,pm_curtarg}->(pm_targets!!pm_curtarg,p)) ps
= (ct.target_bcprelink,ps)
getCurrentLink :: !*(PSt *General) -> (!String,!*PSt *General)
getCurrentLink ps
# (ct,ps) = accPLoc (\p=:{pm_targets,pm_curtarg}->(pm_targets!!pm_curtarg,p)) ps
......
......@@ -398,6 +398,9 @@ where
:+: CheckControl
[("Strip bytecode",Nothing,toMark lo.strip_bytecode,noPS (\l->{l & lo.strip_bytecode = not l.lo.strip_bytecode}))]
(Columns 1) [ControlPos (Left,zero)]
:+: CheckControl
[("Prelink bytecode",Nothing,toMark lo.prelink_bytecode,noPS (\l->{l & lo.prelink_bytecode = not l.lo.prelink_bytecode}))]
(Columns 1) [ControlPos (Left,zero)]
:+: TextControl ("Generate main bytecode file as: "+++bytecodepath) [ControlId bytecodepathId,ControlPos (Left,zero):if actualProject [] [ControlHide]]
:+: ButtonControl "Set bytecode file..." [ControlFunction setbytecodepath,ControlPos (Left,zero):if actualProject [] [ControlHide]]
)
......
......@@ -425,6 +425,7 @@ editTargets getTs setTs ps
, bcGenId :: !Id // bytecode generator
, bcLinkId :: !Id // bytecode linker
, bcStripId :: !Id // bytecode stripper
, bcPrelinkId :: !Id // bytecode prelinker
}
envDialog ap pp ts ct getTs setTs ps
......@@ -483,7 +484,7 @@ envDialog ap pp ts ct getTs setTs ps
) // selection update function
lbsllId
[ControlViewSize {h=siz.Size.h,w=300}]
# ([compId,cgenId,linkId,dynlId,versId,methId,abcOptId,bcGenId,bcLinkId,bcStripId:_],ps) = openIds 10 ps
# ([compId,cgenId,linkId,dynlId,versId,methId,abcOptId,bcGenId,bcLinkId,bcStripId,bcPrelinkId:_],ps) = openIds 11 ps
# environmentSettingsIds =
{ compId = compId
, cgenId = cgenId
......@@ -495,6 +496,7 @@ envDialog ap pp ts ct getTs setTs ps
, bcGenId = bcGenId
, bcLinkId = bcLinkId
, bcStripId = bcStripId
, bcPrelinkId = bcPrelinkId
}
# (c1id,ps) = openId ps
# (c2id,ps) = openId ps
......@@ -539,7 +541,7 @@ where
:+: Pane "Object Modules" (objmpane inifull lbobj c4id r4id)
) (Columns 2) [ControlPos (Left,zero)]
buttons wid okId cancelId getTs setTs ct ts {compId,cgenId,linkId,dynlId,versId,methId,abcOptId,bcGenId,bcLinkId,bcStripId}
buttons wid okId cancelId getTs setTs ct ts {compId,cgenId,linkId,dynlId,versId,methId,abcOptId,bcGenId,bcLinkId,bcStripId,bcPrelinkId}
= ButtonControl "Done"
[ ControlFunction savefun
, ControlId okId, ControlPos (Right,zero)
......@@ -590,13 +592,13 @@ where
= abort "Fatal error in environment dialog: window has disappeared."
# wdef = fromJust wdef
# [(ok1,comp),(ok2,cgen),(ok3,link),(ok4,dynl),(ok5,vers),(ok6,mnum),
(ok7,abcopt),(ok8,bcgen),(ok9,bclink),(ok10,bcstrip):_]
= getControlTexts [compId,cgenId,linkId,dynlId,versId,methId,abcOptId,bcGenId,bcLinkId,bcStripId] wdef
| not (ok1 && ok2 && ok3 && ok4 && ok5 && ok6 && ok7 && ok8 && ok9 && ok10)
(ok7,abcopt),(ok8,bcgen),(ok9,bclink),(ok10,bcstrip),(ok11,bcprelink):_]
= getControlTexts [compId,cgenId,linkId,dynlId,versId,methId,abcOptId,bcGenId,bcLinkId,bcStripId,bcPrelinkId] wdef
| not (ok1 && ok2 && ok3 && ok4 && ok5 && ok6 && ok7 && ok8 && ok9 && ok10 && ok11)
= abort "Fatal error in environment dialog: controls have disappeared."
| (isNothing comp) || (isNothing cgen) || (isNothing link) || (isNothing dynl)
|| (isNothing vers) || (isNothing mnum)
|| isNothing abcopt || isNothing bcgen || isNothing bclink || isNothing bcstrip
|| isNothing abcopt || isNothing bcgen || isNothing bclink || isNothing bcstrip || isNothing bcprelink
= abort "Fatal error in environment dialog: controls are empty."
# comp = fromJust comp
# cgen = fromJust cgen
......@@ -608,6 +610,7 @@ where
# bcgen = fromJust bcgen
# bclink = fromJust bclink
# bcstrip = fromJust bcstrip
# bcprelink = fromJust bcprelink
# ls =
{ ls
& tg.target_comp = comp
......@@ -619,6 +622,7 @@ where
, tg.target_bcgen = bcgen
, tg.target_bclink = bclink
, tg.target_bcstrip = bcstrip
, tg.target_bcprelink = bcprelink
}
# ls = case ls.tg.target_meth of
(CompileAsync _) -> {ls & tg.target_meth = CompileAsync (toInt mnum)}
......@@ -631,7 +635,7 @@ where
title
= TextControl "Environment Options" [ControlPos (Center,zero)]
toolpane tg {compId,cgenId,linkId,dynlId,versId,methId,abcOptId,bcGenId,bcLinkId,bcStripId}
toolpane tg {compId,cgenId,linkId,dynlId,versId,methId,abcOptId,bcGenId,bcLinkId,bcStripId,bcPrelinkId}
= TextControl "Compiler: " [ControlWidth textWidth]
:+: EditControl tg.target_comp (PixelWidth 250) 1
[ ControlId compId
......@@ -672,6 +676,11 @@ toolpane tg {compId,cgenId,linkId,dynlId,versId,methId,abcOptId,bcGenId,bcLinkId
[ ControlId bcStripId
, ControlActivate (noLS (appPIO (setEditControlSelection bcStripId 1 0)))
]
:+: TextControl "Bytecode Prelinker: " [ControlPos (Left,zero),ControlWidth textWidth]
:+: EditControl tg.target_bcprelink (PixelWidth 250) 1
[ ControlId bcPrelinkId
, ControlActivate (noLS (appPIO (setEditControlSelection bcPrelinkId 1 0)))
]
:+: TextControl "ABC version: " [ControlPos (Left,zero),ControlWidth textWidth]
:+: EditControl (toString tg.target_vers) (PixelWidth 250) 1
[ ControlId versId
......
......@@ -817,6 +817,9 @@ step intr (DLink ds=:{ok, newpaths, fileinfo, libsinfo, modpaths, abccache, proj
| not ok
= continue False newpaths False fileinfo libsinfo modpaths project intr (abccache, ps)
# (ok,ps) = if (lo.strip_bytecode && PR_GetByteCodePath project <> "") (ByteCodeStrip fileinfo project ps) (True, ps)
| not ok
= continue False newpaths False fileinfo libsinfo modpaths project intr (abccache, ps)
# (ok,ps) = if (lo.prelink_bytecode && PR_GetByteCodePath project <> "") (ByteCodePrelink project ps) (True, ps)
| not ok
= continue False newpaths False fileinfo libsinfo modpaths project intr (abccache, ps)
......@@ -1732,3 +1735,19 @@ ByteCodeStrip fileinfo project ps
(err ++ ["Bytecode stripper failed (exit code: " +++ toString exitcode +++ ")"])
# ps = updateErrorWindow err ps
= (exitcode == 0, ps)
ByteCodePrelink :: !Project !*GeneralSt -> *(!Bool, !*GeneralSt)
ByteCodePrelink project ps
# (startupdir,ps) = getStup ps
(bcprelink,ps) = getCurrentBCprelink ps
bcprelink = startupdir +++ DirSeparatorString +++ bcprelink
# bcpath = fulPath startupdir (PR_GetRootDir project) (PR_GetByteCodePath project)
pbcpath = (bcpath % (0,size bcpath-3)) +++ "pbc"
# ps = showInfo (Level2 ("Prelinking bytecode for '" +++ RemovePath bcpath +++ "'")) ps
# (exitcode,err,ps) = RunExternalCommand bcprelink [bcpath,"-o",pbcpath] startupdir ps
# err = if (exitcode == 0)
err
(err ++ ["Bytecode prelinker failed (exit code: " +++ toString exitcode +++ ")"])
# ps = updateErrorWindow err ps
= (exitcode == 0, ps)
......@@ -18,6 +18,7 @@ EnvsFileName :== "IDEEnvs"
, target_bcgen :: !String // bytecode generator
, target_bclink :: !String // bytecode linker
, target_bcstrip :: !String // bytecode stripper
, target_bcprelink :: !String // bytecode prelinker
, target_link :: !String // static/eager linker
, target_dynl :: !String // dynamic linker
, target_vers :: !Int // abc version
......
......@@ -31,6 +31,7 @@ t_StdEnv
, target_bcgen :: !String // bytecode generator
, target_bclink :: !String // bytecode linker
, target_bcstrip :: !String // bytecode stripper
, target_bcprelink :: !String // bytecode prelinker
, target_link :: !String // static/eager linker
, target_dynl :: !String // dynamic linker
, target_vers :: !Int // abc version
......@@ -137,6 +138,7 @@ emptyTarget =
, target_bcgen = ""
, target_bclink = ""
, target_bcstrip = ""
, target_bcprelink = ""
, target_link = ""
, target_dynl = ""
, target_vers = 42
......@@ -171,6 +173,7 @@ TargetTable =
, SimpleOption "EnvironmentByteCodeGen" (\a->a.target_bcgen) (\v a->{a & target_bcgen=v})
, SimpleOption "EnvironmentByteCodeLink" (\a->a.target_bclink) (\v a->{a & target_bclink=v})
, SimpleOption "EnvironmentByteCodeStrip" (\a->a.target_bcstrip) (\v a->{a & target_bcstrip=v})
, SimpleOption "EnvironmentByteCodePrelink" (\a->a.target_bcprelink) (\v a->{a & target_bcprelink=v})
, SimpleOption "EnvironmentLinker" (\a->a.target_link) (\v a->{a & target_link=v})
, SimpleOption "EnvironmentDynLink" (\a->a.target_dynl) (\v a->{a & target_dynl=v})
, SimpleOption "EnvironmentVersion" (\a->toString a.target_vers) (\v a->{a & target_vers=toInt v})
......@@ -212,6 +215,7 @@ t_StdEnv20
, target_bcgen = compiler_and_linker_directory+++DirSeparatorString+++IF_WINDOWS "ByteCodeGenerator.exe" "bcgen"
, target_bclink = compiler_and_linker_directory+++DirSeparatorString+++IF_WINDOWS "ByteCodeLinker.exe" "bclink"
, target_bcstrip = compiler_and_linker_directory+++DirSeparatorString+++IF_WINDOWS "ByteCodeStripper.exe" "bcstrip"
, target_bcprelink = compiler_and_linker_directory+++DirSeparatorString+++IF_WINDOWS "ByteCodePrelinker.exe" "bcprelink"
, target_link = IF_MACOSX "/usr/bin/gcc" (compiler_and_linker_directory+++DirSeparatorString+++IF_WINDOWS "StaticLinker.exe" "linker")
, target_dynl = "Tools"+++DirSeparatorString+++"Dynamics"+++DirSeparatorString+++"DynamicLinker.exe"
, target_vers = 920
......
......@@ -443,6 +443,7 @@ LinkOptionsTable =
, SimpleOption "ExportedNames" (\a->a.dll_export_list_name) (\v a->{a & dll_export_list_name = v})
// , SimpleOption "AddCarbResource" (\a->a.add_carb_resource) (\v a->{a & add_carb_resource = v})
, SimpleOption "StripByteCode" (\a->a.strip_bytecode) (\v a->{a & strip_bytecode=v})
, SimpleOption "PrelinkByteCode" (\a->a.prelink_bytecode) (\v a->{a & prelink_bytecode=v})
}
EditWdOptionsTable :: OptionsTable EditWdOptions
......
......@@ -40,6 +40,7 @@ instance fromString Processor
// , add_carb_resource :: !Bool // Mac-only!
, strip_bytecode :: !Bool // strip ABC bytecode
, prelink_bytecode :: !Bool // prelink bytecode for location-dependent interpretation
}
DefaultLinkOptions :: LinkOptions
......
......@@ -141,6 +141,7 @@ where
// , add_carb_resource :: !Bool // Mac-only!
, strip_bytecode :: !Bool // strip ABC bytecode
, prelink_bytecode :: !Bool // prelink bytecode for location-dependent interpretation
}
/*
instance == LinkOptions // do we need to check resource linking flags???
......@@ -172,6 +173,7 @@ DefaultLinkOptions =
, dll_export_list_name = ""
// , add_carb_resource = False // Clean2 ide targets Carbon?!
, strip_bytecode = False
, prelink_bytecode = False
}
:: LinkMethod
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment