Merge pull request #1606 from withmorten/master

add RemoveUnreferencedCodeData option to disable /Zc:inline
This commit is contained in:
starkos 2021-04-06 14:13:37 -04:00 committed by GitHub
commit 954271148c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 88 additions and 1 deletions

View File

@ -1546,6 +1546,45 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
</ClCompile>
]]
end
--
-- If removeUnreferencedCodeData flag is set, add <RemoveUnreferencedCodeData> element
--
function suite.onRemoveUnreferencedCodeDataOff()
removeunreferencedcodedata "Off"
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<RemoveUnreferencedCodeData>false</RemoveUnreferencedCodeData>
]]
end
function suite.onRemoveUnreferencedCodeDataOn()
removeunreferencedcodedata "On"
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
]]
end
function suite.onRemoveUnreferencedCodeDataNotSpecified()
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile> </ClCompile>
]] ]]
end end

View File

@ -386,7 +386,8 @@
m.languageStandard, m.languageStandard,
m.conformanceMode, m.conformanceMode,
m.structMemberAlignment, m.structMemberAlignment,
m.useFullPaths m.useFullPaths,
m.removeUnreferencedCodeData
} }
if cfg.kind == p.STATICLIB then if cfg.kind == p.STATICLIB then
@ -1515,6 +1516,16 @@
end end
end end
function m.removeUnreferencedCodeData(cfg)
if cfg.removeUnreferencedCodeData ~= nil then
if cfg.removeUnreferencedCodeData then
m.element("RemoveUnreferencedCodeData", nil, "true")
else
m.element("RemoveUnreferencedCodeData", nil, "false")
end
end
end
function m.additionalCompileOptions(cfg, condition) function m.additionalCompileOptions(cfg, condition)
local opts = cfg.buildoptions local opts = cfg.buildoptions
if _ACTION == "vs2015" or vstudio.isMakefile(cfg) then if _ACTION == "vs2015" or vstudio.isMakefile(cfg) then

View File

@ -795,6 +795,12 @@
kind = "boolean" kind = "boolean"
} }
api.register {
name = "removeunreferencedcodedata",
scope = "config",
kind = "boolean"
}
api.register { api.register {
name = "swiftversion", name = "swiftversion",
scope = "config", scope = "config",

View File

@ -0,0 +1,30 @@
Sets the `RemoveUnreferencedCodeData` property for a configuration or all configurations within a project or workspace, adding or removing the `/Zc:inline[-]` build option.
[/Zc:inline (Remove unreferenced COMDAT)](https://docs.microsoft.com/en-us/cpp/build/reference/zc-inline-remove-unreferenced-comdat?view=msvc-160)
If this property is unset, it defaults to `true` in Visual Studio.
```lua
removeunreferencedcodedata ("value")
```
### Parameters ###
`value` one of:
* `on` - Enables `RemoveUnreferencedCodeData`.
* `off` - Disables `RemoveUnreferencedCodeData`.
### Applies To ###
Workspaces and projects.
### Availability ###
Premake 5.0 alpha 16 or later.
### Examples ###
```lua
RemoveUnreferencedCodeData "Off"
```

View File

@ -192,6 +192,7 @@ module.exports = {
'project', 'project',
'propertydefinition', 'propertydefinition',
'rebuildcommands', 'rebuildcommands',
'removeunreferencedcodedata',
'resdefines', 'resdefines',
'resincludedirs', 'resincludedirs',
'resoptions', 'resoptions',