mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Improvements to target triple override
This commit is contained in:
parent
db015a4112
commit
d375c805c9
9 changed files with 97 additions and 34 deletions
|
@ -9,7 +9,7 @@ namespace System
|
|||
#if BF_PLATFORM_WINDOWS
|
||||
public static readonly String NewLine = "\r\n";
|
||||
#else
|
||||
public static readonly String NewLine = new String("\n");
|
||||
public static readonly String NewLine = "\n";
|
||||
#endif // BF_PLATFORM_WINDOWS
|
||||
|
||||
public static OperatingSystem OSVersion = new OperatingSystem() ~ delete _;
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.IO;
|
|||
using System.Diagnostics;
|
||||
using Beefy;
|
||||
using IDE.util;
|
||||
using IDE.Util;
|
||||
|
||||
namespace IDE
|
||||
{
|
||||
|
@ -59,7 +60,7 @@ namespace IDE
|
|||
{
|
||||
Workspace.Options workspaceOptions = gApp.GetCurWorkspaceOptions();
|
||||
mToolset = workspaceOptions.mToolsetType;
|
||||
mPlatformType = Workspace.PlatformType.GetFromName(gApp.mPlatformName);
|
||||
mPlatformType = Workspace.PlatformType.GetFromName(gApp.mPlatformName, workspaceOptions.mTargetTriple);
|
||||
mPtrSize = Workspace.PlatformType.GetPtrSizeByName(gApp.mPlatformName);
|
||||
}
|
||||
|
||||
|
@ -1206,15 +1207,19 @@ namespace IDE
|
|||
{
|
||||
if (project.mCurBfOutputFileNames == null)
|
||||
{
|
||||
BfCompiler.UsedOutputFlags usedOutputFlags = .FlushQueuedHotFiles;
|
||||
if (options.mBuildOptions.mBuildKind == .StaticLib)
|
||||
usedOutputFlags = .SkipImports;
|
||||
|
||||
project.mCurBfOutputFileNames = new .();
|
||||
bfCompiler.GetOutputFileNames(bfProject, true, out bfHadOutputChanges, project.mCurBfOutputFileNames);
|
||||
bfCompiler.GetOutputFileNames(bfProject, usedOutputFlags, out bfHadOutputChanges, project.mCurBfOutputFileNames);
|
||||
}
|
||||
for (var fileName in project.mCurBfOutputFileNames)
|
||||
bfFileNames.Add(fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
bfCompiler.GetOutputFileNames(bfProject, true, out bfHadOutputChanges, bfFileNames);
|
||||
bfCompiler.GetOutputFileNames(bfProject, .FlushQueuedHotFiles, out bfHadOutputChanges, bfFileNames);
|
||||
defer:: ClearAndDeleteItems(bfFileNames);
|
||||
}
|
||||
if (bfHadOutputChanges)
|
||||
|
|
|
@ -41,6 +41,13 @@ namespace IDE.Compiler
|
|||
ArithmeticChecks = 0x40000
|
||||
}
|
||||
|
||||
public enum UsedOutputFlags : int32
|
||||
{
|
||||
None = 0,
|
||||
FlushQueuedHotFiles = 1,
|
||||
SkipImports = 2,
|
||||
}
|
||||
|
||||
[CallingConvention(.Stdcall), CLink]
|
||||
static extern bool BfCompiler_Compile(void* bfCompiler, void* bfPassInstance, char8* outputDirectory);
|
||||
|
||||
|
@ -102,7 +109,7 @@ namespace IDE.Compiler
|
|||
static extern void BfCompiler_WriteBuildCache(void* bfCompiler, char8* cacheDir);
|
||||
|
||||
[CallingConvention(.Stdcall), CLink]
|
||||
static extern char8* BfCompiler_GetUsedOutputFileNames(void* bfCompiler, void* bfProject, bool flushQueuedHotFiles, out bool hadOutputChanges);
|
||||
static extern char8* BfCompiler_GetUsedOutputFileNames(void* bfCompiler, void* bfProject, UsedOutputFlags flags, out bool hadOutputChanges);
|
||||
|
||||
[CallingConvention(.Stdcall), CLink]
|
||||
static extern char8* BfCompiler_GetGeneratorTypeDefList(void* bfCompiler);
|
||||
|
@ -287,9 +294,9 @@ namespace IDE.Compiler
|
|||
BfCompiler_UpdateRenameSymbols(mNativeBfCompiler, passInstance.mNativeBfPassInstance, resolvePassData.mNativeResolvePassData);
|
||||
}*/
|
||||
|
||||
public void GetOutputFileNames(BfProject project, bool flushQueuedHotFiles, out bool hadOutputChanges, List<String> outFileNames)
|
||||
public void GetOutputFileNames(BfProject project, UsedOutputFlags flags, out bool hadOutputChanges, List<String> outFileNames)
|
||||
{
|
||||
char8* result = BfCompiler_GetUsedOutputFileNames(mNativeBfCompiler, project.mNativeBfProject, flushQueuedHotFiles, out hadOutputChanges);
|
||||
char8* result = BfCompiler_GetUsedOutputFileNames(mNativeBfCompiler, project.mNativeBfProject, flags, out hadOutputChanges);
|
||||
if (result == null)
|
||||
return;
|
||||
String fileNamesStr = scope String();
|
||||
|
|
|
@ -7827,7 +7827,8 @@ namespace IDE
|
|||
|
||||
public void GetBeefPreprocessorMacros(DefinesSet macroList)
|
||||
{
|
||||
let platform = Workspace.PlatformType.GetFromName(mPlatformName);
|
||||
var workspaceOptions = GetCurWorkspaceOptions();
|
||||
let platform = Workspace.PlatformType.GetFromName(mPlatformName, workspaceOptions.mTargetTriple);
|
||||
if (platform != .Unknown)
|
||||
{
|
||||
String def = scope .();
|
||||
|
@ -7837,7 +7838,6 @@ namespace IDE
|
|||
macroList.Add(def);
|
||||
}
|
||||
|
||||
var workspaceOptions = GetCurWorkspaceOptions();
|
||||
if (workspaceOptions.mRuntimeChecks)
|
||||
macroList.Add("BF_RUNTIME_CHECKS");
|
||||
if (workspaceOptions.mEnableObjectDebugFlags)
|
||||
|
@ -8961,7 +8961,7 @@ namespace IDE
|
|||
|
||||
bfProject.SetDisabled(false);
|
||||
|
||||
let platform = Workspace.PlatformType.GetFromName(mPlatformName);
|
||||
let platform = Workspace.PlatformType.GetFromName(mPlatformName, workspaceOptions.mTargetTriple);
|
||||
|
||||
var preprocessorMacros = scope DefinesSet();
|
||||
void AddMacros(List<String> macros)
|
||||
|
@ -8982,7 +8982,13 @@ namespace IDE
|
|||
if (options.mBeefOptions.mOptimizationLevel != null)
|
||||
optimizationLevel = options.mBeefOptions.mOptimizationLevel.Value;
|
||||
|
||||
if ((optimizationLevel == .OgPlus) && (mPlatformName != "Win64") && (bfCompiler == mBfBuildCompiler))
|
||||
bool isWin64 = true;
|
||||
if (!workspaceOptions.mTargetTriple.IsWhiteSpace)
|
||||
isWin64 = workspaceOptions.mTargetTriple.StartsWith("x86_64-pc-windows");
|
||||
else
|
||||
isWin64 = mPlatformName == "Win64";
|
||||
|
||||
if ((optimizationLevel == .OgPlus) && (!isWin64) && (bfCompiler == mBfBuildCompiler))
|
||||
{
|
||||
OutputLineSmart("WARNING: Project '{0}' has Og+ specified, which is only supported for Win64 targets.", project.mProjectName);
|
||||
optimizationLevel = .O0;
|
||||
|
@ -9575,7 +9581,7 @@ namespace IDE
|
|||
if (!DoResolveConfigString(platformName, workspaceOptions, project, options, options.mBuildOptions.mTargetName, error, newString))
|
||||
return false;
|
||||
|
||||
let platformType = Workspace.PlatformType.GetFromName(platformName);
|
||||
let platformType = Workspace.PlatformType.GetFromName(platformName, workspaceOptions.mTargetTriple);
|
||||
|
||||
switch (platformType)
|
||||
{
|
||||
|
@ -9626,7 +9632,7 @@ namespace IDE
|
|||
(isBeefDynLib) ||
|
||||
(options.mBuildOptions.mBuildKind == .Test))
|
||||
{
|
||||
let platformType = Workspace.PlatformType.GetFromName(platformName);
|
||||
let platformType = Workspace.PlatformType.GetFromName(platformName, workspaceOptions.mTargetTriple);
|
||||
String rtName = scope String();
|
||||
String dbgName = scope String();
|
||||
BuildContext.GetRtLibNames(platformType, workspaceOptions, options, false, rtName, dbgName);
|
||||
|
@ -10066,7 +10072,7 @@ namespace IDE
|
|||
var bfProject = mBfBuildSystem.mProjectMap[project];
|
||||
bool bfHadOutputChanges;
|
||||
List<String> bfFileNames = scope List<String>();
|
||||
bfCompiler.GetOutputFileNames(bfProject, false, out bfHadOutputChanges, bfFileNames);
|
||||
bfCompiler.GetOutputFileNames(bfProject, .None, out bfHadOutputChanges, bfFileNames);
|
||||
defer ClearAndDeleteItems(bfFileNames);
|
||||
if (bfHadOutputChanges)
|
||||
project.mNeedsTargetRebuild = true;
|
||||
|
@ -10663,9 +10669,9 @@ namespace IDE
|
|||
{
|
||||
get
|
||||
{
|
||||
if (Workspace.PlatformType.GetFromName(mPlatformName) != .Windows)
|
||||
return false;
|
||||
var workspaceOptions = GetCurWorkspaceOptions();
|
||||
if (Workspace.PlatformType.GetFromName(mPlatformName, workspaceOptions.mTargetTriple) != .Windows)
|
||||
return false;
|
||||
if (workspaceOptions.mToolsetType != .LLVM)
|
||||
return true;
|
||||
|
||||
|
@ -10725,7 +10731,9 @@ namespace IDE
|
|||
return false;
|
||||
}
|
||||
|
||||
let platform = Workspace.PlatformType.GetFromName(mPlatformName);
|
||||
var workspaceOptions = GetCurWorkspaceOptions();
|
||||
|
||||
var platform = Workspace.PlatformType.GetFromName(mPlatformName, workspaceOptions.mTargetTriple);
|
||||
let hostPlatform = Workspace.PlatformType.GetHostPlatform();
|
||||
if (platform == .Unknown)
|
||||
{
|
||||
|
@ -10853,7 +10861,6 @@ namespace IDE
|
|||
return false;
|
||||
}
|
||||
|
||||
var workspaceOptions = GetCurWorkspaceOptions();
|
||||
if ((compileKind == .RunAfter) || (compileKind == .DebugAfter))
|
||||
{
|
||||
if (workspaceOptions.mBuildKind == .Test)
|
||||
|
|
|
@ -1648,8 +1648,23 @@ namespace IDE
|
|||
var options = platformKeyValue.value;
|
||||
using (data.CreateObject(platformKeyValue.key))
|
||||
{
|
||||
BuildKind defaultBuildKind = .Normal;
|
||||
BuildOptions.RelocType defaultRelocType = .NotSet;
|
||||
let platformType = Workspace.PlatformType.GetFromName(platformKeyValue.key);
|
||||
switch (platformType)
|
||||
{
|
||||
case .Linux,
|
||||
.Windows,
|
||||
.macOS:
|
||||
defaultBuildKind = isTest ? .Test : .Normal;
|
||||
default:
|
||||
defaultBuildKind = .StaticLib;
|
||||
}
|
||||
if (platformType == .Android)
|
||||
defaultRelocType = .PIC;
|
||||
|
||||
// Build
|
||||
data.ConditionalAdd("BuildKind", options.mBuildOptions.mBuildKind, isTest ? .Test : .Normal);
|
||||
data.ConditionalAdd("BuildKind", options.mBuildOptions.mBuildKind, defaultBuildKind);
|
||||
data.ConditionalAdd("TargetDirectory", options.mBuildOptions.mTargetDirectory, "$(BuildDir)");
|
||||
data.ConditionalAdd("TargetName", options.mBuildOptions.mTargetName, "$(ProjectName)");
|
||||
data.ConditionalAdd("OtherLinkFlags", options.mBuildOptions.mOtherLinkFlags, "$(LinkFlags)");
|
||||
|
@ -1708,7 +1723,7 @@ namespace IDE
|
|||
data.Add(macro);
|
||||
}
|
||||
}
|
||||
data.ConditionalAdd("RelocType", options.mBeefOptions.mRelocType, .NotSet);
|
||||
data.ConditionalAdd("RelocType", options.mBeefOptions.mRelocType, defaultRelocType);
|
||||
data.ConditionalAdd("PICLevel", options.mBeefOptions.mPICLevel, .NotSet);
|
||||
data.ConditionalAdd("OptimizationLevel", options.mBeefOptions.mOptimizationLevel);
|
||||
data.ConditionalAdd("LTOType", options.mBeefOptions.mLTOType);
|
||||
|
@ -1986,9 +2001,24 @@ namespace IDE
|
|||
{
|
||||
Options options = new Options();
|
||||
config.mPlatforms[new String(platformName)] = options;
|
||||
|
||||
|
||||
BuildKind defaultBuildKind = .Normal;
|
||||
BuildOptions.RelocType defaultRelocType = .NotSet;
|
||||
let platformType = Workspace.PlatformType.GetFromName(platformName);
|
||||
switch (platformType)
|
||||
{
|
||||
case .Linux,
|
||||
.Windows,
|
||||
.macOS:
|
||||
defaultBuildKind = isTest ? .Test : .Normal;
|
||||
default:
|
||||
defaultBuildKind = .StaticLib;
|
||||
}
|
||||
if (platformType == .Android)
|
||||
defaultRelocType = .PIC;
|
||||
|
||||
// Build
|
||||
options.mBuildOptions.mBuildKind = data.GetEnum<BuildKind>("BuildKind", isTest ? .Test : .Normal);
|
||||
options.mBuildOptions.mBuildKind = data.GetEnum<BuildKind>("BuildKind", defaultBuildKind);
|
||||
if ((isBeefDynLib) && (options.mBuildOptions.mBuildKind == .Normal))
|
||||
options.mBuildOptions.mBuildKind = .DynamicLib;
|
||||
data.GetString("TargetDirectory", options.mBuildOptions.mTargetDirectory, "$(BuildDir)");
|
||||
|
@ -2034,7 +2064,7 @@ namespace IDE
|
|||
options.mBeefOptions.mPreprocessorMacros.Add(new String("TEST"));
|
||||
}
|
||||
|
||||
options.mBeefOptions.mRelocType = data.GetEnum<BuildOptions.RelocType>("RelocType");
|
||||
options.mBeefOptions.mRelocType = data.GetEnum<BuildOptions.RelocType>("RelocType", defaultRelocType);
|
||||
options.mBeefOptions.mPICLevel = data.GetEnum<BuildOptions.PICLevel>("PICLevel");
|
||||
if (data.Contains("OptimizationLevel"))
|
||||
options.mBeefOptions.mOptimizationLevel = data.GetEnum<BuildOptions.BfOptimizationLevel>("OptimizationLevel");
|
||||
|
|
|
@ -68,8 +68,11 @@ namespace IDE
|
|||
case Android;
|
||||
case Wasm;
|
||||
|
||||
public static PlatformType GetFromName(StringView name)
|
||||
public static PlatformType GetFromName(StringView name, StringView targetTriple = default)
|
||||
{
|
||||
if (!targetTriple.IsWhiteSpace)
|
||||
return TargetTriple.GetPlatformType(targetTriple);
|
||||
|
||||
switch (name)
|
||||
{
|
||||
case "Win32", "Win64": return .Windows;
|
||||
|
|
|
@ -16049,7 +16049,7 @@ void BeMCContext::Generate(BeFunction* function)
|
|||
|
||||
if (!mModule->mTargetCPU.IsEmpty())
|
||||
mModule->mBeIRCodeGen->Fail(StrFormat("Cannot set Target CPU to '%s' for +Og optimization. Considering compiling under a different optimization setting.", mModule->mTargetCPU.c_str()));
|
||||
if (mModule->mTargetTriple != "x86_64-pc-windows-msvc")
|
||||
if ((!mModule->mTargetTriple.IsEmpty()) && (!mModule->mTargetTriple.StartsWith("x86_64-pc-windows")))
|
||||
{
|
||||
mModule->mBeIRCodeGen->Fail(StrFormat("Cannot set Target Triple to '%s' for +Og optimization. Considering compiling under a different optimization setting.", mModule->mTargetTriple.c_str()));
|
||||
return;
|
||||
|
|
|
@ -9388,7 +9388,14 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetTypeInfo(BfCompiler* bfCompiler,
|
|||
return outString.c_str();
|
||||
}
|
||||
|
||||
BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetUsedOutputFileNames(BfCompiler* bfCompiler, BfProject* bfProject, bool flushQueuedHotFiles, bool* hadOutputChanges)
|
||||
enum BfUsedOutputFlags
|
||||
{
|
||||
BfUsedOutputFlags_None = 0,
|
||||
BfUsedOutputFlags_FlushQueuedHotFiles = 1,
|
||||
BfUsedOutputFlags_SkipImports = 2,
|
||||
};
|
||||
|
||||
BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetUsedOutputFileNames(BfCompiler* bfCompiler, BfProject* bfProject, BfUsedOutputFlags flags, bool* hadOutputChanges)
|
||||
{
|
||||
BP_ZONE("BfCompiler_GetUsedOutputFileNames");
|
||||
|
||||
|
@ -9435,14 +9442,17 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetUsedOutputFileNames(BfCompiler*
|
|||
{
|
||||
BF_ASSERT(!mainModule->mIsDeleting);
|
||||
|
||||
for (auto fileNameIdx : mainModule->mImportFileNames)
|
||||
if ((flags & BfUsedOutputFlags_SkipImports) == 0)
|
||||
{
|
||||
auto fileName = bfCompiler->mContext->mStringObjectIdMap[fileNameIdx].mString;
|
||||
if (!usedFileNames.TryAdd(fileName, NULL))
|
||||
continue;
|
||||
if (!outString.empty())
|
||||
outString += "\n";
|
||||
outString += fileName;
|
||||
for (auto fileNameIdx : mainModule->mImportFileNames)
|
||||
{
|
||||
auto fileName = bfCompiler->mContext->mStringObjectIdMap[fileNameIdx].mString;
|
||||
if (!usedFileNames.TryAdd(fileName, NULL))
|
||||
continue;
|
||||
if (!outString.empty())
|
||||
outString += "\n";
|
||||
outString += fileName;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto&& moduleFileName : mainModule->mOutFileNames)
|
||||
|
@ -9493,7 +9503,7 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetUsedOutputFileNames(BfCompiler*
|
|||
continue;
|
||||
outPaths.Add(fileEntry.mFileName);
|
||||
|
||||
if (flushQueuedHotFiles)
|
||||
if ((flags & BfUsedOutputFlags_FlushQueuedHotFiles) != 0)
|
||||
{
|
||||
bfCompiler->mHotState->mQueuedOutFiles.RemoveAtFast(i);
|
||||
i--;
|
||||
|
|
|
@ -2197,6 +2197,7 @@ void BfContext::UpdateRevisedTypes()
|
|||
HashContext workspaceConfigHashCtx;
|
||||
|
||||
workspaceConfigHashCtx.MixinStr(options->mTargetTriple);
|
||||
workspaceConfigHashCtx.MixinStr(options->mTargetCPU);
|
||||
workspaceConfigHashCtx.Mixin(options->mForceRebuildIdx);
|
||||
|
||||
workspaceConfigHashCtx.Mixin(options->mMachineType);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue