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

Added target triple support for more useful cross compilation

This commit is contained in:
Brian Fiete 2019-10-14 17:49:10 -07:00
parent 22ec4a86b8
commit 3bf4c792d8
15 changed files with 145 additions and 124 deletions

View file

@ -8123,7 +8123,7 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_HotResolve_Finish(BfCompiler* bfCom
}
BF_EXPORT void BF_CALLTYPE BfCompiler_SetOptions(BfCompiler* bfCompiler, BfProject* hotProject, int hotIdx,
int machineType, int toolsetType, int simdSetting, int allocStackCount, int maxWorkerThreads,
const char* targetTriple, int toolsetType, int simdSetting, int allocStackCount, int maxWorkerThreads,
BfCompilerOptionFlags optionFlags, char* mallocLinkName, char* freeLinkName)
{
BfLogSys(bfCompiler->mSystem, "BfCompiler_SetOptions\n");
@ -8135,7 +8135,15 @@ BF_EXPORT void BF_CALLTYPE BfCompiler_SetOptions(BfCompiler* bfCompiler, BfProje
options->mErrorString.Clear();
options->mHotProject = hotProject;
options->mHotCompileIdx = hotIdx;
options->mMachineType = (BfMachineType)machineType;
options->mTargetTriple = targetTriple;
if (options->mTargetTriple.StartsWith("x86_64-"))
options->mMachineType = BfMachineType_x64;
else if (options->mTargetTriple.StartsWith("i686-"))
options->mMachineType = BfMachineType_x86;
else
options->mMachineType = BfMachineType_x64; // Default
bfCompiler->mCodeGen.SetMaxThreads(maxWorkerThreads);
if (!bfCompiler->mIsResolveOnly)

View file

@ -93,6 +93,7 @@ public:
int32 mForceRebuildIdx;
BfCompileOnDemandKind mCompileOnDemandKind;
String mTargetTriple;
BfMachineType mMachineType;
BfToolsetType mToolsetType;
BfSIMDSetting mSIMDSetting;

View file

@ -241,6 +241,8 @@ bool BfMethodMatcher::InferGenericArgument(BfMethodInstance* methodInstance, BfT
{
if (argType == NULL)
return false;
if (argType->IsVar())
return false;
if (wantType->IsGenericParam())
{
@ -248,7 +250,7 @@ bool BfMethodMatcher::InferGenericArgument(BfMethodInstance* methodInstance, BfT
BfType* methodGenericTypeConstraint = NULL;
auto _SetGeneric = [&]()
{
{
if (mCheckMethodGenericArguments[wantGenericParam->mGenericParamIdx] != argType)
{
if (methodGenericTypeConstraint != NULL)
@ -1347,6 +1349,9 @@ bool BfMethodMatcher::CheckMethod(BfTypeInstance* typeInstance, BfMethodDef* che
genericArg = mModule->GetPrimitiveStructType(primType->mTypeDef->mTypeCode);
}
if (genericArg == NULL)
goto NoMatch;
//SetAndRestoreValue<bool> ignoreError(mModule->mIgnoreErrors, true);
if (!mModule->CheckGenericConstraints(BfGenericParamSource(methodInstance), genericArg, NULL, genericParams[checkGenericIdx], genericArgumentsSubstitute, NULL))
{

View file

@ -954,30 +954,32 @@ void BfModule::FinishInit()
mBfIRBuilder->Start(mModuleName, mCompiler->mSystem->mPtrSize, IsOptimized());
#ifdef BF_PLATFORM_WINDOWS
if (mCompiler->mOptions.mToolsetType == BfToolsetType_GNU)
{
if (mCompiler->mOptions.mMachineType == BfMachineType_x86)
mBfIRBuilder->Module_SetTargetTriple("i686-pc-windows-gnu");
else
mBfIRBuilder->Module_SetTargetTriple("x86_64-pc-windows-gnu");
}
else //if (mCompiler->mOptions.mToolsetType == BfToolsetType_Microsoft)
{
if (mCompiler->mOptions.mMachineType == BfMachineType_x86)
mBfIRBuilder->Module_SetTargetTriple("i686-pc-windows-msvc");
else
mBfIRBuilder->Module_SetTargetTriple("x86_64-pc-windows-msvc");
}
#elif defined BF_PLATFORM_LINUX
if (mCompiler->mOptions.mMachineType == BfMachineType_x86)
mBfIRBuilder->Module_SetTargetTriple("i686-unknown-linux-gnu");
else
mBfIRBuilder->Module_SetTargetTriple("x86_64-unknown-linux-gnu");
#else
// Leave it default
mBfIRBuilder->Module_SetTargetTriple("");
#endif
mBfIRBuilder->Module_SetTargetTriple(mCompiler->mOptions.mTargetTriple);
// #ifdef BF_PLATFORM_WINDOWS
// if (mCompiler->mOptions.mToolsetType == BfToolsetType_GNU)
// {
// if (mCompiler->mOptions.mMachineType == BfMachineType_x86)
// mBfIRBuilder->Module_SetTargetTriple("i686-pc-windows-gnu");
// else
// mBfIRBuilder->Module_SetTargetTriple("x86_64-pc-windows-gnu");
// }
// else //if (mCompiler->mOptions.mToolsetType == BfToolsetType_Microsoft)
// {
// if (mCompiler->mOptions.mMachineType == BfMachineType_x86)
// mBfIRBuilder->Module_SetTargetTriple("i686-pc-windows-msvc");
// else
// mBfIRBuilder->Module_SetTargetTriple("x86_64-pc-windows-msvc");
// }
// #elif defined BF_PLATFORM_LINUX
// if (mCompiler->mOptions.mMachineType == BfMachineType_x86)
// mBfIRBuilder->Module_SetTargetTriple("i686-unknown-linux-gnu");
// else
// mBfIRBuilder->Module_SetTargetTriple("x86_64-unknown-linux-gnu");
// #else
// // Leave it default
// mBfIRBuilder->Module_SetTargetTriple("");
// #endif
mBfIRBuilder->SetBackend(IsTargetingBeefBackend());