Skip to content

Commit db340bf

Browse files
Clean external warnings native (#8948)
## Summary of changes Treat vendored spdlog/fmt headers as external in the native Windows projects and filter routine NuGet restore progress, while preserving warnings and errors. ## Reason for change Native compilation and package restore produced thousands of low-value lines. This is not expected to materially improve build time, but it makes CI logs easier to inspect and future optimizations easier to measure. ## Implementation details Use MSVC external include paths with `ExternalWarningLevel=TurnOffAllWarnings`, which generates `/external:W0`. Use a NUKE custom logger to suppress routine NuGet install, restore, add, and feed-probe messages. ## Test coverage Validated with repeated GitLab Windows builds: | Metric | Original | After warning + initial NuGet cleanup | Latest | | --- | ---: | ---: | ---: | | Lines | 17,699 | 7,894 | 3,585 | | Size | 2.55 MiB | 1.21 MiB | 0.46 MiB | | Targeted NuGet messages | 5,475 | 4,308 | 0 | | Compiler warnings | 1,036 | 116 | 116 | | Errors | 0 | 0 | 0 | The final log is approximately 80% shorter. The remaining compiler warnings originate in Datadog/PPDB code and remain visible as intended.
1 parent 0158624 commit db340bf

5 files changed

Lines changed: 34 additions & 9 deletions

File tree

profiler/Directory.Build.props

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@
188188
<DOTNET-TRACER-REPO-ROOT-PATH>$([System.IO.Path]::GetFullPath( $(EnlistmentRoot)/ ))</DOTNET-TRACER-REPO-ROOT-PATH>
189189
<SHARED-LIB-PATH>$(DOTNET-TRACER-REPO-ROOT-PATH)shared\src\native-lib\</SHARED-LIB-PATH>
190190
<CORECLR-PATH>$(SHARED-LIB-PATH)coreclr\src</CORECLR-PATH>
191-
<SHARED-LIB-INCLUDES>$(SHARED-LIB-PATH)fmt\include;$(SHARED-LIB-PATH)spdlog\include</SHARED-LIB-INCLUDES>
191+
<!-- Suppress warnings from vendored headers without suppressing warnings in Datadog code. -->
192+
<ExternalIncludePath>$(SHARED-LIB-PATH)fmt\include;$(SHARED-LIB-PATH)spdlog\include;$(ExternalIncludePath)</ExternalIncludePath>
192193
<!-- VCPKG setup -->
193194
<VcpkgEnableManifest>true</VcpkgEnableManifest>
194195
<VcpkgUseStatic>false</VcpkgUseStatic>
@@ -207,6 +208,7 @@
207208
PatchSpdlogFile in tracer/build/_build/UpdateVendors/VendoredDependency.cs).
208209
Defined here on Windows for consistency. -->
209210
<PreprocessorDefinitions>%(PreprocessorDefinitions);MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS=1;FMT_UNICODE=0;DD_SPDLOG_NO_MDC</PreprocessorDefinitions>
211+
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
210212
<BuildStlModules>false</BuildStlModules>
211213
<EnableModules>false</EnableModules>
212214
</ClCompile>

shared/src/Datadog.Trace.ClrProfiler.Native/Datadog.Trace.ClrProfiler.Native.vcxproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<DOTNET-TRACER-REPO-ROOT-PATH>..\..\..\</DOTNET-TRACER-REPO-ROOT-PATH>
4444
<SHARED-LIB-PATH>$(DOTNET-TRACER-REPO-ROOT-PATH)shared/src/native-lib/</SHARED-LIB-PATH>
4545
<LIB_INCLUDES>$(SHARED-LIB-PATH)coreclr\src\pal\prebuilt\inc</LIB_INCLUDES>
46-
<SHARED-LIB-INCLUDES>$(SHARED-LIB-PATH)spdlog\include</SHARED-LIB-INCLUDES>
46+
<ExternalIncludePath>$(SHARED-LIB-PATH)spdlog\include;$(ExternalIncludePath)</ExternalIncludePath>
4747
</PropertyGroup>
4848
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
4949
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -156,6 +156,8 @@
156156
</PropertyGroup>
157157
<ItemDefinitionGroup>
158158
<ClCompile>
159+
<!-- Suppress warnings from vendored headers without suppressing warnings in Datadog code. -->
160+
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
159161
<!-- spdlog 1.17 (and the bundled fmt 11+) need two build flags:
160162
- FMT_UNICODE=0: fmt 11+ static_asserts that narrow string literals are UTF-8.
161163
We don't compile with /utf-8 (would change the encoding of every narrow string in
@@ -390,4 +392,4 @@
390392
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
391393
<ImportGroup Label="ExtensionTargets">
392394
</ImportGroup>
393-
</Project>
395+
</Project>

tracer/build/_build/Build.Steps.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,24 @@ bool RequiresThoroughTesting()
294294
NuGetTasks.NuGetRestore(s => s
295295
.SetTargetPath(Solution)
296296
.SetVerbosity(NuGetVerbosity.Normal)
297-
.SetProcessLogOutput(!IsServerBuild)
297+
.SetProcessLogOutput(true)
298298
.When(!string.IsNullOrEmpty(NugetPackageDirectory), o =>
299-
o.SetPackagesDirectory(NugetPackageDirectory)));
299+
o.SetPackagesDirectory(NugetPackageDirectory))
300+
.When(IsServerBuild || IsGitlab, o =>
301+
o.SetProcessCustomLogger((type, text) =>
302+
{
303+
var trimmedText = text.TrimStart();
304+
if (!trimmedText.StartsWith("Installed ", StringComparison.Ordinal) &&
305+
!trimmedText.StartsWith("Restoring NuGet package ", StringComparison.Ordinal) &&
306+
!trimmedText.StartsWith("Adding package '", StringComparison.Ordinal) &&
307+
!trimmedText.StartsWith("Added package '", StringComparison.Ordinal) &&
308+
!trimmedText.StartsWith("GET ", StringComparison.Ordinal) &&
309+
!trimmedText.StartsWith("OK ", StringComparison.Ordinal) &&
310+
!trimmedText.StartsWith("NotFound ", StringComparison.Ordinal))
311+
{
312+
NuGetTasks.NuGetLogger(type, text);
313+
}
314+
})));
300315
}
301316
else
302317
{

tracer/src/Datadog.Tracer.Native/Datadog.Tracer.Native.DLL.vcxproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
<RootNamespace>DatadogTraceClrProfilerNativeDLL</RootNamespace>
4242
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
4343
<LIB_PATH>..\..\..\shared\src\native-lib\</LIB_PATH>
44-
<LIB_INCLUDES>$(LIB_PATH)spdlog\include;$(LIB_PATH)coreclr\src\pal\prebuilt\inc</LIB_INCLUDES>
44+
<LIB_INCLUDES>$(LIB_PATH)coreclr\src\pal\prebuilt\inc</LIB_INCLUDES>
45+
<ExternalIncludePath>$(LIB_PATH)spdlog\include;$(ExternalIncludePath)</ExternalIncludePath>
4546
</PropertyGroup>
4647
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
4748
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -142,6 +143,8 @@
142143
</PropertyGroup>
143144
<ItemDefinitionGroup>
144145
<ClCompile>
146+
<!-- Suppress warnings from vendored headers without suppressing warnings in Datadog code. -->
147+
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
145148
<!-- spdlog 1.17 (and the bundled fmt 11+) need two build flags:
146149
- FMT_UNICODE=0: fmt 11+ static_asserts that narrow string literals are UTF-8.
147150
We don't compile with /utf-8 (would change the encoding of every narrow string in
@@ -344,4 +347,4 @@
344347
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
345348
<ImportGroup Label="ExtensionTargets">
346349
</ImportGroup>
347-
</Project>
350+
</Project>

tracer/src/Datadog.Tracer.Native/Datadog.Tracer.Native.vcxproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
<CORECLR_PATH>..\..\..\shared\src\native-lib\coreclr</CORECLR_PATH>
4444
<ProjectName>Datadog.Tracer.Native</ProjectName>
4545
<LIB_PATH>..\..\..\shared\src\native-lib\</LIB_PATH>
46-
<LIB_INCLUDES>$(CORECLR_PATH)\src\pal\prebuilt\inc;$(CORECLR_PATH)\src\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath);$(LIB_PATH)spdlog\include</LIB_INCLUDES>
46+
<LIB_INCLUDES>$(CORECLR_PATH)\src\pal\prebuilt\inc;$(CORECLR_PATH)\src\inc;$(VC_IncludePath);$(WindowsSDK_IncludePath)</LIB_INCLUDES>
47+
<ExternalIncludePath>$(LIB_PATH)spdlog\include;$(ExternalIncludePath)</ExternalIncludePath>
4748
</PropertyGroup>
4849
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
4950
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -119,6 +120,8 @@
119120
</PropertyGroup>
120121
<ItemDefinitionGroup>
121122
<ClCompile>
123+
<!-- Suppress warnings from vendored headers without suppressing warnings in Datadog code. -->
124+
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
122125
<!-- spdlog 1.17 (and the bundled fmt 11+) need two build flags:
123126
- FMT_UNICODE=0: fmt 11+ static_asserts that narrow string literals are UTF-8.
124127
We don't compile with /utf-8 (would change the encoding of every narrow string in
@@ -417,4 +420,4 @@
417420
<ClCompile Include="tracer_tokens.cpp" />
418421
</ItemGroup>
419422
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
420-
</Project>
423+
</Project>

0 commit comments

Comments
 (0)