Skip to content

Commit 7927a19

Browse files
Delete .GuardCF library build (#110671)
Based on measurements on the ASP.NET perf infra (BasicWebApi and TodosApi), using the GuardCF libraries in non-guard context doesn't have measurable impact on throughput. The impact on size is negligible. We can just have it enabled unconditionally on the native runtime bits.
1 parent 43b89b4 commit 7927a19

File tree

12 files changed

+3
-127
lines changed

12 files changed

+3
-127
lines changed

src/coreclr/nativeaot/Bootstrap/base/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ set_target_properties(bootstrapper PROPERTIES OUTPUT_NAME bootstrapper)
99

1010
install_bootstrapper_object(bootstrapper aotsdk)
1111

12-
if (CLR_CMAKE_TARGET_WIN32)
13-
add_library(bootstrapper.GuardCF OBJECT ${SOURCES})
14-
install_bootstrapper_object(bootstrapper.GuardCF aotsdk)
15-
set_target_properties(bootstrapper.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON)
16-
else()
12+
if (CLR_CMAKE_HOST_UNIX)
1713
add_library(stdc++compat STATIC ../stdcppshim.cpp)
1814
install_static_library(stdc++compat aotsdk nativeaot)
1915
endif()

src/coreclr/nativeaot/Bootstrap/dll/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,3 @@ set(SOURCES
99
add_library(bootstrapperdll STATIC ${SOURCES})
1010

1111
install_bootstrapper_object(bootstrapperdll aotsdk)
12-
13-
if (CLR_CMAKE_TARGET_WIN32)
14-
add_library(bootstrapperdll.GuardCF STATIC ${SOURCES})
15-
install_bootstrapper_object(bootstrapperdll.GuardCF aotsdk)
16-
set_target_properties(bootstrapperdll.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON)
17-
endif()

src/coreclr/nativeaot/Bootstrap/dllmain/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,3 @@ set(SOURCES
77
add_library(dllmain STATIC ${SOURCES})
88

99
install_bootstrapper_object(dllmain aotsdk)
10-
11-
add_library(dllmain.GuardCF STATIC ${SOURCES})
12-
install_bootstrapper_object(dllmain.GuardCF aotsdk)
13-
set_target_properties(dllmain.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON)

src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Windows.targets

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ The .NET Foundation licenses this file to you under the MIT license.
1818
<CppLibCreator>lib</CppLibCreator>
1919
<ObjectSuffix>.obj</ObjectSuffix>
2020
<LibrarySuffix>.lib</LibrarySuffix>
21-
<ObjectSuffix Condition="'$(ControlFlowGuard)' == 'Guard'">.GuardCF.obj</ObjectSuffix>
22-
<LibrarySuffix Condition="'$(ControlFlowGuard)' == 'Guard'">.GuardCF.lib</LibrarySuffix>
2321
<FullRuntimeName>Runtime.WorkstationGC</FullRuntimeName>
24-
<FullRuntimeName Condition="'$(ServerGarbageCollection)' == 'true' or '$(IlcLinkServerGC)' == 'true' or '$(ControlFlowGuard)' == 'Guard'">Runtime.ServerGC</FullRuntimeName>
22+
<FullRuntimeName Condition="'$(ServerGarbageCollection)' == 'true' or '$(IlcLinkServerGC)' == 'true'">Runtime.ServerGC</FullRuntimeName>
2523
<BootstrapperName>bootstrapper</BootstrapperName>
2624
<BootstrapperName Condition="'$(NativeLib)' != '' or '$(CustomNativeMain)' == 'true'">bootstrapperdll</BootstrapperName>
2725
<VxSortSupportName>Runtime.VxsortEnabled</VxSortSupportName>
28-
<VxSortSupportName Condition="'$(ControlFlowGuard)' != 'Guard' and ('$(OptimizationPreference)' == 'Size' or '$(IlcDisableVxsort)' == 'true')">Runtime.VxsortDisabled</VxSortSupportName>
26+
<VxSortSupportName Condition="'$(OptimizationPreference)' == 'Size' or '$(IlcDisableVxsort)' == 'true'">Runtime.VxsortDisabled</VxSortSupportName>
2927
<StandaloneGCSupportName>standalonegc-disabled</StandaloneGCSupportName>
3028
<StandaloneGCSupportName Condition="'$(IlcStandaloneGCSupport)' == 'true'">standalonegc-enabled</StandaloneGCSupportName>
3129
<EntryPointSymbol Condition="'$(EntryPointSymbol)' == ''">wmainCRTStartup</EntryPointSymbol>

src/coreclr/nativeaot/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ endif (WIN32)
55

66
if(MSVC)
77
set_property(DIRECTORY PROPERTY CLR_EH_OPTION /EHa-s-) # Native AOT runtime does not use C++ exception handling
8-
set_property(DIRECTORY PROPERTY CLR_CONTROL_FLOW_GUARD OFF)
98

109
# The code generated by the Native AOT compiler doesn't work with Link Time Code Generation
1110
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)

src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,6 @@ endif (CLR_CMAKE_TARGET_ARCH_AMD64)
5151
target_compile_definitions(Runtime.ServerGC PRIVATE -DFEATURE_SVR_GC)
5252

5353
if (CLR_CMAKE_TARGET_WIN32)
54-
add_library(standalonegc-disabled.GuardCF STATIC ${STANDALONEGC_DISABLED_SOURCES})
55-
set_target_properties(standalonegc-disabled.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON)
56-
add_dependencies(standalonegc-disabled.GuardCF aot_eventing_headers)
57-
add_dependencies(standalonegc-disabled.GuardCF aot_etw_headers)
58-
add_library(standalonegc-enabled.GuardCF STATIC ${STANDALONEGC_ENABLED_SOURCES})
59-
set_target_properties(standalonegc-enabled.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON)
60-
add_dependencies(standalonegc-enabled.GuardCF aot_eventing_headers)
61-
add_dependencies(standalonegc-enabled.GuardCF aot_etw_headers)
62-
add_library(Runtime.ServerGC.GuardCF STATIC ${COMMON_RUNTIME_SOURCES} ${FULL_RUNTIME_SOURCES} ${RUNTIME_SOURCES_ARCH_ASM} ${SERVER_GC_SOURCES} ${RUNTIME_ARCH_ASM_OBJECTS})
63-
target_compile_definitions(Runtime.ServerGC.GuardCF PRIVATE -DFEATURE_SVR_GC)
64-
set_target_properties(Runtime.ServerGC.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON)
65-
target_link_libraries(Runtime.ServerGC.GuardCF PRIVATE aotminipal)
66-
67-
if (CLR_CMAKE_TARGET_ARCH_AMD64)
68-
add_library(Runtime.VxsortEnabled.GuardCF STATIC ${VXSORT_SOURCES})
69-
set_target_properties(Runtime.VxsortEnabled.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON)
70-
endif (CLR_CMAKE_TARGET_ARCH_AMD64)
71-
7254
set_target_properties(aotminipal PROPERTIES
7355
COMPILE_PDB_NAME "aotminipal"
7456
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>")
@@ -115,25 +97,13 @@ add_custom_target(
11597

11698
add_dependencies(Runtime.WorkstationGC RuntimeAsmHelpers)
11799
add_dependencies(Runtime.ServerGC RuntimeAsmHelpers)
118-
if (CLR_CMAKE_TARGET_WIN32)
119-
add_dependencies(Runtime.ServerGC.GuardCF RuntimeAsmHelpers)
120-
endif (CLR_CMAKE_TARGET_WIN32)
121100

122101
install_static_library(Runtime.WorkstationGC aotsdk nativeaot)
123102
install_static_library(Runtime.ServerGC aotsdk nativeaot)
124103
install_static_library(standalonegc-disabled aotsdk nativeaot)
125104
install_static_library(standalonegc-enabled aotsdk nativeaot)
126105
install_static_library(aotminipal aotsdk nativeaot)
127-
if (CLR_CMAKE_TARGET_WIN32)
128-
install_static_library(Runtime.ServerGC.GuardCF aotsdk nativeaot)
129-
add_dependencies(Runtime.ServerGC.GuardCF aot_eventing_headers)
130-
install_static_library(standalonegc-disabled.GuardCF aotsdk nativeaot)
131-
install_static_library(standalonegc-enabled.GuardCF aotsdk nativeaot)
132-
endif (CLR_CMAKE_TARGET_WIN32)
133106
if (CLR_CMAKE_TARGET_ARCH_AMD64)
134107
install_static_library(Runtime.VxsortEnabled aotsdk nativeaot)
135108
install_static_library(Runtime.VxsortDisabled aotsdk nativeaot)
136-
if (CLR_CMAKE_TARGET_WIN32)
137-
install_static_library(Runtime.VxsortEnabled.GuardCF aotsdk nativeaot)
138-
endif (CLR_CMAKE_TARGET_WIN32)
139109
endif (CLR_CMAKE_TARGET_ARCH_AMD64)

src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -168,26 +168,11 @@ set_target_properties(eventpipe-shared-objects PROPERTIES
168168
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>"
169169
)
170170
if (CLR_CMAKE_TARGET_WIN32)
171-
add_library(eventpipe-shared-objects.GuardCF OBJECT)
172-
target_link_libraries(eventpipe-shared-objects.GuardCF PRIVATE dn-diagnosticserver dn-eventpipe dn-diagnosticserver-pal)
173-
174171
target_compile_options(eventpipe-shared-objects PRIVATE
175172
"/FI${RUNTIME_DIR}/eventpipe/NativeaotEventPipeSupport.h")
176173

177-
target_compile_options(eventpipe-shared-objects.GuardCF PRIVATE
178-
"/FI${RUNTIME_DIR}/eventpipe/NativeaotEventPipeSupport.h")
179-
180-
# Build EventPipe and DiagnosticServer as unity-builds for better inlining.
181-
set_target_properties(eventpipe-shared-objects.GuardCF PROPERTIES
182-
UNITY_BUILD ON
183-
UNITY_BUILD_BATCH_SIZE 0
184-
CLR_CONTROL_FLOW_GUARD ON
185-
COMPILE_PDB_NAME "eventpipe-shared-objects.GuardCF"
186-
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>")
187-
188174
# Install the compile PDB for the eventpipe unity builds.
189175
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/eventpipe-shared-objects.pdb" DESTINATION aotsdk COMPONENT nativeaot)
190-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/eventpipe-shared-objects.GuardCF.pdb" DESTINATION aotsdk COMPONENT nativeaot)
191176
# For the container library, we need to produce a compile PDB and install it
192177
set_target_properties(dn-containers-no-lto PROPERTIES
193178
COMPILE_PDB_NAME "dn-containers"
@@ -222,20 +207,5 @@ endif()
222207
add_library(eventpipe-disabled STATIC ${AOT_EVENTPIPE_DISABLED_SOURCES})
223208
add_dependencies(eventpipe-disabled aot_eventing_headers)
224209

225-
if (CLR_CMAKE_TARGET_WIN32)
226-
add_library(eventpipe-enabled.GuardCF STATIC ${EVENTPIPE_SOURCES})
227-
target_link_libraries(eventpipe-enabled.GuardCF PRIVATE eventpipe-shared-objects.GuardCF dn-containers-no-lto)
228-
add_dependencies(eventpipe-enabled.GuardCF aot_eventing_headers)
229-
add_dependencies(eventpipe-enabled.GuardCF aot_etw_headers)
230-
add_library(eventpipe-disabled.GuardCF STATIC ${AOT_EVENTPIPE_DISABLED_SOURCES})
231-
add_dependencies(eventpipe-disabled.GuardCF aot_eventing_headers)
232-
set_target_properties(eventpipe-enabled.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON)
233-
set_target_properties(eventpipe-disabled.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON)
234-
endif (CLR_CMAKE_TARGET_WIN32)
235-
236210
install_static_library(eventpipe-enabled aotsdk nativeaot)
237211
install_static_library(eventpipe-disabled aotsdk nativeaot)
238-
if (CLR_CMAKE_TARGET_WIN32)
239-
install_static_library(eventpipe-enabled.GuardCF aotsdk nativeaot)
240-
install_static_library(eventpipe-disabled.GuardCF aotsdk nativeaot)
241-
endif (CLR_CMAKE_TARGET_WIN32)

src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,29 +150,18 @@
150150
<PlatformManifestFileEntry Include="libstdc++compat.a" IsNative="true" />
151151
<!-- NativeAOT/Windows specific files -->
152152
<PlatformManifestFileEntry Include="bootstrapper.obj" IsNative="true" />
153-
<PlatformManifestFileEntry Include="bootstrapper.GuardCF.obj" IsNative="true" />
154153
<PlatformManifestFileEntry Include="bootstrapperdll.obj" IsNative="true" />
155-
<PlatformManifestFileEntry Include="bootstrapperdll.GuardCF.obj" IsNative="true" />
156154
<PlatformManifestFileEntry Include="dllmain.obj" IsNative="true" />
157-
<PlatformManifestFileEntry Include="dllmain.GuardCF.obj" IsNative="true" />
158155
<PlatformManifestFileEntry Include="eventpipe-disabled.lib" IsNative="true" />
159-
<PlatformManifestFileEntry Include="eventpipe-disabled.GuardCF.lib" IsNative="true" />
160156
<PlatformManifestFileEntry Include="eventpipe-enabled.lib" IsNative="true" />
161-
<PlatformManifestFileEntry Include="eventpipe-enabled.GuardCF.lib" IsNative="true" />
162157
<PlatformManifestFileEntry Include="Runtime.ServerGC.lib" IsNative="true" />
163-
<PlatformManifestFileEntry Include="Runtime.ServerGC.GuardCF.lib" IsNative="true" />
164158
<PlatformManifestFileEntry Include="Runtime.WorkstationGC.lib" IsNative="true" />
165159
<PlatformManifestFileEntry Include="Runtime.VxsortEnabled.lib" IsNative="true" />
166-
<PlatformManifestFileEntry Include="Runtime.VxsortEnabled.GuardCF.lib" IsNative="true" />
167160
<PlatformManifestFileEntry Include="Runtime.VxsortDisabled.lib" IsNative="true" />
168161
<PlatformManifestFileEntry Include="standalonegc-disabled.lib" IsNative="true" />
169-
<PlatformManifestFileEntry Include="standalonegc-disabled.GuardCF.lib" IsNative="true" />
170162
<PlatformManifestFileEntry Include="standalonegc-enabled.lib" IsNative="true" />
171-
<PlatformManifestFileEntry Include="standalonegc-enabled.GuardCF.lib" IsNative="true" />
172163
<PlatformManifestFileEntry Include="System.Globalization.Native.Aot.lib" IsNative="true" />
173-
<PlatformManifestFileEntry Include="System.Globalization.Native.Aot.GuardCF.lib" IsNative="true" />
174164
<PlatformManifestFileEntry Include="System.IO.Compression.Native.Aot.lib" IsNative="true" />
175-
<PlatformManifestFileEntry Include="System.IO.Compression.Native.Aot.GuardCF.lib" IsNative="true" />
176165
<PlatformManifestFileEntry Include="aotminipal.lib" IsNative="true" />
177166
<!-- NativeAOT managed specific files -->
178167
<PlatformManifestFileEntry Include="System.Private.Reflection.Execution.dll" />

src/native/libs/System.Globalization.Native/CMakeLists.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,7 @@ if(CLR_CMAKE_TARGET_WIN32)
212212
STATIC
213213
${NATIVEGLOBALIZATION_SOURCES}
214214
)
215-
set_target_properties(System.Globalization.Native.Aot PROPERTIES CLR_CONTROL_FLOW_GUARD OFF)
216215
set_target_properties(System.Globalization.Native.Aot PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
217-
218-
add_library(System.Globalization.Native.Aot.GuardCF
219-
STATIC
220-
${NATIVEGLOBALIZATION_SOURCES}
221-
)
222-
set_target_properties(System.Globalization.Native.Aot.GuardCF PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
223-
224216
install_static_library(System.Globalization.Native.Aot aotsdk nativeaot)
225-
install_static_library(System.Globalization.Native.Aot.GuardCF aotsdk nativeaot)
226217
endif()
227218
endif()

src/native/libs/System.IO.Compression.Native/CMakeLists.txt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -163,23 +163,7 @@ else ()
163163

164164
target_include_directories(System.IO.Compression.Native.Aot PUBLIC ${BROTLI_INCLUDE_DIRS})
165165
target_link_libraries(System.IO.Compression.Native.Aot PUBLIC ${BROTLI_LIBRARIES})
166-
167-
set_target_properties(System.IO.Compression.Native.Aot PROPERTIES CLR_CONTROL_FLOW_GUARD OFF)
168166
set_target_properties(System.IO.Compression.Native.Aot PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
169-
170-
add_library(System.IO.Compression.Native.Aot.GuardCF
171-
STATIC
172-
${NATIVECOMPRESSION_SOURCES}
173-
)
174-
175-
if (NOT CLR_CMAKE_USE_SYSTEM_ZLIB)
176-
target_link_libraries(System.IO.Compression.Native.Aot.GuardCF PRIVATE zlibstatic)
177-
endif()
178-
179-
target_include_directories(System.IO.Compression.Native.Aot.GuardCF PUBLIC ${BROTLI_INCLUDE_DIRS})
180-
target_link_libraries(System.IO.Compression.Native.Aot.GuardCF PUBLIC ${BROTLI_LIBRARIES})
181-
182-
set_target_properties(System.IO.Compression.Native.Aot.GuardCF PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
183167
endif()
184168

185169
if (GEN_SHARED_LIB)
@@ -196,7 +180,6 @@ else ()
196180

197181
if(STATIC_LIBS_ONLY)
198182
install_static_library(System.IO.Compression.Native.Aot aotsdk nativeaot)
199-
install_static_library(System.IO.Compression.Native.Aot.GuardCF aotsdk nativeaot)
200183
foreach(BROTLI_LIB ${BROTLI_LIBRARIES})
201184
# Brotli's build scripts can add some system dependencies like libm
202185
# to BROTLI_LIBRARIES. Only install the libraries that are actually

src/tests/tracing/eventpipe/randomizedallocationsampling/allocationsampling.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
<DisableProjectBuild Condition="'$(RuntimeFlavor)' == 'mono'">true</DisableProjectBuild>
1313
</PropertyGroup>
1414

15-
<!-- Test coverage for EventPipe CFG library, eventpipe-enabled.GuardCF.lib -->
16-
<PropertyGroup Condition="'$(TestBuildMode)' == 'nativeaot' and '$(TargetsWindows)' == 'true'">
17-
<ControlFlowGuard>guard</ControlFlowGuard>
18-
</PropertyGroup>
19-
2015
<ItemGroup>
2116
<Compile Include="$(MSBuildProjectName).cs" />
2217
<ProjectReference Include="../common/eventpipe_common.csproj" />

src/tests/tracing/eventpipe/simpleruntimeeventvalidation/simpleruntimeeventvalidation.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
<JitOptimizationSensitive>true</JitOptimizationSensitive>
1111
</PropertyGroup>
1212

13-
<!-- Test coverage for EventPipe CFG library, eventpipe-enabled.GuardCF.lib -->
14-
<PropertyGroup Condition="'$(TestBuildMode)' == 'nativeaot' and '$(TargetsWindows)' == 'true'">
15-
<ControlFlowGuard>guard</ControlFlowGuard>
16-
</PropertyGroup>
17-
1813
<ItemGroup>
1914
<Compile Include="$(MSBuildProjectName).cs" />
2015
<ProjectReference Include="../common/eventpipe_common.csproj" />

0 commit comments

Comments
 (0)