Merge pull request #1043 from tdesveauxPKFX/omit-frame-pointer

Add omitframepointer API
This commit is contained in:
Samuel Surtees 2018-04-17 20:19:36 +10:00 committed by GitHub
commit 2061b151b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 191 additions and 21 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.
@ -1284,3 +1272,58 @@
</ClCompile>
]]
end
--
-- Check OmitFramePointer
--
function suite.omitFramePointer_Default()
omitframepointer "Default"
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
]]
end
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

@ -1333,7 +1333,7 @@
function m.omitFramePointers(cfg)
if cfg.flags.NoFramePointer then
if cfg.omitframepointer == "On" then
p.w('OmitFramePointers="true"')
end
end

View File

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

View File

@ -1700,6 +1700,62 @@
end
function suite.XCBuildConfigurationProject_OnOmitFramePointer()
omitframepointer "On"
prepare()
xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
test.capture [[
[MyProject:Debug(2)] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
GCC_OPTIMIZATION_LEVEL = 0;
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OBJROOT = obj/Debug;
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = (
"-fomit-frame-pointer",
);
SYMROOT = bin/Debug;
};
name = Debug;
};
]]
end
function suite.XCBuildConfigurationProject_OnNoOmitFramePointer()
omitframepointer "Off"
prepare()
xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
test.capture [[
[MyProject:Debug(2)] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
GCC_OPTIMIZATION_LEVEL = 0;
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OBJROOT = obj/Debug;
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = (
"-fno-omit-frame-pointer",
);
SYMROOT = bin/Debug;
};
name = Debug;
};
]]
end
function suite.XCBuildConfigurationProject_OnNoPCH()
pchheader "MyProject_Prefix.pch"
flags { "NoPCH" }

View File

@ -1143,8 +1143,9 @@
-- build list of "other" C/C++ flags
local checks = {
["-ffast-math"] = cfg.floatingpoint == "Fast",
["-fomit-frame-pointer"] = cfg.flags.NoFramePointer,
["-ffast-math"] = cfg.floatingpoint == "Fast",
["-fomit-frame-pointer"] = cfg.omitframepointer == "On",
["-fno-omit-frame-pointer"] = cfg.omitframepointer == "Off",
}
local flags = { }

View File

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

View File

@ -62,7 +62,8 @@
isaextensions = gcc.shared.isaextensions,
warnings = gcc.shared.warnings,
symbols = gcc.shared.symbols,
unsignedchar = gcc.shared.unsignedchar
unsignedchar = gcc.shared.unsignedchar,
omitframepointer = gcc.shared.omitframepointer
}
clang.cflags = table.merge(gcc.cflags, {

View File

@ -42,7 +42,6 @@
flags = {
FatalCompileWarnings = "-Werror",
LinkTimeOptimization = "-flto",
NoFramePointer = "-fomit-frame-pointer",
ShadowedVariables = "-Wshadow",
UndefinedIdentifiers = "-Wundef",
},
@ -100,6 +99,10 @@
unsignedchar = {
On = "-funsigned-char",
Off = "-fno-unsigned-char"
},
omitframepointer = {
On = "-fomit-frame-pointer",
Off = "-fno-omit-frame-pointer"
}
}

View File

@ -38,7 +38,6 @@
flags = {
FatalCompileWarnings = "/WX",
MultiProcessorCompile = "/MP",
NoFramePointer = "/Oy",
NoMinimalRebuild = "/Gm-",
OmitDefaultLibrary = "/Zl"
},
@ -102,6 +101,9 @@
},
unsignedchar = {
On = "/J",
},
omitframepointer = {
On = "/Oy"
}
}

View File

@ -808,3 +808,31 @@
test.contains({ "-fno-unsigned-char" }, gcc.getcxxflags(cfg))
test.contains({ "-fno-unsigned-char" }, gcc.getcflags(cfg))
end
--
-- Test omit-frame-pointer flags.
--
function suite.sharedflags_onOmitFramePointerDefault()
omitframepointer "Default"
prepare()
test.excludes({ "-fomit-frame-pointer", "-fno-omit-frame-pointer" }, gcc.getcxxflags(cfg))
test.excludes({ "-fomit-frame-pointer", "-fno-omit-frame-pointer" }, gcc.getcflags(cfg))
end
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

View File

@ -72,6 +72,18 @@
test.contains("/Oy", msc.getcflags(cfg))
end
function suite.cflags_onOmitFramePointer()
omitframepointer "On"
prepare()
test.contains("/Oy", msc.getcflags(cfg))
end
function suite.cflags_onNoOmitFramePointers()
omitframepointer "Off"
prepare()
test.excludes("/Oy", msc.getcflags(cfg))
end
function suite.ldflags_onLinkTimeOptimizations()
flags "LinkTimeOptimization"
prepare()