Skip to content

Commit 09cbef5

Browse files
committed
Include windows.h before ORT's CUB wrapper undefines the MSVC SAL __out macro.
CUDA 13 CCCL headers use __out as a parameter name in generated PTX helpers. If Windows/SAL headers are included later while cub.cuh is being parsed, __out can be redefined and expanded away, producing invalid code such as "=r"( [0]). Preloading windows.h lets the existing ORT wrapper undefine __out for the full CUB/CCCL include.
1 parent a2ff388 commit 09cbef5

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

onnxruntime/cppbuild.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@ sedinplace 's/-fvisibility=hidden//g' cmake/CMakeLists.txt cmake/adjust_global_c
133133
sedinplace 's:/Yucuda_pch.h /FIcuda_pch.h::g' cmake/onnxruntime_providers_cuda.cmake cmake/onnxruntime_providers.cmake
134134
#sedinplace 's/${PROJECT_SOURCE_DIR}\/external\/cub//g' cmake/onnxruntime_providers_cuda.cmake cmake/onnxruntime_providers.cmake
135135
sedinplace 's/-Xcompiler \/Zc:__cplusplus/-Xcompiler \/Zc:__cplusplus -Xcompiler \/Zc:preprocessor/g' cmake/onnxruntime_providers_cuda.cmake cmake/onnxruntime_providers_cuda_plugin.cmake
136+
sedinplace '/#include <sal.h>/i\
137+
#ifndef WIN32_LEAN_AND_MEAN\
138+
#define WIN32_LEAN_AND_MEAN\
139+
#endif\
140+
#ifndef NOMINMAX\
141+
#define NOMINMAX\
142+
#endif\
143+
#include <windows.h>
144+
' onnxruntime/core/providers/cuda/cu_inc/cub.cuh
136145
sedinplace '/CXX>:\/permissive/a\
137146
"$<$<COMPILE_LANGUAGE:CXX>:/Zc:preprocessor>"
138147
' cmake/onnxruntime_providers_cuda.cmake cmake/onnxruntime_providers_cuda_plugin.cmake

0 commit comments

Comments
 (0)