Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add omitframepointer API #1043

Merged
merged 12 commits into from
Apr 17, 2018
67 changes: 55 additions & 12 deletions modules/vstudio/tests/vc2010/test_compile_settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion modules/vstudio/vs200x_vcproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@


function m.omitFramePointers(cfg)
if cfg.flags.NoFramePointer then
if cfg.omitframepointer == "On" then
p.w('OmitFramePointers="true"')
end
end
Expand Down
7 changes: 5 additions & 2 deletions modules/vstudio/vs2010_vcxproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2168,8 +2168,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

Expand Down
56 changes: 56 additions & 0 deletions modules/xcode/tests/test_xcode_project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
5 changes: 3 additions & 2 deletions modules/xcode/xcode_common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = { }
Expand Down
23 changes: 22 additions & 1 deletion src/_premake_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@
"No64BitChecks",
"NoCopyLocal",
"NoEditAndContinue", -- DEPRECATED
"NoFramePointer",
"NoFramePointer", -- DEPRECATED
"NoImplicitLink",
"NoImportLib",
"NoIncrementalLink",
Expand Down Expand Up @@ -1355,6 +1355,17 @@
}
}

api.register {
name = "omitframepointer",
scope = "config",
kind = "string",
allowed = {
"Default",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't test this value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an "unset". I was unsure that it is a value we want and kinda forgot.
So I see some APIs that have the option to set Default and others not. What is your take on this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned in the other comment chain, I've encountered the need for an "unset" value. So I'm 100% in favour of not having to hack around in my Premake scripts just to "unset" something.

"On",
"Off"
}
}

-----------------------------------------------------------------------------
--
-- Field name aliases for backward compatibility
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/tools/clang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
5 changes: 4 additions & 1 deletion src/tools/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
flags = {
FatalCompileWarnings = "-Werror",
LinkTimeOptimization = "-flto",
NoFramePointer = "-fomit-frame-pointer",
ShadowedVariables = "-Wshadow",
UndefinedIdentifiers = "-Wundef",
},
Expand Down Expand Up @@ -100,6 +99,10 @@
unsignedchar = {
On = "-funsigned-char",
Off = "-fno-unsigned-char"
},
omitframepointer = {
On = "-fomit-frame-pointer",
Off = "-fno-omit-frame-pointer"
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/tools/msc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
flags = {
FatalCompileWarnings = "/WX",
MultiProcessorCompile = "/MP",
NoFramePointer = "/Oy",
NoMinimalRebuild = "/Gm-",
OmitDefaultLibrary = "/Zl"
},
Expand Down Expand Up @@ -102,6 +101,9 @@
},
unsignedchar = {
On = "/J",
},
omitframepointer = {
On = "/Oy"
}

}
Expand Down
28 changes: 28 additions & 0 deletions tests/tools/test_gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions tests/tools/test_msc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down