Procházet zdrojové kódy

More CompilerExplorer changes, like OmitDebugHelpers option

Brian Fiete před 5 roky
rodič
revize
75f11b1459

+ 23 - 44
BeefBoot/BootApp.cpp

@@ -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_EXPORT void BF_CALLTYPE BfCompiler_SetOptions(void* bfCompiler, void* hotProject, int hotIdx,
 	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 bool BF_CALLTYPE BfCompiler_Compile(void* bfCompiler, void* bfPassInstance, const char* outputPath);
 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;
 }
 
+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
 void BootApp::DoLinkMS()
 {
@@ -720,14 +715,8 @@ void BootApp::DoLinkMS()
 
 	linkLine.Append(mLinkParams);	
 
-	BfpSpawnFlags flags = BfpSpawnFlag_None;
-	if (true)
-	{		
-		if (true)
-			flags = (BfpSpawnFlags)(BfpSpawnFlag_UseArgsFile | BfpSpawnFlag_UseArgsFile_Native | BfpSpawnFlag_UseArgsFile_BOM);
-		else
-			flags = (BfpSpawnFlags)(BfpSpawnFlag_UseArgsFile);
-	}
+	BfpSpawnFlags flags = BfpSpawnFlag_None;			
+	flags = (BfpSpawnFlags)(BfpSpawnFlag_UseArgsFile | BfpSpawnFlag_UseArgsFile_Native | BfpSpawnFlag_UseArgsFile_BOM);			
 
 	auto runCmd = QueueRun(linkerPath, linkLine, mWorkingDir, flags);
 }
@@ -768,7 +757,7 @@ void BootApp::DoLinkGNU()
     linkLine.Append("-debug -no-pie ");
     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()
@@ -831,7 +820,7 @@ bool BootApp::Compile()
 	if (mIsCERun)
 		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)
 		optionFlags = (BfCompilerOptionFlags)(optionFlags | BfCompilerOptionFlag_WriteIR);
 
@@ -864,13 +853,8 @@ bool BootApp::Compile()
 				srcResult += BF_OBJ_EXT;
 			else			
 				srcResult += ".s";			
-
-			BfpFileResult result = BfpFileResult_Ok;
-			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()));
-			}
+			
+			CopyFile(srcResult, mCEDest);			
 		}
 
 		if ((mIsCERun) && (mEmitIR))
@@ -892,13 +876,8 @@ bool BootApp::Compile()
 				srcResult += ".ll";			
 				irDestPath += ".ll";
 			}
-
-			BfpFileResult result = BfpFileResult_Ok;
-			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()));
-			}			
+			
+			CopyFile(srcResult, irDestPath);			
 		}
 	}
 

+ 1 - 0
BeefBoot/BootApp.h

@@ -64,6 +64,7 @@ public:
 	void Fail(const String & error);
 	void OutputLine(const String& text, OutputPri outputPri = OutputPri_Normal);
 	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 QueuePath(const StringImpl& path);

+ 50 - 1
BeefySysLib/platform/linux/LinuxCommon.cpp

@@ -688,7 +688,7 @@ BFP_EXPORT BfpSpawn* BFP_CALLTYPE BfpSpawn_Create(const char* inTargetPath, cons
 {
     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))
 	{
@@ -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;
     bool inQuote = false;
 

+ 1 - 20
IDEHelper/Compiler/BfCompiler.cpp

@@ -8122,26 +8122,6 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_HotResolve_Finish(BfCompiler* bfCom
 	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,
 	int machineType, int toolsetType, int simdSetting, int allocStackCount, int maxWorkerThreads,
 	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->mEnableRealtimeLeakCheck = ((optionFlags & BfCompilerOptionFlag_EnableRealtimeLeakCheck) != 0) && options->mObjectHasDebugFlags;
 		options->mDebugAlloc = ((optionFlags & BfCompilerOptionFlag_DebugAlloc) != 0) || options->mEnableRealtimeLeakCheck;
+		options->mOmitDebugHelpers = (optionFlags & BfCompilerOptionFlag_OmitDebugHelpers) != 0;
 
 #ifdef _WINDOWS
 		if (options->mToolsetType == BfToolsetType_GNU)

+ 3 - 1
IDEHelper/Compiler/BfCompiler.h

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

+ 1 - 12
IDEHelper/Compiler/BfModule.cpp

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

+ 0 - 1
IDEHelper/Compiler/BfModule.h

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

+ 21 - 0
IDEHelper/Compiler/BfSystem.h

@@ -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
 {
 	BfTypeFlags_UnspecializedGeneric = 0x0001,