Merge pull request #1298 from TurkeyMan/d_updates

Update D module to VS2019 and latest D compiler options.
This commit is contained in:
@starkos 2019-06-03 17:21:02 -04:00 committed by GitHub
commit d561c80ed4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 511 additions and 170 deletions

View File

@ -16,67 +16,59 @@ to your project definition and populate with .d files.
C and C++ projects that include .d files will also support some of the API below. Any API tagged with (D/C/C++) works in D and C/C++ projects. Any API tagged with (C/C++) only works for .d files in C/C++ projects.
### APIs ###
## D ##
* [flags](https://github.com/premake/premake-dlang/wiki/flags)
* AllInstantiate
* CodeCoverage
* Deprecated
* Color
* Documentation
* GenerateHeader
* GenerateJSON
* GenerateMap
* NoBoundsCheck
* IgnorePragma
* LowMem
* Main
* PerformSyntaxCheckOnly
* Profile
* ProfileGC
* Quiet
* RetainPaths
* SeparateCompilation
* ShowCommandLine
* ShowDependencies
* ShowGC
* ShowTLS
* StackFrame
* StackStomp
* SymbolsLikeC
* UnitTest
* UseLDC
* Verbose
* [versionconstants](https://github.com/premake/premake-dlang/wiki/versionconstants)
* [versionlevel](https://github.com/premake/premake-dlang/wiki/versionlevel)
* boundscheck ("type") [Off, SafeOnly, On]
* compilationmodel ("model") [ Project, Package, File ]
* checkaction
* computetargets
* [debugconstants](https://github.com/premake/premake-dlang/wiki/debugconstants)
* [debuglevel](https://github.com/premake/premake-dlang/wiki/debuglevel)
* [docdir](https://github.com/premake/premake-dlang/wiki/docdir)
* [docname](https://github.com/premake/premake-dlang/wiki/docname)
* [headerdir](https://github.com/premake/premake-dlang/wiki/headerdir)
* [headername](https://github.com/premake/premake-dlang/wiki/headername)
## C/C++ ##
* [flags](https://github.com/premake/premake-dlang/wiki/flags)
* CodeCoverage
* UnitTest
* Verbose
* Profile
* ProfileGC
* StackFrame
* StackStomp
* AllTemplateInst
* BetterC
* Main
* ShowCommandLine
* ShowTLS
* ShowGC
* IgnorePragma
* ShowDependencies
* [versionconstants](https://github.com/premake/premake-dlang/wiki/versionconstants)
* [debugconstants](https://github.com/premake/premake-dlang/wiki/debugconstants)
* [docdir](https://github.com/premake/premake-dlang/wiki/docdir)
* [docname](https://github.com/premake/premake-dlang/wiki/docname)
* [headerdir](https://github.com/premake/premake-dlang/wiki/headerdir)
* [headername](https://github.com/premake/premake-dlang/wiki/headername)
* dependenciesfile ("filename")
* jsonfile ("filename")
* importpaths { "paths" }
* stringimportpaths { "paths" }
* compilationmodel ("model") [ Project, Package, File ]
* deprecatedfeatures ("feature") [ Error, Info, Allow ]
* [docdir](https://github.com/premake/premake-dlang/wiki/docdir)
* [docname](https://github.com/premake/premake-dlang/wiki/docname)
* [headerdir](https://github.com/premake/premake-dlang/wiki/headerdir)
* [headername](https://github.com/premake/premake-dlang/wiki/headername)
* importdirs { "paths" }
* [inlining](https://github.com/premake/premake-core/wiki/inlining)
* jsonfile ("filename")
* importdirs
* [optimize](https://github.com/premake/premake-core/wiki/optimize)
* preview
* revert
* runtime ("type") [ Debug, Release ]
* staticruntime ("state") [ on, off ]
* [optimize](https://github.com/premake/premake-core/wiki/optimize)
* [inlining](https://github.com/premake/premake-core/wiki/inlining)
* boundscheck ("type") [Off, SafeOnly, On]
* deprecatedfeatures ("feature") [ Error, Info, Allow ]
* stringimportdirs { "paths" }
* transition
* [versionconstants](https://github.com/premake/premake-dlang/wiki/versionconstants)
* [versionlevel](https://github.com/premake/premake-dlang/wiki/versionlevel)
### Example ###
The contents of your premake5.lua file would be:

View File

@ -24,25 +24,24 @@
api.addAllowed("floatingpoint", "None")
api.addAllowed("flags", {
"CodeCoverage",
"Deprecated", -- DEPRECATED
"Color",
"Documentation",
"GenerateHeader",
"GenerateJSON",
"GenerateMap",
"NoBoundsCheck", -- DEPRECATED
"LowMem",
"Profile",
"Quiet",
-- "Release", // Note: We infer this flag from config.isDebugBuild()
"RetainPaths",
"SeparateCompilation", -- DEPRECATED
"SymbolsLikeC",
"UnitTest",
-- These are used by C++/D mixed $todo move them somewhere else? "flags2" "Dflags"?
-- [Code Generation Flags]
"UseLDC",
"ProfileGC",
"StackFrame",
"StackStomp",
"AllTemplateInst",
"AllInstantiate",
"BetterC",
"Main",
"PerformSyntaxCheckOnly",
@ -61,18 +60,54 @@
--
api.register {
name = "versionconstants",
name = "boundscheck",
scope = "config",
kind = "list:string",
tokens = true,
kind = "string",
allowed = {
"Default",
"Off",
"On",
"SafeOnly",
},
}
api.register {
name = "versionlevel",
name = "compilationmodel",
scope = "config",
kind = "integer",
kind = "string",
allowed = {
"Default",
"File",
"Package", -- TODO: this doesn't work with gmake!!
"Project",
},
}
api.register {
name = "checkaction",
scope = "config",
kind = "string",
allowed = {
"Default",
"D",
"C",
"Halt",
"Context",
},
}
api.register {
name = "computetargets",
scope = "config",
kind = "list:string",
}
-- api.register {
-- name = "debugcode",
-- scope = "config",
-- kind = "string",
-- }
api.register {
name = "debugconstants",
scope = "config",
@ -86,6 +121,25 @@
kind = "integer",
}
api.register {
name = "dependenciesfile",
scope = "config",
kind = "path",
tokens = true,
}
api.register {
name = "deprecatedfeatures",
scope = "config",
kind = "string",
allowed = {
"Default",
"Allow",
"Warn",
"Error",
},
}
api.register {
name = "docdir",
scope = "config",
@ -114,22 +168,11 @@
tokens = true,
}
-- api.register {
-- name = "debugcode",
-- scope = "config",
-- kind = "string",
-- }
api.register {
name = "compilationmodel",
name = "jsonfile",
scope = "config",
kind = "string",
allowed = {
"Default",
"File",
"Package", -- TODO: this doesn't work with gmake!!
"Project",
},
kind = "path",
tokens = true,
}
api.register {
@ -139,6 +182,32 @@
tokens = true,
}
api.register {
name = "preview",
scope = "config",
kind = "list:string",
allowed = {
"dip25",
"dip1000",
"dip1008",
"fieldwise",
"markdown",
"fixAliasThis",
"intpromote",
"dtorfields",
},
}
api.register {
name = "revert",
scope = "config",
kind = "list:string",
allowed = {
"dip25",
"import",
},
}
api.register {
name = "stringimportdirs",
scope = "config",
@ -147,41 +216,29 @@
}
api.register {
name = "deprecatedfeatures",
name = "transition",
scope = "config",
kind = "string",
kind = "list:string",
allowed = {
"Default",
"Allow",
"Warn",
"Error",
"field",
"checkimports",
"complex",
"tls",
"vmarkdown",
},
}
api.register {
name = "boundscheck",
name = "versionconstants",
scope = "config",
kind = "string",
allowed = {
"Default",
"Off",
"On",
"SafeOnly",
},
}
api.register {
name = "dependenciesfile",
scope = "config",
kind = "path",
kind = "list:string",
tokens = true,
}
api.register {
name = "jsonfile",
name = "versionlevel",
scope = "config",
kind = "path",
tokens = true,
kind = "integer",
}
--
@ -201,35 +258,6 @@
}
--
-- Deprecate old stuff
--
api.deprecateValue("flags", "SeparateCompilation", 'Use `compilationmodel "File"` instead',
function(value)
compilationmodel "File"
end,
function(value)
compilationmodel "Default"
end)
api.deprecateValue("flags", "Deprecated", 'Use `deprecatedfeatures "Allow"` instead',
function(value)
deprecatedfeatures "Allow"
end,
function(value)
deprecatedfeatures "Default"
end)
api.deprecateValue("flags", "NoBoundsCheck", 'Use `boundscheck "Off"` instead',
function(value)
boundscheck "Off"
end,
function(value)
boundscheck "Default"
end)
--
-- Decide when to load the full module
--

View File

@ -19,6 +19,47 @@
local vc2010 = p.vstudio.vc2010
local config = p.config
--
-- Patch DCompiler into the configuration properties
--
p.override(vc2010.elements, "configurationProperties", function(oldfn, cfg)
local items = oldfn(cfg)
if cfg.kind ~= p.UTILITY then
table.insert(items, m.dCompiler)
end
return items
end)
function m.dCompiler(cfg)
local dc = nil
-- TODO: chech for explicit DMD or LDC request?
if _OPTIONS.dc then
local dcMap = {
["dmd"] = "DMD",
["ldc"] = "LDC",
}
dc = dcMap[_OPTIONS.dc]
end
if cfg.flags.UseLDC then
dc = "LDC"
end
-- TODO: dunno how to use `toolset`, since it's also used by the C++ compiler :/
-- local tool, version = p.config.toolset(cfg)
-- if not version then
-- local value = p.action.current().toolset
-- tool, version = p.tools.canonical(value)
-- end
if dc then
if cfg.kind == p.NONE or cfg.kind == p.MAKEFILE then
if p.config.hasFile(cfg, path.isdfile) or _ACTION >= "vs2015" then
vc2010.element("DCompiler", nil, dc)
end
else
vc2010.element("DCompiler", nil, dc)
end
end
end
--
-- Patch the dCompile step into the project items
--
@ -42,10 +83,13 @@
m.dVersionConstants,
m.dDebugConstants,
m.dCompilationModel,
m.dPreserveSourcePath,
m.dRuntime,
m.dCodeGeneration,
m.dLanguage,
m.dMessages,
m.dDocumentation,
m.dAdditionalCompileOptions,
}
end
@ -76,10 +120,13 @@
m.dVersionConstants,
m.dDebugConstants,
m.dCompilationModel,
m.dPreserveSourcePath,
m.dRuntime,
m.dCodeGeneration,
m.dLanguage,
m.dMessages,
m.dDocumentation,
m.dAdditionalCompileOptions,
}
else
return {
@ -97,7 +144,7 @@
}
function m.dOptimization(cfg, condition)
local map = { Off="false", On="true", Debug="true", Full="true", Size="true", Speed="true" }
local map = { Off="false", On="true", Debug="false", Full="true", Size="true", Speed="true" }
if cfg.optimize then
vc2010.element('Optimizer', condition, map[cfg.optimize] or "false")
end
@ -146,6 +193,11 @@
end
end
function m.dPreserveSourcePath(cfg, condition)
if cfg.flags.RetainPaths then
vc2010.element("PreserveSourcePath", condition, "true")
end
end
function m.dRuntime(cfg, condition)
if cfg.flags.OmitDefaultLibrary then
@ -192,37 +244,51 @@
vc2010.element("ObjectFileName", condition, ObjectFileName)
end
if cfg.optimize then
if config.isOptimizedBuild(cfg) then
vc2010.element("Optimizer", condition, "true")
end
end
if cfg.flags.Profile then
vc2010.element("Profile", condition, "true")
end
if cfg.flags.ProfileGC then
vc2010.element("ProfileGC", condition, "true")
end
if cfg.flags.CodeCoverage then
vc2010.element("Coverage", condition, "true")
end
if cfg.flags.UnitTest then
vc2010.element("Unittest", condition, "true")
end
if cfg.inlining then
if cfg.inlining and cfg.inlining ~= "Default" then
local types = {
Default = "true",
Disabled = "false",
Explicit = "true",
Auto = "true",
}
vc2010.element("Inliner", condition, types[cfg.inlining])
end
if cfg.boundscheck and cfg.boundscheck ~= "Default" then
local types = {
Off = "Off",
SafeOnly = "SafeOnly",
On = "On",
}
vc2010.element("BoundsCheck", condition, types[cfg.boundscheck])
if cfg.flags.StackFrame then
vc2010.element("StackFrame", condition, "true")
end
if cfg.flags.StackStomp then
vc2010.element("StackStomp", condition, "true")
end
if cfg.flags.AllInstantiate then
vc2010.element("AllInst", condition, "true")
end
if cfg.flags.Main then
vc2010.element("Main", condition, "true")
end
if _OPTIONS.dc ~= "ldc" and not cfg.flags.UseLDC then
if cfg.vectorextensions then
local vextMap = {
AVX = "avx",
AVX2 = "avx2",
}
if vextMap[cfg.vectorextensions] ~= nil then
vc2010.element("CPUArchitecture", condition, vextMap[cfg.vectorextensions])
end
end
end
-- if cfg.debugcode then
-- local types = {
-- DebugFull = "Debug",
@ -231,6 +297,13 @@
-- }
-- vc2010.element("DebugCode", condition, types[cfg.debugcode])
-- end
-- TODO: proper option for this? should support unspecified...
if config.isDebugBuild(cfg) then
vc2010.element("DebugCode", condition, "Debug")
else
vc2010.element("DebugCode", condition, "Release")
end
if cfg.symbols then
if cfg.symbols == p.Off then
vc2010.element("DebugInfo", condition, "None")
@ -238,29 +311,54 @@
vc2010.element("DebugInfo", condition, iif(cfg.flags.SymbolsLikeC, "VS", "Mago"))
end
end
if cfg.flags.ProfileGC then
vc2010.element("ProfileGC", condition, "true")
end
if cfg.flags.StackFrame then
vc2010.element("StackFrame", condition, "true")
end
if cfg.flags.StackStomp then
vc2010.element("StackStomp", condition, "true")
end
if cfg.flags.AllTemplateInst then
vc2010.element("AllInst", condition, "true")
end
if cfg.flags.BetterC then
vc2010.element("BetterC", condition, "true")
end
if cfg.flags.Main then
vc2010.element("Main", condition, "true")
if cfg.boundscheck and cfg.boundscheck ~= "Default" then
local types = {
Off = "Off",
SafeOnly = "SafeOnly",
On = "On",
}
vc2010.element("BoundsCheck", condition, types[cfg.boundscheck])
end
if cfg.flags.PerformSyntaxCheckOnly then
vc2010.element("PerformSyntaxCheckOnly", condition, "true")
end
end
function m.dLanguage(cfg, condition)
if cfg.flags.BetterC then
vc2010.element("BetterC", condition, "true")
end
if #cfg.preview > 0 then
for _, opt in ipairs(cfg.preview) do
if opt == "dip25" then
vc2010.element("DIP25", condition, "true")
elseif opt == "dip1000" then
vc2010.element("DIP1000", condition, "true")
elseif opt == "dip1008" then
vc2010.element("DIP1008", condition, "true")
elseif opt == "fieldwise" then
vc2010.element("PreviewFieldwise", condition, "true")
elseif opt == "dtorfields" then
vc2010.element("PreviewDtorFields", condition, "true")
elseif opt == "intpromote" then
vc2010.element("PreviewIntPromote", condition, "true")
elseif opt == "fixAliasThis" then
vc2010.element("PreviewFixAliasThis", condition, "true")
end
end
end
if #cfg.revert > 0 then
for _, opt in ipairs(cfg.revert) do
if opt == "import" then
vc2010.element("RevertImport", condition, "true")
end
end
end
end
function m.dMessages(cfg, condition)
if cfg.warnings == p.OFF then
@ -268,6 +366,7 @@
elseif cfg.warnings and cfg.warnings ~= "Default" then
vc2010.element("Warnings", condition, iif(cfg.flags.FatalCompileWarnings, "Error", "Info"))
end
if cfg.deprecatedfeatures and cfg.deprecatedfeatures ~= "Default" then
local types = {
Error = "Error",
@ -276,6 +375,7 @@
}
vc2010.element("Deprecations", condition, types[cfg.deprecatedfeatures])
end
if cfg.flags.ShowCommandLine then
vc2010.element("ShowCommandLine", condition, "true")
end
@ -294,8 +394,19 @@
if cfg.flags.ShowDependencies then
vc2010.element("ShowDependencies", condition, "true")
end
end
if #cfg.transition > 0 then
for _, opt in ipairs(cfg.transition) do
if opt == "field" then
vc2010.element("TransitionField", condition, "true")
elseif opt == "checkimports" then
vc2010.element("TransitionCheckImports", condition, "true")
elseif opt == "complex" then
vc2010.element("TransitionComplex", condition, "true")
end
end
end
end
function m.dDocumentation(cfg, condition)
if cfg.docdir then
@ -304,16 +415,112 @@
if cfg.docname then
vc2010.element("DocFile", condition, cfg.docname)
end
if #cfg.preview > 0 then
for _, opt in ipairs(cfg.preview) do
if opt == "markdown" then
vc2010.element("PreviewMarkdown", condition, "true")
end
end
end
if #cfg.transition > 0 then
for _, opt in ipairs(cfg.transition) do
if opt == "vmarkdown" then
vc2010.element("TransitionVMarkdown", condition, "true")
end
end
end
if cfg.dependenciesfile then
vc2010.element("DepFile", condition, cfg.dependenciesfile)
end
if cfg.headerdir then
vc2010.element("HeaderDir", condition, cfg.headerdir)
end
if cfg.headername then
vc2010.element("HeaderFile", condition, cfg.headername)
end
if cfg.jsonfile then
vc2010.element("JSONFile", condition, cfg.jsonfile)
end
end
function m.dAdditionalCompileOptions(cfg, condition)
local opts = cfg.buildoptions
if cfg.flags.LowMem then
table.insert(opts, "-lowmem")
end
if cfg.cppdialect and cfg.cppdialect ~= "Default" then
local cppMap = {
["C++latest"] = "c++17", -- TODO: keep this up to date >_<
["C++98"] = "c++98",
["C++0x"] = "c++11",
["C++11"] = "c++11",
["C++1y"] = "c++14",
["C++14"] = "c++14",
["C++1z"] = "c++17",
["C++17"] = "c++17",
["gnu++98"] = "c++98",
["gnu++0x"] = "c++11",
["gnu++11"] = "c++11",
["gnu++1y"] = "c++14",
["gnu++14"] = "c++14",
["gnu++1z"] = "c++17",
["gnu++17"] = "c++17",
}
if cppMap[cfg.cppdialect] ~= nil then
table.insert(opts, "-extern-std=" .. cppMap[cfg.cppdialect])
end
end
-- TODO: better way to check toolset?
if _OPTIONS.dc == "ldc" or cfg.flags.UseLDC then
if cfg.vectorextensions then
local vextMap = {
AVX = "avx",
AVX2 = "avx2",
SSE = "sse",
SSE2 = "sse2",
SSE3 = "sse3",
SSSE3 = "ssse3",
["SSE4.1"] = "sse4.1",
}
if vextMap[cfg.vectorextensions] ~= nil then
table.insert(opts, "-mattr=+" .. vextMap[cfg.vectorextensions])
end
end
if #cfg.isaextensions > 0 then
local isaMap = {
MOVBE = "movbe",
POPCNT = "popcnt",
PCLMUL = "pclmul",
LZCNT = "lzcnt",
BMI = "bmi",
BMI2 = "bmi2",
F16C = "f16c",
AES = "aes",
FMA = "fma",
FMA4 = "fma4",
RDRND = "rdrnd",
}
for _, ext in ipairs(cfg.isaextensions) do
if isaMap[ext] ~= nil then
table.insert(opts, "-mattr=+" .. isaMap[ext])
end
end
end
if #cfg.computetargets > 0 then
table.insert(opts, "-mdcompute-targets=" .. table.concat(cfg.computetargets, ','))
end
end
if #opts > 0 then
opts = table.concat(opts, " ")
vc2010.element("AdditionalOptions", condition, '%s %%(AdditionalOptions)', opts)
end
end

View File

@ -50,7 +50,7 @@
end
function suite.dmd_target_separateCompilation()
flags { "SeparateCompilation" }
compilationmodel "File"
prepare_cfg({ m.make.target })
test.capture [[
OUTPUTFLAG = -of"$@"
@ -98,7 +98,7 @@
end
function suite.dmd_linkCmd_separateCompilation()
flags { "SeparateCompilation" }
compilationmodel "File"
prepare_cfg({ m.make.linkCmd })
test.capture [[
LINKCMD = $(DC) -of$(TARGET) $(ALL_LDFLAGS) $(LIBS) $(OBJECTS)

View File

@ -50,7 +50,7 @@
end
function suite.dmd_target_separateCompilation()
flags { "SeparateCompilation" }
compilationmodel "File"
prepare_cfg({ m.make.target })
test.capture [[
OUTPUTFLAG = -o "$@"
@ -98,7 +98,7 @@
end
function suite.dmd_linkCmd_separateCompilation()
flags { "SeparateCompilation" }
compilationmodel "File"
prepare_cfg({ m.make.linkCmd })
test.capture [[
LINKCMD = $(DC) -o $(TARGET) $(ALL_LDFLAGS) $(LIBS) $(OBJECTS)

View File

@ -50,7 +50,7 @@
end
function suite.dmd_target_separateCompilation()
flags { "SeparateCompilation" }
compilationmodel "File"
prepare_cfg({ m.make.target })
test.capture [[
OUTPUTFLAG = -of="$@"
@ -98,7 +98,7 @@
end
function suite.dmd_linkCmd_separateCompilation()
flags { "SeparateCompilation" }
compilationmodel "File"
prepare_cfg({ m.make.linkCmd })
test.capture [[
LINKCMD = $(DC) -of=$(TARGET) $(ALL_LDFLAGS) $(LIBS) $(OBJECTS)

View File

@ -218,14 +218,15 @@
flags = {
OmitDefaultLibrary = "-mscrtlib=",
CodeCoverage = "-cov",
Color = "-color",
Documentation = "-D",
FatalWarnings = "-w",
GenerateHeader = "-H",
GenerateJSON = "-X",
GenerateMap = "-map",
LowMem = "-lowmem",
Profile = "-profile",
Quiet = "-quiet",
-- Release = "-release",
RetainPaths = "-op",
SymbolsLikeC = "-gc",
UnitTest = "-unittest",
@ -233,7 +234,7 @@
ProfileGC = "-profile=gc",
StackFrame = "-gs",
StackStomp = "-gx",
AllTemplateInst = "-allinst",
AllInstantiate = "-allinst",
BetterC = "-betterC",
Main = "-main",
PerformSyntaxCheckOnly = "-o-",
@ -247,6 +248,29 @@
On = "-boundscheck=on",
SafeOnly = "-boundscheck=safeonly",
},
checkaction = {
D = "-checkaction=D",
C = "-checkaction=C",
Halt = "-checkaction=halt",
Context = "-checkaction=context",
},
cppdialect = {
["C++latest"] = "-extern-std=c++17", -- TODO: keep this up to date >_<
["C++98"] = "-extern-std=c++98",
["C++0x"] = "-extern-std=c++11",
["C++11"] = "-extern-std=c++11",
["C++1y"] = "-extern-std=c++14",
["C++14"] = "-extern-std=c++14",
["C++1z"] = "-extern-std=c++17",
["C++17"] = "-extern-std=c++17",
["gnu++98"] = "-extern-std=c++98",
["gnu++0x"] = "-extern-std=c++11",
["gnu++11"] = "-extern-std=c++11",
["gnu++1y"] = "-extern-std=c++14",
["gnu++14"] = "-extern-std=c++14",
["gnu++1z"] = "-extern-std=c++17",
["gnu++17"] = "-extern-std=c++17",
},
deprecatedfeatures = {
Allow = "-d",
Warn = "-dw",
@ -264,16 +288,20 @@
pic = {
On = "-fPIC",
},
symbols = {
On = "-g",
FastLink = "-g",
Full = "-g",
},
vectorextensions = {
AVX = "-mcpu=avx",
AVX2 = "-mcpu=avx2",
},
warnings = {
Default = "-wi",
High = "-wi",
Extra = "-wi",
},
symbols = {
On = "-g",
FastLink = "-g",
Full = "-g",
}
}
function dmd.getdflags(cfg)
@ -327,6 +355,22 @@
end
end
if #cfg.preview > 0 then
for _, opt in ipairs(cfg.preview) do
table.insert(flags, "-preview=" .. opt)
end
end
if #cfg.revert > 0 then
for _, opt in ipairs(cfg.revert) do
table.insert(flags, "-revert=" .. opt)
end
end
if #cfg.transition > 0 then
for _, opt in ipairs(cfg.transition) do
table.insert(flags, "-transition=" .. opt)
end
end
return flags
end

View File

@ -42,7 +42,7 @@
-- ProfileGC = "-profile=gc",
-- StackFrame = "-gs",
-- StackStomp = "-gx",
-- AllTemplateInst = "-allinst",
-- AllInstantiate = "-allinst",
-- BetterC = "-betterC",
-- Main = "-main",
-- PerformSyntaxCheckOnly = "-o-",

View File

@ -29,7 +29,8 @@
architecture = {
x86 = "-m32",
x86_64 = "-m64",
-- arm = "-march=arm",
ARM = "-march=arm",
ARM64 = "-march=aarch64",
-- ppc = "-march=ppc32",
-- ppc64 = "-march=ppc64",
-- spu = "-march=cellspu",
@ -38,16 +39,17 @@
flags = {
OmitDefaultLibrary = "-mscrtlib=",
CodeCoverage = "-cov",
Color = "-enable-color",
Documentation = "-D",
FatalWarnings = "-w", -- Use LLVM flag? : "-fatal-assembler-warnings",
GenerateHeader = "-H",
GenerateJSON = "-X",
-- Release = "-release",
LowMem = "-lowmem",
RetainPaths = "-op",
SymbolsLikeC = "-gc",
UnitTest = "-unittest",
Verbose = "-v",
AllTemplateInst = "-allinst",
AllInstantiate = "-allinst",
BetterC = "-betterC",
Main = "-main",
PerformSyntaxCheckOnly = "-o-",
@ -59,6 +61,29 @@
On = "-boundscheck=on",
SafeOnly = "-boundscheck=safeonly",
},
checkaction = {
D = "-checkaction=D",
C = "-checkaction=C",
Halt = "-checkaction=halt",
Context = "-checkaction=context",
},
cppdialect = {
["C++latest"] = "-extern-std=c++17", -- TODO: keep this up to date >_<
["C++98"] = "-extern-std=c++98",
["C++0x"] = "-extern-std=c++11",
["C++11"] = "-extern-std=c++11",
["C++1y"] = "-extern-std=c++14",
["C++14"] = "-extern-std=c++14",
["C++1z"] = "-extern-std=c++17",
["C++17"] = "-extern-std=c++17",
["gnu++98"] = "-extern-std=c++98",
["gnu++0x"] = "-extern-std=c++11",
["gnu++11"] = "-extern-std=c++11",
["gnu++1y"] = "-extern-std=c++14",
["gnu++14"] = "-extern-std=c++14",
["gnu++1z"] = "-extern-std=c++17",
["gnu++17"] = "-extern-std=c++17",
},
deprecatedfeatures = {
Allow = "-d",
Warn = "-dw",
@ -81,8 +106,12 @@
},
vectorextensions = {
AVX = "-mattr=+avx",
AVX2 = "-mattr=+avx2",
SSE = "-mattr=+sse",
SSE2 = "-mattr=+sse2",
SSE3 = "-mattr=+sse3",
SSSE3 = "-mattr=+ssse3",
["SSE4.1"] = "-mattr=+sse4.1",
},
warnings = {
Default = "-wi",
@ -147,6 +176,47 @@
end
end
if #cfg.computetargets > 0 then
table.insert(flags, "-mdcompute-targets=" .. table.concat(cfg.computetargets, ','))
end
if #cfg.isaextensions > 0 then
local isaMap = {
MOVBE = "movbe",
POPCNT = "popcnt",
PCLMUL = "pclmul",
LZCNT = "lzcnt",
BMI = "bmi",
BMI2 = "bmi2",
F16C = "f16c",
AES = "aes",
FMA = "fma",
FMA4 = "fma4",
RDRND = "rdrnd",
}
for _, ext in ipairs(cfg.transition) do
if isaMap[ext] ~= nil then
table.insert(flags, "-mattr=+" .. isaMap[ext])
end
end
end
if #cfg.preview > 0 then
for _, opt in ipairs(cfg.preview) do
table.insert(flags, "-preview=" .. opt)
end
end
if #cfg.revert > 0 then
for _, opt in ipairs(cfg.revert) do
table.insert(flags, "-revert=" .. opt)
end
end
if #cfg.transition > 0 then
for _, opt in ipairs(cfg.transition) do
table.insert(flags, "-transition=" .. opt)
end
end
return flags
end