1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 20:42:21 +02:00

Added JEMalloc/TCMalloc options

This commit is contained in:
Brian Fiete 2022-06-02 17:57:09 -07:00
parent 652142e189
commit 8c16454006
7 changed files with 89 additions and 28 deletions

View file

@ -708,7 +708,7 @@ namespace IDE
outPdbPath.Append(".pdb");
}
public static void GetRtLibNames(Workspace.PlatformType platformType, Workspace.Options workspaceOptions, Project.Options options, bool dynName, String outRt, String outDbg)
public static void GetRtLibNames(Workspace.PlatformType platformType, Workspace.Options workspaceOptions, Project.Options options, bool dynName, String outRt, String outDbg, String outAlloc)
{
if ((platformType == .Linux) || (platformType == .macOS) || (platformType == .iOS))
{
@ -748,6 +748,16 @@ namespace IDE
outDbg.Append("_d");
outDbg.Append(dynName ? ".dll" : ".lib");
}
if ((workspaceOptions.mAllocType == .TCMalloc) || (workspaceOptions.mAllocType == .TCMalloc_Debug) ||
(workspaceOptions.mAllocType == .JEMalloc) || (workspaceOptions.mAllocType == .JEMalloc_Debug))
{
outAlloc.Append(((workspaceOptions.mAllocType == .TCMalloc) || (workspaceOptions.mAllocType == .TCMalloc_Debug)) ? "TCMalloc" : "JEMalloc");
outAlloc.Append((Workspace.PlatformType.GetPtrSizeByName(gApp.mPlatformName) == 4) ? "32" : "64");
if ((workspaceOptions.mAllocType == .TCMalloc_Debug) || (workspaceOptions.mAllocType == .JEMalloc_Debug))
outAlloc.Append("_d");
outAlloc.Append(dynName ? ".dll" : ".lib");
}
}
bool CopyLibFiles(String targetPath, Workspace.Options workspaceOptions, Project.Options options)
@ -775,21 +785,17 @@ namespace IDE
String rtName = scope String();
String dbgName = scope String();
GetRtLibNames(mPlatformType, workspaceOptions, options, true, rtName, dbgName);
String allocName = scope String();
GetRtLibNames(mPlatformType, workspaceOptions, options, true, rtName, dbgName, allocName);
if (!rtName.IsEmpty)
if (!AddLib(rtName))
return false;
if (!dbgName.IsEmpty)
if (!AddLib(dbgName))
return false;
switch (workspaceOptions.mAllocType)
{
case .JEMalloc:
if (!AddLib("jemalloc.dll"))
if (!allocName.IsEmpty)
if (!AddLib(allocName))
return false;
default:
}
return true;
}

View file

@ -751,12 +751,12 @@ namespace IDE.Compiler
case .CRT:
mallocLinkName = "malloc";
freeLinkName = "free";
case .JEMalloc:
case .JEMalloc, .JEMalloc_Debug:
mallocLinkName = "je_malloc";
freeLinkName = "je_free";
case .TCMalloc:
mallocLinkName = "tcmalloc";
freeLinkName = "tcfree";
case .TCMalloc, .TCMalloc_Debug:
mallocLinkName = "tc_malloc";
freeLinkName = "tc_free";
case .Custom:
mallocLinkName = options.mAllocMalloc;
freeLinkName = options.mAllocFree;

View file

@ -9979,7 +9979,8 @@ namespace IDE
let platformType = Workspace.PlatformType.GetFromName(platformName, workspaceOptions.mTargetTriple);
String rtName = scope String();
String dbgName = scope String();
BuildContext.GetRtLibNames(platformType, workspaceOptions, options, false, rtName, dbgName);
String allocName = scope String();
BuildContext.GetRtLibNames(platformType, workspaceOptions, options, false, rtName, dbgName, allocName);
switch (platformType)
{
@ -9987,14 +9988,8 @@ namespace IDE
newString.Append(rtName);
if (!dbgName.IsEmpty)
newString.Append(" ", dbgName);
switch (workspaceOptions.mAllocType)
{
case .JEMalloc:
newString.Append(" jemalloc.lib");
case .TCMalloc:
newString.Append(" tcmalloc.lib");
default:
}
if (!allocName.IsEmpty)
newString.Append(" ", allocName);
case .macOS:
newString.AppendF("./{} -Wl,-rpath -Wl,@executable_path", rtName);
case .iOS:

View file

@ -218,7 +218,9 @@ namespace IDE
Stomp,
CRT,
JEMalloc,
JEMalloc_Debug,
TCMalloc,
TCMalloc_Debug,
Custom
}

View file

@ -734,7 +734,7 @@ namespace IDE.ui
AddPropertiesItem(category, "Incremental Build", "mIncrementalBuild");
AddPropertiesItem(category, "Intermediate Type", "mIntermediateType");
var (allocCategory, allocPropEntry) = AddPropertiesItem(category, "Memory Allocator", "mAllocType",
scope String[] ("Debug", "Stomp (Debug)", "CRT", "JEMalloc", "TCMalloc"));
scope String[] ("Debug", "Stomp (Debug)", "CRT", "JEMalloc", "JEMalloc Debug", "TCMalloc", "TCMalloc Debug"));
var (mallocItem, mallocPropEntry) = AddPropertiesItem(allocCategory, "Malloc", "mAllocMalloc");
var (freeItem, freePropEntry) = AddPropertiesItem(allocCategory, "Free", "mAllocFree");
allocPropEntry.mOnUpdate.Add(new () =>
@ -769,15 +769,15 @@ namespace IDE.ui
mallocSubItem.Label = "malloc";
freeSubItem.Label = "free";
}
else if (allocType == .JEMalloc)
else if ((allocType == .JEMalloc) || (allocType == .JEMalloc_Debug))
{
mallocSubItem.Label = "je_malloc";
freeSubItem.Label = "je_free";
}
else if (allocType == .TCMalloc)
else if ((allocType == .TCMalloc) || (allocType == .TCMalloc_Debug))
{
mallocSubItem.Label = "tcmalloc";
freeSubItem.Label = "tcfree";
mallocSubItem.Label = "tc_malloc";
freeSubItem.Label = "tc_free";
}
mallocSubItem.mTextColor = Color.Mult(DarkTheme.COLOR_TEXT, 0xFFC0C0C0);