mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-02 06:16:00 +02:00
Extensive runtime refactor to reduce generated executable sizes
This commit is contained in:
parent
4e750a7e1a
commit
ddd9b1b218
74 changed files with 2514 additions and 717 deletions
|
@ -763,7 +763,10 @@ namespace IDE
|
|||
}
|
||||
|
||||
public static void GetRtLibNames(Workspace.PlatformType platformType, Workspace.Options workspaceOptions, Project.Options options, bool dynName, String outRt, String outDbg, String outAlloc)
|
||||
{
|
||||
{
|
||||
if (workspaceOptions.mRuntimeKind == .Disabled)
|
||||
return;
|
||||
|
||||
if ((platformType == .Linux) || (platformType == .macOS) || (platformType == .iOS))
|
||||
{
|
||||
if (options.mBuildOptions.mBeefLibType == .DynamicDebug)
|
||||
|
@ -1059,10 +1062,13 @@ namespace IDE
|
|||
return false;
|
||||
}*/
|
||||
|
||||
switch (options.mBuildOptions.mCLibType)
|
||||
var clibType = options.mBuildOptions.mCLibType;
|
||||
if (workspaceOptions.mRuntimeKind == .Disabled)
|
||||
clibType = .None;
|
||||
switch (clibType)
|
||||
{
|
||||
case .None:
|
||||
linkLine.Append("-nodefaultlib ");
|
||||
linkLine.Append("-nodefaultlib chkstk.obj ");
|
||||
case .Dynamic:
|
||||
//linkLine.Append((workspaceOptions.mMachineType == .x86) ? "-defaultlib:msvcprt " : "-defaultlib:msvcrt ");
|
||||
linkLine.Append("-defaultlib:msvcrt ");
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace IDE
|
|||
{
|
||||
class BuildOptions
|
||||
{
|
||||
[Reflect(.All)]
|
||||
public enum LTOType
|
||||
{
|
||||
case None;
|
||||
|
@ -18,6 +19,7 @@ namespace IDE
|
|||
}
|
||||
}
|
||||
|
||||
[Reflect(.All)]
|
||||
public enum EmitDebugInfo
|
||||
{
|
||||
No,
|
||||
|
@ -25,6 +27,7 @@ namespace IDE
|
|||
LinesOnly,
|
||||
}
|
||||
|
||||
[Reflect(.All)]
|
||||
public enum SIMDSetting
|
||||
{
|
||||
None,
|
||||
|
@ -38,6 +41,7 @@ namespace IDE
|
|||
AVX2,
|
||||
}
|
||||
|
||||
[Reflect]
|
||||
public enum BfOptimizationLevel
|
||||
{
|
||||
case O0;
|
||||
|
@ -53,6 +57,7 @@ namespace IDE
|
|||
}
|
||||
}
|
||||
|
||||
[Reflect]
|
||||
public enum RelocType
|
||||
{
|
||||
NotSet,
|
||||
|
@ -64,6 +69,7 @@ namespace IDE
|
|||
ROPI_RWPI
|
||||
}
|
||||
|
||||
[Reflect]
|
||||
public enum PICLevel
|
||||
{
|
||||
NotSet,
|
||||
|
@ -72,6 +78,7 @@ namespace IDE
|
|||
Big
|
||||
}
|
||||
|
||||
[Reflect]
|
||||
public enum AlwaysIncludeKind
|
||||
{
|
||||
NotSet,
|
||||
|
|
|
@ -739,9 +739,14 @@ namespace IDE.Compiler
|
|||
SetOpt(options.mAllowHotSwapping, .EnableHotSwapping);
|
||||
#endif
|
||||
|
||||
var allocType = options.mAllocType;
|
||||
|
||||
if ((options.mRuntimeKind == .Disabled) && (allocType == .Debug))
|
||||
allocType = .CRT;
|
||||
|
||||
String mallocLinkName;
|
||||
String freeLinkName;
|
||||
switch (options.mAllocType)
|
||||
switch (allocType)
|
||||
{
|
||||
case .CRT:
|
||||
mallocLinkName = "malloc";
|
||||
|
|
|
@ -366,6 +366,9 @@ namespace IDE.Debugger
|
|||
[CallingConvention(.Stdcall),CLink]
|
||||
static extern char8* Debugger_GetModulesInfo();
|
||||
|
||||
[CallingConvention(.Stdcall),CLink]
|
||||
static extern char8* Debugger_GetModuleInfo(char8* moduleName);
|
||||
|
||||
[CallingConvention(.Stdcall),CLink]
|
||||
static extern bool Debugger_HasPendingDebugLoads();
|
||||
|
||||
|
@ -1194,6 +1197,11 @@ namespace IDE.Debugger
|
|||
modulesInfo.Append(Debugger_GetModulesInfo());
|
||||
}
|
||||
|
||||
public void GetModuleInfo(StringView moduleName, String moduleInfo)
|
||||
{
|
||||
moduleInfo.Append(Debugger_GetModuleInfo(moduleName.ToScopeCStr!()));
|
||||
}
|
||||
|
||||
public int32 LoadDebugInfoForModule(String moduleName)
|
||||
{
|
||||
return Debugger_LoadDebugInfoForModule(moduleName);
|
||||
|
|
|
@ -8488,6 +8488,13 @@ namespace IDE
|
|||
macroList.Add("BF_LARGE_COLLECTIONS");
|
||||
}
|
||||
|
||||
if (workspaceOptions.mRuntimeKind == .Disabled)
|
||||
macroList.Add("BF_RUNTIME_DISABLE");
|
||||
if ((workspaceOptions.mRuntimeKind == .Reduced) || (workspaceOptions.mRuntimeKind == .Disabled))
|
||||
macroList.Add("BF_RUNTIME_REDUCED");
|
||||
if (workspaceOptions.mReflectKind == .Minimal)
|
||||
macroList.Add("BF_REFLECT_MINIMAL");
|
||||
|
||||
// Only supported on Windows at the moment
|
||||
bool hasLeakCheck = false;
|
||||
if (workspaceOptions.LeakCheckingEnabled)
|
||||
|
|
|
@ -94,6 +94,12 @@ namespace IDE
|
|||
BitcodeAndIRCode,
|
||||
}
|
||||
|
||||
public enum ReflectKind
|
||||
{
|
||||
Normal,
|
||||
Minimal
|
||||
}
|
||||
|
||||
public enum PlatformType
|
||||
{
|
||||
case Unknown;
|
||||
|
@ -263,6 +269,13 @@ namespace IDE
|
|||
Custom
|
||||
}
|
||||
|
||||
public enum RuntimeKind
|
||||
{
|
||||
Default,
|
||||
Reduced,
|
||||
Disabled
|
||||
}
|
||||
|
||||
public class BeefGlobalOptions
|
||||
{
|
||||
[Reflect]
|
||||
|
@ -305,6 +318,10 @@ namespace IDE
|
|||
[Reflect]
|
||||
public bool mLargeCollections;
|
||||
[Reflect]
|
||||
public RuntimeKind mRuntimeKind;
|
||||
[Reflect]
|
||||
public ReflectKind mReflectKind;
|
||||
[Reflect]
|
||||
public AllocType mAllocType = .CRT;
|
||||
[Reflect]
|
||||
public String mAllocMalloc = new String() ~ delete _;
|
||||
|
@ -352,7 +369,7 @@ namespace IDE
|
|||
get
|
||||
{
|
||||
#if BF_PLATFORM_WINDOWS
|
||||
return mEnableRealtimeLeakCheck && mEnableObjectDebugFlags && (mAllocType == .Debug);
|
||||
return mEnableRealtimeLeakCheck && mEnableObjectDebugFlags && (mAllocType == .Debug) && (mRuntimeKind != .Disabled);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
@ -376,6 +393,8 @@ namespace IDE
|
|||
mNoOmitFramePointers = prev.mNoOmitFramePointers;
|
||||
mLargeStrings = prev.mLargeStrings;
|
||||
mLargeCollections = prev.mLargeCollections;
|
||||
mRuntimeKind = prev.mRuntimeKind;
|
||||
mReflectKind = prev.mReflectKind;
|
||||
mAllocType = prev.mAllocType;
|
||||
mAllocMalloc.Set(prev.mAllocMalloc);
|
||||
mAllocFree.Set(prev.mAllocFree);
|
||||
|
@ -813,6 +832,8 @@ namespace IDE
|
|||
data.ConditionalAdd("NoOmitFramePointers", options.mNoOmitFramePointers, false);
|
||||
data.ConditionalAdd("LargeStrings", options.mLargeStrings, false);
|
||||
data.ConditionalAdd("LargeCollections", options.mLargeCollections, false);
|
||||
data.ConditionalAdd("RuntimeKind", options.mRuntimeKind);
|
||||
data.ConditionalAdd("ReflectKind", options.mReflectKind);
|
||||
data.ConditionalAdd("InitLocalVariables", options.mInitLocalVariables, false);
|
||||
data.ConditionalAdd("RuntimeChecks", options.mRuntimeChecks, !isRelease);
|
||||
data.ConditionalAdd("EmitDynamicCastCheck", options.mEmitDynamicCastCheck, !isRelease);
|
||||
|
@ -1004,6 +1025,8 @@ namespace IDE
|
|||
options.mNoOmitFramePointers = false;
|
||||
options.mLargeStrings = false;
|
||||
options.mLargeCollections = false;
|
||||
options.mRuntimeKind = .Default;
|
||||
options.mReflectKind = .Normal;
|
||||
options.mInitLocalVariables = false;
|
||||
options.mRuntimeChecks = !isRelease;
|
||||
options.mEmitDynamicCastCheck = !isRelease;
|
||||
|
@ -1113,6 +1136,8 @@ namespace IDE
|
|||
options.mNoOmitFramePointers = data.GetBool("NoOmitFramePointers", false);
|
||||
options.mLargeStrings = data.GetBool("LargeStrings", false);
|
||||
options.mLargeCollections = data.GetBool("LargeCollections", false);
|
||||
options.mRuntimeKind = data.GetEnum<RuntimeKind>("RuntimeKind");
|
||||
options.mReflectKind = data.GetEnum<ReflectKind>("ReflectKind");
|
||||
options.mInitLocalVariables = data.GetBool("InitLocalVariables", false);
|
||||
options.mRuntimeChecks = data.GetBool("RuntimeChecks", !isRelease);
|
||||
options.mEmitDynamicCastCheck = data.GetBool("EmitDynamicCastCheck", !isRelease);
|
||||
|
|
|
@ -158,6 +158,20 @@ namespace IDE.ui
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
anItem = menu.AddItem("Copy Info to Clipboard");
|
||||
anItem.mOnMenuItemSelected.Add(new (item) =>
|
||||
{
|
||||
String moduleInfo = scope .();
|
||||
listView.GetRoot().WithSelectedItems(scope (item) =>
|
||||
{
|
||||
if (!moduleInfo.IsEmpty)
|
||||
moduleInfo.Append("\n");
|
||||
gApp.mDebugger.GetModuleInfo(item.GetSubItem(1).Label, moduleInfo);
|
||||
});
|
||||
gApp.SetClipboardText(moduleInfo);
|
||||
});
|
||||
|
||||
MenuWidget menuWidget = ThemeFactory.mDefault.CreateMenuWidget(menu);
|
||||
menuWidget.Init(relWidget, x, y);
|
||||
}
|
||||
|
|
|
@ -797,6 +797,8 @@ namespace IDE.ui
|
|||
AddPropertiesItem(category, "No Omit Frame Pointers", "mNoOmitFramePointers");
|
||||
AddPropertiesItem(category, "Large Strings", "mLargeStrings");
|
||||
AddPropertiesItem(category, "Large Collections", "mLargeCollections");
|
||||
AddPropertiesItem(category, "Runtime", "mRuntimeKind");
|
||||
AddPropertiesItem(category, "Reflection", "mReflectKind");
|
||||
category.Open(true, true);
|
||||
|
||||
(category, propEntry) = AddPropertiesItem(root, "Debug");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue