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 RemoveUnreferencedCodeData option to disable /Zc:inline #1606

Merged
merged 1 commit into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions modules/vstudio/tests/vc2010/test_compile_settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,45 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<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>
]]
end
13 changes: 12 additions & 1 deletion modules/vstudio/vs2010_vcxproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,8 @@
m.languageStandard,
m.conformanceMode,
m.structMemberAlignment,
m.useFullPaths
m.useFullPaths,
m.removeUnreferencedCodeData
}

if cfg.kind == p.STATICLIB then
Expand Down Expand Up @@ -1515,6 +1516,16 @@
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)
local opts = cfg.buildoptions
if _ACTION == "vs2015" or vstudio.isMakefile(cfg) then
Expand Down
6 changes: 6 additions & 0 deletions src/_premake_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,12 @@
kind = "boolean"
}

api.register {
name = "removeunreferencedcodedata",
scope = "config",
kind = "boolean"
}

api.register {
name = "swiftversion",
scope = "config",
Expand Down
30 changes: 30 additions & 0 deletions website/docs/removeunreferencedcodedata.md
Original file line number Diff line number Diff line change
@@ -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"
```

1 change: 1 addition & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ module.exports = {
'project',
'propertydefinition',
'rebuildcommands',
'removeunreferencedcodedata',
'resdefines',
'resincludedirs',
'resoptions',
Expand Down