Skip to content

Commit c59e526

Browse files
committed
add RemoveUnreferencedCodeData option to disable /Zc:inline
1 parent 8e69556 commit c59e526

File tree

5 files changed

+88
-1
lines changed

5 files changed

+88
-1
lines changed

modules/vstudio/tests/vc2010/test_compile_settings.lua

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,45 @@
15461546
<PrecompiledHeader>NotUsing</PrecompiledHeader>
15471547
<WarningLevel>Level3</WarningLevel>
15481548
<Optimization>Disabled</Optimization>
1549+
</ClCompile>
1550+
]]
1551+
end
1552+
1553+
--
1554+
-- If removeUnreferencedCodeData flag is set, add <RemoveUnreferencedCodeData> element
1555+
--
1556+
1557+
function suite.onRemoveUnreferencedCodeDataOff()
1558+
removeunreferencedcodedata "Off"
1559+
prepare()
1560+
test.capture [[
1561+
<ClCompile>
1562+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
1563+
<WarningLevel>Level3</WarningLevel>
1564+
<Optimization>Disabled</Optimization>
1565+
<RemoveUnreferencedCodeData>false</RemoveUnreferencedCodeData>
1566+
]]
1567+
end
1568+
1569+
function suite.onRemoveUnreferencedCodeDataOn()
1570+
removeunreferencedcodedata "On"
1571+
prepare()
1572+
test.capture [[
1573+
<ClCompile>
1574+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
1575+
<WarningLevel>Level3</WarningLevel>
1576+
<Optimization>Disabled</Optimization>
1577+
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
1578+
]]
1579+
end
1580+
1581+
function suite.onRemoveUnreferencedCodeDataNotSpecified()
1582+
prepare()
1583+
test.capture [[
1584+
<ClCompile>
1585+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
1586+
<WarningLevel>Level3</WarningLevel>
1587+
<Optimization>Disabled</Optimization>
15491588
</ClCompile>
15501589
]]
15511590
end

modules/vstudio/vs2010_vcxproj.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@
386386
m.languageStandard,
387387
m.conformanceMode,
388388
m.structMemberAlignment,
389-
m.useFullPaths
389+
m.useFullPaths,
390+
m.removeUnreferencedCodeData
390391
}
391392

392393
if cfg.kind == p.STATICLIB then
@@ -1515,6 +1516,16 @@
15151516
end
15161517
end
15171518

1519+
function m.removeUnreferencedCodeData(cfg)
1520+
if cfg.removeUnreferencedCodeData ~= nil then
1521+
if cfg.removeUnreferencedCodeData then
1522+
m.element("RemoveUnreferencedCodeData", nil, "true")
1523+
else
1524+
m.element("RemoveUnreferencedCodeData", nil, "false")
1525+
end
1526+
end
1527+
end
1528+
15181529
function m.additionalCompileOptions(cfg, condition)
15191530
local opts = cfg.buildoptions
15201531
if _ACTION == "vs2015" or vstudio.isMakefile(cfg) then

src/_premake_init.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,12 @@
795795
kind = "boolean"
796796
}
797797

798+
api.register {
799+
name = "removeunreferencedcodedata",
800+
scope = "config",
801+
kind = "boolean"
802+
}
803+
798804
api.register {
799805
name = "swiftversion",
800806
scope = "config",
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Sets the `RemoveUnreferencedCodeData` property for a configuration or all configurations within a project or workspace, adding or removing the `/Zc:inline[-]` build option.
2+
3+
[/Zc:inline (Remove unreferenced COMDAT)](https://docs.microsoft.com/en-us/cpp/build/reference/zc-inline-remove-unreferenced-comdat?view=msvc-160)
4+
5+
If this property is unset, it defaults to `true` in Visual Studio.
6+
7+
```lua
8+
removeunreferencedcodedata ("value")
9+
```
10+
11+
### Parameters ###
12+
13+
`value` one of:
14+
* `on` - Enables `RemoveUnreferencedCodeData`.
15+
* `off` - Disables `RemoveUnreferencedCodeData`.
16+
17+
### Applies To ###
18+
19+
Workspaces and projects.
20+
21+
### Availability ###
22+
23+
Premake 5.0 alpha 16 or later.
24+
25+
### Examples ###
26+
27+
```lua
28+
RemoveUnreferencedCodeData "Off"
29+
```
30+

website/sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ module.exports = {
192192
'project',
193193
'propertydefinition',
194194
'rebuildcommands',
195+
'removeunreferencedcodedata',
195196
'resdefines',
196197
'resincludedirs',
197198
'resoptions',

0 commit comments

Comments
 (0)