MCPcopy Create free account
hub / github.com/beefytech/Beef / PrepareCompiler

Method PrepareCompiler

BeefFuzz/FuzzApp.cpp:200–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198}
199
200void FuzzApp::PrepareCompiler()
201{
202 mSystem = BfSystem_Create();
203
204 mCompiler = BfSystem_CreateCompiler(mSystem, false);
205
206 String projectName = GetFileName(mTargetPath);
207 int dotPos = (int)projectName.IndexOf('.');
208 if (dotPos != -1)
209 projectName.RemoveToEnd(dotPos);
210 if (projectName.IsEmpty())
211 projectName.Append("BeefProject");
212
213 mProject = BfSystem_CreateProject(mSystem, projectName.c_str(), GetFileDir(mTargetPath).c_str());
214
215 if (mIsCERun)
216 {
217 mCELibProject = BfSystem_CreateProject(mSystem, "BeefLib", GetFileDir(mTargetPath).c_str());
218 BfProject_SetOptions(mCELibProject, BfTargetType_BeefLib, "", mDefines.c_str(), mOptLevel, 0, 0, 0, BfProjectFlags_None);
219 }
220
221 String defines = mDefines;
222 if (!defines.IsEmpty())
223 defines.Append("\n");
224 defines.Append("BF_64_BIT");
225 defines.Append("\nBF_LITTLE_ENDIAN");
226 defines.Append("\n");
227 defines.Append(BF_PLATFORM_NAME);
228
229 int ltoType = 0;
230 BfProject_SetOptions(mProject, mTargetType, mStartupObject.c_str(), defines.c_str(), BfOptLevel_O0, ltoType, 0, 0, BfProjectFlags_None);
231
232 if (mCELibProject != NULL)
233 BfProject_AddDependency(mProject, mCELibProject);
234
235 mPassInstance = BfSystem_CreatePassInstance(mSystem);
236
237 Beefy::String exePath;
238 BfpGetStrHelper(exePath, [](char* outStr, int* inOutStrSize, BfpResult* result)
239 {
240 BfpSystem_GetExecutablePath(outStr, inOutStrSize, (BfpSystemResult*)result);
241 });
242 mBuildDir = GetFileDir(exePath) + "/build";
243
244 RecursiveCreateDirectory(mBuildDir + "/" + projectName);
245 if (mIsCERun)
246 RecursiveCreateDirectory(mBuildDir + "/BeefLib");
247
248 BfCompilerOptionFlags optionFlags = (BfCompilerOptionFlags)(BfCompilerOptionFlag_EmitDebugInfo | BfCompilerOptionFlag_EmitLineInfo | BfCompilerOptionFlag_GenerateOBJ | BfCompilerOptionFlag_OmitDebugHelpers);
249
250 //int maxWorkerThreads = BfpSystem_GetNumLogicalCPUs(NULL);
251 //if (maxWorkerThreads <= 1)
252 // maxWorkerThreads = 6;
253
254 BfCompiler_SetOptions(mCompiler, NULL, 0, mTargetTriple.c_str(), "", mToolset, BfSIMDSetting_SSE2, 1, 1, optionFlags, "malloc", "free");
255}
256
257

Callers 1

LLVMFuzzerTestOneInputFunction · 0.80

Calls 12

BfSystem_CreateCompilerFunction · 0.85
BfProject_SetOptionsFunction · 0.85
BfProject_AddDependencyFunction · 0.85
BfpGetStrHelperFunction · 0.85
BfCompiler_SetOptionsFunction · 0.85
AppendMethod · 0.80
IndexOfMethod · 0.45
RemoveToEndMethod · 0.45
IsEmptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected