Skip to content

Commit 1088c23

Browse files
authored
Merge pull request #8 from Devsh-Graphics-Programming/etw-optional
Make Event Tracing for Windows optional
2 parents 4621c70 + 96a5b5c commit 1088c23

File tree

14 files changed

+80
-14
lines changed

14 files changed

+80
-14
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ mark_as_advanced(DXC_DISABLE_ALLOCATOR_OVERRIDES)
100100
option(DXC_CODEGEN_EXCEPTIONS_TRAP "An exception in code generation generates a trap, ending the compiler process" OFF)
101101
mark_as_advanced(DXC_CODEGEN_EXCEPTIONS_TRAP)
102102

103+
option(DXC_ENABLE_ETW "Compile with ETW Tracing" ON)
104+
mark_as_advanced(DXC_ENABLE_ETW)
105+
106+
if(DXC_ENABLE_ETW)
107+
add_compile_definitions(DXC_ENABLE_ETW)
108+
endif()
109+
103110
# adjust link option to enable debugging from kernel mode; not compatible with incremental linking
104111
if(NOT CMAKE_VERSION VERSION_LESS "3.13" AND MSVC AND NOT CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "ARM64EC")
105112
add_link_options(/DEBUGTYPE:CV,FIXUP,PDATA /INCREMENTAL:NO)

include/dxc/WinAdapter.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,8 @@
198198
#define OutputDebugStringA(msg) fputs(msg, stderr)
199199
#define OutputDebugFormatA(...) fprintf(stderr, __VA_ARGS__)
200200

201-
// Event Tracing for Windows (ETW) provides application programmers the ability
202-
// to start and stop event tracing sessions, instrument an application to
203-
// provide trace events, and consume trace events.
204-
#define DxcEtw_DXCompilerCreateInstance_Start()
205-
#define DxcEtw_DXCompilerCreateInstance_Stop(hr)
206-
#define DxcEtw_DXCompilerCompile_Start()
207-
#define DxcEtw_DXCompilerCompile_Stop(hr)
208-
#define DxcEtw_DXCompilerDisassemble_Start()
209-
#define DxcEtw_DXCompilerDisassemble_Stop(hr)
210-
#define DxcEtw_DXCompilerPreprocess_Start()
211-
#define DxcEtw_DXCompilerPreprocess_Stop(hr)
212-
#define DxcEtw_DxcValidation_Start()
213-
#define DxcEtw_DxcValidation_Stop(hr)
201+
// I have no idea if I don't break something like INSTALL targets, requires CI tests
202+
#include "WinEtwAdapter.h"
214203

215204
#define UInt32Add UIntAdd
216205
#define Int32ToUInt32 IntToUInt

include/dxc/WinEtwAdapter.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//===- WinEtwAdapter.h - Windows ETW Adapter, stub -*- C++ -*-===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is distributed under the University of Illinois Open Source
6+
// License. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef LLVM_SUPPORT_WIN_ETW_ADAPTER_H
11+
#define LLVM_SUPPORT_WIN_ETW_ADAPTER_H
12+
13+
// Event Tracing for Windows (ETW) provides application programmers the ability
14+
// to start and stop event tracing sessions, instrument an application to
15+
// provide trace events, and consume trace events.
16+
#define EventRegisterMicrosoft_Windows_DXCompiler_API()
17+
#define EventUnregisterMicrosoft_Windows_DXCompiler_API()
18+
#define DxcEtw_DXCompilerCreateInstance_Start()
19+
#define DxcEtw_DXCompilerCreateInstance_Stop(hr)
20+
#define DxcEtw_DXCompilerInitialization_Start()
21+
#define DxcEtw_DXCompilerInitialization_Stop(hr)
22+
#define DxcEtw_DXCompilerShutdown_Start()
23+
#define DxcEtw_DXCompilerShutdown_Stop(hr)
24+
#define DxcEtw_DXCompilerCompile_Start()
25+
#define DxcEtw_DXCompilerCompile_Stop(hr)
26+
#define DxcEtw_DXCompilerDisassemble_Start()
27+
#define DxcEtw_DXCompilerDisassemble_Stop(hr)
28+
#define DxcEtw_DXCompilerPreprocess_Start()
29+
#define DxcEtw_DXCompilerPreprocess_Stop(hr)
30+
#define DxcEtw_DxcValidation_Start()
31+
#define DxcEtw_DxcValidation_Stop(hr)
32+
33+
#endif // LLVM_SUPPORT_WIN_ETW_ADAPTER_H

projects/dxilconv/tools/dxilconv/dxilconv.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
#include "dxc/config.h"
2424
#include "dxc/dxcisense.h"
2525
#include "dxc/dxctools.h"
26+
#ifdef DXC_ENABLE_ETW
2627
#include "dxcetw.h"
28+
#else
29+
#include "dxc/WinEtwAdapter.h"
30+
#endif // DXC_ENABLE_ETW
2731

2832
#include "DxbcConverter.h"
2933

tools/clang/tools/dxcompiler/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ endif (MSVC)
128128

129129
add_clang_library(dxcompiler SHARED ${SOURCES})
130130
add_dependencies(dxcompiler TablegenHLSLOptions)
131-
if (MSVC)
131+
132+
if (MSVC AND DXC_ENABLE_ETW)
132133
# No DxcEtw on non-Windows platforms.
133134
add_dependencies(dxcompiler DxcEtw)
134135
endif()

tools/clang/tools/dxcompiler/DXCompiler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
#include "llvm/Support/FileSystem.h"
1818
#include "llvm/Support/ManagedStatic.h"
1919
#ifdef LLVM_ON_WIN32
20+
#ifdef DXC_ENABLE_ETW
2021
#include "dxcetw.h"
22+
#else
23+
#include "dxc/WinEtwAdapter.h"
24+
#endif // DXC_ENABLE_ETW
2125
#endif
2226
#include "dxillib.h"
2327

tools/clang/tools/dxcompiler/DXCompiler.rc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@
1111
#define VER_ORIGINALFILENAME_STR "DXCompiler.dll"
1212

1313
// #include <common.ver>
14+
#ifdef DXC_ENABLE_ETW
1415
#include "dxcetw.rc"
16+
#endif

tools/clang/tools/dxcompiler/dxcapi.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
#include "dxc/dxcisense.h"
2323
#include "dxc/dxctools.h"
2424
#ifdef _WIN32
25+
#ifdef DXC_ENABLE_ETW
2526
#include "dxcetw.h"
27+
#else
28+
#include "dxc/WinEtwAdapter.h"
29+
#endif // DXC_ENABLE_ETW
2630
#endif
2731
#include "dxc/DxilContainer/DxcContainerBuilder.h"
2832
#include "dxillib.h"

tools/clang/tools/dxcompiler/dxcompilerobj.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@
5151
#include "dxc/Support/microcom.h"
5252

5353
#ifdef _WIN32
54+
#ifdef DXC_ENABLE_ETW
5455
#include "dxcetw.h"
56+
#else
57+
#include "dxc/WinEtwAdapter.h"
58+
#endif // DXC_ENABLE_ETW
5559
#endif
5660
#include "dxcompileradapter.h"
5761
#include "dxcshadersourceinfo.h"

tools/clang/tools/dxcvalidator/dxcvalidator.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
#include "dxc/Support/dxcapi.impl.h"
2828

2929
#ifdef _WIN32
30+
#ifdef DXC_ENABLE_ETW
3031
#include "dxcetw.h"
32+
#else
33+
#include "dxc/WinEtwAdapter.h"
34+
#endif // DXC_ENABLE_ETW
3135
#endif
3236

3337
using namespace llvm;

tools/clang/tools/dxildll/dxildll.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@
2323
#include "llvm/Support/ManagedStatic.h"
2424
#include <algorithm>
2525
#ifdef _WIN32
26+
#ifdef DXC_ENABLE_ETW
2627
#include "Tracing/DxcRuntimeEtw.h"
2728
#include "dxc/Tracing/dxcetw.h"
29+
#else
30+
#include "dxc/WinEtwAdapter.h"
31+
#endif // DXC_ENABLE_ETW
2832
#endif
2933

3034
#include "dxc/dxcisense.h"

tools/clang/tools/dxrfallbackcompiler/DXCompiler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
#include "dxc/Support/Global.h"
1515
#include "dxc/Support/HLSLOptions.h"
1616
#include "dxc/config.h"
17+
#ifdef DXC_ENABLE_ETW
1718
#include "dxcetw.h"
19+
#else
20+
#include "dxc/WinEtwAdapter.h"
21+
#endif // DXC_ENABLE_ETW
1822
#include "dxillib.h"
1923
#include "llvm/Support/FileSystem.h"
2024
#include "llvm/Support/ManagedStatic.h"

tools/clang/tools/dxrfallbackcompiler/DXCompiler.rc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@
1111
#define VER_ORIGINALFILENAME_STR "DxrFallbackCompiler.dll"
1212

1313
// #include <common.ver>
14+
#ifdef DXC_ENABLE_ETW
1415
#include "dxcetw.rc"
16+
#endif

tools/clang/tools/dxrfallbackcompiler/dxcapi.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
#include "dxc/Support/Global.h"
1717
#include "dxc/dxcdxrfallbackcompiler.h"
1818
#include "dxc/dxctools.h"
19+
#ifdef DXC_ENABLE_ETW
1920
#include "dxcetw.h"
21+
#else
22+
#include "dxc/WinEtwAdapter.h"
23+
#endif // DXC_ENABLE_ETW
2024
#include <memory>
2125

2226
HRESULT CreateDxcDxrFallbackCompiler(REFIID riid, LPVOID *ppv);

0 commit comments

Comments
 (0)