Add omitframepointer API + implement for gcc and vstudio

This commit is contained in:
Thomas Desveaux 2018-04-09 17:11:38 +02:00
parent 2ac3153f81
commit 0160e82188
5 changed files with 91 additions and 16 deletions

View File

@ -239,18 +239,6 @@
]]
end
function suite.omitFrames_onNoFramePointer()
flags "NoFramePointer"
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<OmitFramePointers>true</OmitFramePointers>
]]
end
--
-- If defines are specified, the <PreprocessorDefinitions> element should be added.
@ -1238,3 +1226,47 @@
</ClCompile>
]]
end
--
-- Check OmitFramePointer
--
function suite.omitFramePointer_On()
omitframepointer "On"
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<OmitFramePointers>true</OmitFramePointers>
</ClCompile>
]]
end
function suite.omitFramePointer_Off()
omitframepointer "Off"
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<OmitFramePointers>false</OmitFramePointers>
</ClCompile>
]]
end
function suite.omitFramePointer_DeprecationFlag()
flags "NoFramePointer"
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<OmitFramePointers>true</OmitFramePointers>
</ClCompile>
]]
end

View File

@ -2071,8 +2071,9 @@
function m.omitFramePointers(cfg)
if cfg.flags.NoFramePointer then
m.element("OmitFramePointers", nil, "true")
if cfg.omitframepointer then
local map = { Off = "false", On = "true" }
m.element("OmitFramePointers", nil, map[cfg.omitframepointer])
end
end

View File

@ -507,7 +507,7 @@
"No64BitChecks",
"NoCopyLocal",
"NoEditAndContinue", -- DEPRECATED
"NoFramePointer",
"NoFramePointer", -- DEPRECATED
"NoImplicitLink",
"NoImportLib",
"NoIncrementalLink",
@ -1336,6 +1336,18 @@
}
}
api.register {
name = "omitframepointer",
scope = "config",
kind = "string",
allowed = {
"Default",
"On",
"Off"
}
}
-----------------------------------------------------------------------------
--
-- Field name aliases for backward compatibility
@ -1577,6 +1589,13 @@
staticruntime "Default"
end)
-- 08 April 2018
api.deprecateValue("flags", "NoFramePointer", 'Use `framepointer "Off"` instead.',
function(value)
omitframepointer("On")
end)
-----------------------------------------------------------------------------
--
-- Install Premake's default set of command line arguments.

View File

@ -42,7 +42,6 @@
flags = {
FatalCompileWarnings = "-Werror",
LinkTimeOptimization = "-flto",
NoFramePointer = "-fomit-frame-pointer",
ShadowedVariables = "-Wshadow",
UndefinedIdentifiers = "-Wundef",
},
@ -96,6 +95,10 @@
},
symbols = {
On = "-g"
},
omitframepointer = {
On = "-fomit-frame-pointer",
Off = "-fno-omit-frame-pointer"
}
}

View File

@ -788,3 +788,23 @@
test.contains({ "-std=gnu++17" }, gcc.getcxxflags(cfg))
test.contains({ }, gcc.getcflags(cfg))
end
--
-- Test omit-frame-pointer flags.
--
function suite.sharedflags_onOmitFramePointer()
omitframepointer "On"
prepare()
test.contains({ "-fomit-frame-pointer" }, gcc.getcxxflags(cfg))
test.contains({ "-fomit-frame-pointer" }, gcc.getcflags(cfg))
end
function suite.sharedflags_onNoOmitFramePointer()
omitframepointer "Off"
prepare()
test.contains({ "-fno-omit-frame-pointer" }, gcc.getcxxflags(cfg))
test.contains({ "-fno-omit-frame-pointer" }, gcc.getcflags(cfg))
end