1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

More CompilerExplorer changes, like OmitDebugHelpers option

This commit is contained in:
Brian Fiete 2019-10-14 13:01:15 -07:00
parent c9e0ab6089
commit 75f11b1459
8 changed files with 100 additions and 79 deletions

View file

@ -24,29 +24,10 @@ BF_IMPORT void BF_CALLTYPE Debugger_FullReportMemory();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
enum BfCompilerOptionFlags
{
BfCompilerOptionFlag_None = 0,
BfCompilerOptionFlag_EmitDebugInfo = 1,
BfCompilerOptionFlag_EmitLineInfo = 2,
BfCompilerOptionFlag_WriteIR = 4,
BfCompilerOptionFlag_GenerateOBJ = 8,
BfCompilerOptionFlag_NoFramePointerElim = 0x10,
BfCompilerOptionFlag_ClearLocalVars = 0x20,
BfCompilerOptionFlag_ArrayBoundsCheck = 0x40,
BfCompilerOptionFlag_EmitDynamicCastCheck = 0x80,
BfCompilerOptionFlag_EnableObjectDebugFlags = 0x100,
BfCompilerOptionFlag_EmitObjectAccessCheck = 0x200,
BfCompilerOptionFlag_EnableCustodian = 0x400,
BfCompilerOptionFlag_EnableRealtimeLeakCheck = 0x800,
BfCompilerOptionFlag_EnableSideStack = 0x1000,
BfCompilerOptionFlag_EnableHotSwapping = 0x2000
};
BF_IMPORT void BF_CALLTYPE BfCompiler_Delete(void* bfCompiler); BF_IMPORT void BF_CALLTYPE BfCompiler_Delete(void* bfCompiler);
BF_EXPORT void BF_CALLTYPE BfCompiler_SetOptions(void* bfCompiler, void* hotProject, int hotIdx, BF_EXPORT void BF_CALLTYPE BfCompiler_SetOptions(void* bfCompiler, void* hotProject, int hotIdx,
int machineType, int toolsetType, int simdSetting, int allocStackCount, int maxWorkerThreads, int machineType, int toolsetType, int simdSetting, int allocStackCount, int maxWorkerThreads,
BfCompilerOptionFlags optionFlags, const char* mallocLinkName, const char* freeLinkName); Beefy::BfCompilerOptionFlags optionFlags, const char* mallocLinkName, const char* freeLinkName);
BF_IMPORT void BF_CALLTYPE BfCompiler_ClearBuildCache(void* bfCompiler); BF_IMPORT void BF_CALLTYPE BfCompiler_ClearBuildCache(void* bfCompiler);
BF_IMPORT bool BF_CALLTYPE BfCompiler_Compile(void* bfCompiler, void* bfPassInstance, const char* outputPath); BF_IMPORT bool BF_CALLTYPE BfCompiler_Compile(void* bfCompiler, void* bfPassInstance, const char* outputPath);
BF_IMPORT float BF_CALLTYPE BfCompiler_GetCompletionPercentage(void* bfCompiler); BF_IMPORT float BF_CALLTYPE BfCompiler_GetCompletionPercentage(void* bfCompiler);
@ -639,6 +620,20 @@ bool BootApp::QueueRun(const String& fileName, const String& args, const String&
return true; return true;
} }
bool BootApp::CopyFile(const StringImpl& srcPath, const StringImpl& destPath)
{
BfpFileResult result = BfpFileResult_Ok;
for (int i = 0; i < 20; i++)
{
BfpFile_Copy(srcPath.c_str(), destPath.c_str(), BfpFileCopyKind_Always, &result);
if (result == BfpFileResult_Ok)
return true;
BfpThread_Sleep(100);
}
Fail(StrFormat("Failed to copy '%s' to '%s'", srcPath.c_str(), destPath.c_str()));
return false;
}
#ifdef BF_PLATFORM_WINDOWS #ifdef BF_PLATFORM_WINDOWS
void BootApp::DoLinkMS() void BootApp::DoLinkMS()
{ {
@ -720,14 +715,8 @@ void BootApp::DoLinkMS()
linkLine.Append(mLinkParams); linkLine.Append(mLinkParams);
BfpSpawnFlags flags = BfpSpawnFlag_None; BfpSpawnFlags flags = BfpSpawnFlag_None;
if (true) flags = (BfpSpawnFlags)(BfpSpawnFlag_UseArgsFile | BfpSpawnFlag_UseArgsFile_Native | BfpSpawnFlag_UseArgsFile_BOM);
{
if (true)
flags = (BfpSpawnFlags)(BfpSpawnFlag_UseArgsFile | BfpSpawnFlag_UseArgsFile_Native | BfpSpawnFlag_UseArgsFile_BOM);
else
flags = (BfpSpawnFlags)(BfpSpawnFlag_UseArgsFile);
}
auto runCmd = QueueRun(linkerPath, linkLine, mWorkingDir, flags); auto runCmd = QueueRun(linkerPath, linkLine, mWorkingDir, flags);
} }
@ -768,7 +757,7 @@ void BootApp::DoLinkGNU()
linkLine.Append("-debug -no-pie "); linkLine.Append("-debug -no-pie ");
linkLine.Append(mLinkParams); linkLine.Append(mLinkParams);
auto runCmd = QueueRun(linkerPath, linkLine, mWorkingDir, true ? BfpSpawnFlag_UseArgsFile : BfpSpawnFlag_None); auto runCmd = QueueRun(linkerPath, linkLine, mWorkingDir, BfpSpawnFlag_UseArgsFile);
} }
bool BootApp::Compile() bool BootApp::Compile()
@ -831,7 +820,7 @@ bool BootApp::Compile()
if (mIsCERun) if (mIsCERun)
RecursiveCreateDirectory(mBuildDir + "/BeefLib"); RecursiveCreateDirectory(mBuildDir + "/BeefLib");
BfCompilerOptionFlags optionFlags = (BfCompilerOptionFlags)(BfCompilerOptionFlag_EmitDebugInfo | BfCompilerOptionFlag_EmitLineInfo | BfCompilerOptionFlag_GenerateOBJ); BfCompilerOptionFlags optionFlags = (BfCompilerOptionFlags)(BfCompilerOptionFlag_EmitDebugInfo | BfCompilerOptionFlag_EmitLineInfo | BfCompilerOptionFlag_GenerateOBJ | BfCompilerOptionFlag_OmitDebugHelpers);
if (mEmitIR) if (mEmitIR)
optionFlags = (BfCompilerOptionFlags)(optionFlags | BfCompilerOptionFlag_WriteIR); optionFlags = (BfCompilerOptionFlags)(optionFlags | BfCompilerOptionFlag_WriteIR);
@ -864,13 +853,8 @@ bool BootApp::Compile()
srcResult += BF_OBJ_EXT; srcResult += BF_OBJ_EXT;
else else
srcResult += ".s"; srcResult += ".s";
BfpFileResult result = BfpFileResult_Ok; CopyFile(srcResult, mCEDest);
BfpFile_Copy(srcResult.c_str(), mCEDest.c_str(), BfpFileCopyKind_Always, &result);
if (result != BfpFileResult_Ok)
{
Fail(StrFormat("Failed to copy '%s' to '%s'", srcResult.c_str(), mCEDest.c_str()));
}
} }
if ((mIsCERun) && (mEmitIR)) if ((mIsCERun) && (mEmitIR))
@ -892,13 +876,8 @@ bool BootApp::Compile()
srcResult += ".ll"; srcResult += ".ll";
irDestPath += ".ll"; irDestPath += ".ll";
} }
BfpFileResult result = BfpFileResult_Ok; CopyFile(srcResult, irDestPath);
BfpFile_Copy(srcResult.c_str(), irDestPath.c_str(), BfpFileCopyKind_Always, &result);
if (result != BfpFileResult_Ok)
{
Fail(StrFormat("Failed to copy '%s' to '%s'", srcResult.c_str(), mCEDest.c_str()));
}
} }
} }

View file

@ -64,6 +64,7 @@ public:
void Fail(const String & error); void Fail(const String & error);
void OutputLine(const String& text, OutputPri outputPri = OutputPri_Normal); void OutputLine(const String& text, OutputPri outputPri = OutputPri_Normal);
bool QueueRun(const String& fileName, const String& args, const String& workingDir, BfpSpawnFlags extraFlags); bool QueueRun(const String& fileName, const String& args, const String& workingDir, BfpSpawnFlags extraFlags);
bool CopyFile(const StringImpl& srcPath, const StringImpl& destPath);
void QueueFile(const StringImpl& path, void* project); void QueueFile(const StringImpl& path, void* project);
void QueuePath(const StringImpl& path); void QueuePath(const StringImpl& path);

View file

@ -688,7 +688,7 @@ BFP_EXPORT BfpSpawn* BFP_CALLTYPE BfpSpawn_Create(const char* inTargetPath, cons
{ {
Beefy::Array<Beefy::StringView> stringViews; Beefy::Array<Beefy::StringView> stringViews;
//printf("Executing: %s %s\n", inTargetPath, args); //printf("Executing: %s %s %x\n", inTargetPath, args, flags);
if ((workingDir != NULL) && (workingDir[0] != 0)) if ((workingDir != NULL) && (workingDir[0] != 0))
{ {
@ -700,6 +700,55 @@ BFP_EXPORT BfpSpawn* BFP_CALLTYPE BfpSpawn_Create(const char* inTargetPath, cons
} }
} }
String newArgs;
String tempFileName;
if ((flags & BfpSpawnFlag_UseArgsFile) != 0)
{
char tempFileNameStr[256];
int size = 256;
BfpFileResult fileResult;
BfpFile_GetTempFileName(tempFileNameStr, &size, &fileResult);
if (fileResult == BfpFileResult_Ok)
{
tempFileName = tempFileNameStr;
BfpFileResult fileResult;
BfpFile* file = BfpFile_Create(tempFileNameStr, BfpFileCreateKind_CreateAlways, BfpFileCreateFlag_Write, BfpFileAttribute_Normal, &fileResult);
if (file == NULL)
{
OUTRESULT(BfpSpawnResult_TempFileError);
return NULL;
}
if ((flags & BfpSpawnFlag_UseArgsFile_Native) != 0)
{
UTF16String wStr = UTF8Decode(args);
if ((flags & BfpSpawnFlag_UseArgsFile_BOM) != 0)
{
uint8 bom[2] = { 0xFF, 0xFE };
BfpFile_Write(file, bom, 2, -1, NULL);
}
BfpFile_Write(file, wStr.c_str(), wStr.length() * 2, -1, NULL);
}
else
BfpFile_Write(file, args, strlen(args), -1, NULL);
BfpFile_Release(file);
newArgs.Append("@");
newArgs.Append(tempFileName);
if (newArgs.Contains(' '))
{
newArgs.Insert(0, '\"');
newArgs.Append('\"');
}
args = newArgs.c_str();
}
}
int32 firstCharIdx = -1; int32 firstCharIdx = -1;
bool inQuote = false; bool inQuote = false;

View file

@ -8122,26 +8122,6 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_HotResolve_Finish(BfCompiler* bfCom
return outString.c_str(); return outString.c_str();
} }
enum BfCompilerOptionFlags
{
BfCompilerOptionFlag_EmitDebugInfo = 1,
BfCompilerOptionFlag_EmitLineInfo = 2,
BfCompilerOptionFlag_WriteIR = 4,
BfCompilerOptionFlag_GenerateOBJ = 8,
BfCompilerOptionFlag_NoFramePointerElim = 0x10,
BfCompilerOptionFlag_ClearLocalVars = 0x20,
BfCompilerOptionFlag_RuntimeChecks = 0x40,
BfCompilerOptionFlag_EmitDynamicCastCheck = 0x80,
BfCompilerOptionFlag_EnableObjectDebugFlags = 0x100,
BfCompilerOptionFlag_EmitObjectAccessCheck = 0x200,
BfCompilerOptionFlag_EnableCustodian = 0x400,
BfCompilerOptionFlag_EnableRealtimeLeakCheck = 0x800,
BfCompilerOptionFlag_EnableSideStack = 0x1000,
BfCompilerOptionFlag_EnableHotSwapping = 0x2000,
BfCompilerOptionFlag_IncrementalBuild = 0x4000,
BfCompilerOptionFlag_DebugAlloc = 0x8000
};
BF_EXPORT void BF_CALLTYPE BfCompiler_SetOptions(BfCompiler* bfCompiler, BfProject* hotProject, int hotIdx, BF_EXPORT void BF_CALLTYPE BfCompiler_SetOptions(BfCompiler* bfCompiler, BfProject* hotProject, int hotIdx,
int machineType, int toolsetType, int simdSetting, int allocStackCount, int maxWorkerThreads, int machineType, int toolsetType, int simdSetting, int allocStackCount, int maxWorkerThreads,
BfCompilerOptionFlags optionFlags, char* mallocLinkName, char* freeLinkName) BfCompilerOptionFlags optionFlags, char* mallocLinkName, char* freeLinkName)
@ -8178,6 +8158,7 @@ BF_EXPORT void BF_CALLTYPE BfCompiler_SetOptions(BfCompiler* bfCompiler, BfProje
options->mObjectHasDebugFlags = (optionFlags & BfCompilerOptionFlag_EnableObjectDebugFlags) != 0; options->mObjectHasDebugFlags = (optionFlags & BfCompilerOptionFlag_EnableObjectDebugFlags) != 0;
options->mEnableRealtimeLeakCheck = ((optionFlags & BfCompilerOptionFlag_EnableRealtimeLeakCheck) != 0) && options->mObjectHasDebugFlags; options->mEnableRealtimeLeakCheck = ((optionFlags & BfCompilerOptionFlag_EnableRealtimeLeakCheck) != 0) && options->mObjectHasDebugFlags;
options->mDebugAlloc = ((optionFlags & BfCompilerOptionFlag_DebugAlloc) != 0) || options->mEnableRealtimeLeakCheck; options->mDebugAlloc = ((optionFlags & BfCompilerOptionFlag_DebugAlloc) != 0) || options->mEnableRealtimeLeakCheck;
options->mOmitDebugHelpers = (optionFlags & BfCompilerOptionFlag_OmitDebugHelpers) != 0;
#ifdef _WINDOWS #ifdef _WINDOWS
if (options->mToolsetType == BfToolsetType_GNU) if (options->mToolsetType == BfToolsetType_GNU)

View file

@ -118,6 +118,7 @@ public:
bool mEnableSideStack; bool mEnableSideStack;
bool mHasVDataExtender; bool mHasVDataExtender;
bool mDebugAlloc; bool mDebugAlloc;
bool mOmitDebugHelpers;
bool mUseDebugBackingParams; bool mUseDebugBackingParams;
@ -143,6 +144,7 @@ public:
mSIMDSetting = BfSIMDSetting_None; mSIMDSetting = BfSIMDSetting_None;
mHotProject = NULL; mHotProject = NULL;
mDebugAlloc = false; mDebugAlloc = false;
mOmitDebugHelpers = false;
mIncrementalBuild = true; mIncrementalBuild = true;
mEmitDebugInfo = false; mEmitDebugInfo = false;
mEmitLineInfo = false; mEmitLineInfo = false;
@ -163,7 +165,7 @@ public:
mUseDebugBackingParams = true; mUseDebugBackingParams = true;
mAllocStackCount = 1; mAllocStackCount = 1;
mExtraResolveChecks = false; mExtraResolveChecks = false;
#ifdef _DEBUG #ifdef _DEBUG
//mExtraResolveChecks = true; //mExtraResolveChecks = true;
#endif #endif

View file

@ -8066,23 +8066,12 @@ void BfModule::EmitObjectAccessCheck(BfTypedValue typedVal)
mBfIRBuilder->CreateObjectAccessCheck(typedVal.mValue, !IsOptimized()); mBfIRBuilder->CreateObjectAccessCheck(typedVal.mValue, !IsOptimized());
} }
void BfModule::EmitNop()
{
if (mProject == NULL)
return;
if ((mBfIRBuilder->mIgnoreWrites) || (!mHasFullDebugInfo) || (IsOptimized()))
return;
mBfIRBuilder->CreateNop();
}
void BfModule::EmitEnsureInstructionAt() void BfModule::EmitEnsureInstructionAt()
{ {
if (mProject == NULL) if (mProject == NULL)
return; return;
if ((mBfIRBuilder->mIgnoreWrites) || (!mHasFullDebugInfo) || (IsOptimized())) if ((mBfIRBuilder->mIgnoreWrites) || (!mHasFullDebugInfo) || (IsOptimized()) || (mCompiler->mOptions.mOmitDebugHelpers))
return; return;
mBfIRBuilder->CreateEnsureInstructionAt(); mBfIRBuilder->CreateEnsureInstructionAt();

View file

@ -1468,7 +1468,6 @@ public:
bool HasCompiledOutput(); bool HasCompiledOutput();
void SkipObjectAccessCheck(BfTypedValue typedVal); void SkipObjectAccessCheck(BfTypedValue typedVal);
void EmitObjectAccessCheck(BfTypedValue typedVal); void EmitObjectAccessCheck(BfTypedValue typedVal);
void EmitNop();
void EmitEnsureInstructionAt(); void EmitEnsureInstructionAt();
void EmitDynamicCastCheck(const BfTypedValue& targetValue, BfType* targetType, BfIRBlock trueBlock, BfIRBlock falseBlock, bool nullSucceeds = false); void EmitDynamicCastCheck(const BfTypedValue& targetValue, BfType* targetType, BfIRBlock trueBlock, BfIRBlock falseBlock, bool nullSucceeds = false);
void EmitDynamicCastCheck(BfTypedValue typedVal, BfType* type, bool allowNull); void EmitDynamicCastCheck(BfTypedValue typedVal, BfType* type, bool allowNull);

View file

@ -137,6 +137,27 @@ struct BfAtomCompositeEquals
} }
}; };
enum BfCompilerOptionFlags
{
BfCompilerOptionFlag_EmitDebugInfo = 1,
BfCompilerOptionFlag_EmitLineInfo = 2,
BfCompilerOptionFlag_WriteIR = 4,
BfCompilerOptionFlag_GenerateOBJ = 8,
BfCompilerOptionFlag_NoFramePointerElim = 0x10,
BfCompilerOptionFlag_ClearLocalVars = 0x20,
BfCompilerOptionFlag_RuntimeChecks = 0x40,
BfCompilerOptionFlag_EmitDynamicCastCheck = 0x80,
BfCompilerOptionFlag_EnableObjectDebugFlags = 0x100,
BfCompilerOptionFlag_EmitObjectAccessCheck = 0x200,
BfCompilerOptionFlag_EnableCustodian = 0x400,
BfCompilerOptionFlag_EnableRealtimeLeakCheck = 0x800,
BfCompilerOptionFlag_EnableSideStack = 0x1000,
BfCompilerOptionFlag_EnableHotSwapping = 0x2000,
BfCompilerOptionFlag_IncrementalBuild = 0x4000,
BfCompilerOptionFlag_DebugAlloc = 0x8000,
BfCompilerOptionFlag_OmitDebugHelpers = 0x10000
};
enum BfTypeFlags enum BfTypeFlags
{ {
BfTypeFlags_UnspecializedGeneric = 0x0001, BfTypeFlags_UnspecializedGeneric = 0x0001,