mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-23 19:32:23 +00:00
[Build] fix: missing nvcc flags when compiling with unittests (#19308)
When configured using the following CMake ops Clion is not able to configure due to checking with `nvcc ... --dryrun tmp.cu`: ``` cmake -G Ninja -Donnxruntime_USE_TENSORRT="ON" -Donnxruntime_USE_CUDA="ON" -Donnxruntime_USE_CUDA_NHWC_OPS="ON" -DCMAKE_CUDA_ARCHITECTURES="native" -Donnxruntime_NVCC_THREADS=1 -Donnxruntime_ENABLE_NVTX_PROFILE="ON" -Donnxruntime_USE_TENSORRT_BUILTIN_PARSER="ON" -DCMAKE_CUDA_COMPILER_LAUNCHER="ccache" -Donnxruntime_BUILD_UNIT_TESTS="ON" -Donnxruntime_USE_TRITON_KERNEL=OFF -Donnxruntime_USE_FLASH_ATTENTION=OFF ``` Without building the unittests everything works fine. I believe my changes only follow the logic that is actually desired. If `NVCC_HAS_STRICT_ALIASING` is set to false it should not be possible to add this as a CUDA flag. Same is true for `HAS_NOERROR` as seen in `adjust_global_compile_flags.cmake`
This commit is contained in:
parent
df5c6718bd
commit
91b2e660fe
2 changed files with 7 additions and 2 deletions
|
|
@ -985,9 +985,12 @@ function(onnxruntime_set_compile_flags target_name)
|
|||
foreach(FLAG ${ORT_WARNING_FLAGS})
|
||||
target_compile_options(${target_name} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options ${FLAG}>")
|
||||
endforeach()
|
||||
if ((NVCC_HAS_STRICT_ALIASING AND "${target_name}" MATCHES "cuda") OR (HAS_STRICT_ALIASING AND NOT "${target_name}" MATCHES "cuda"))
|
||||
if (NVCC_HAS_STRICT_ALIASING AND "${target_name}" MATCHES "cuda")
|
||||
target_compile_options(${target_name} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:-Wno-strict-aliasing>")
|
||||
endif()
|
||||
if (HAS_STRICT_ALIASING AND NOT "${target_name}" MATCHES "cuda")
|
||||
target_compile_options(${target_name} PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-Wno-strict-aliasing>")
|
||||
endif()
|
||||
endif()
|
||||
if (onnxruntime_USE_ROCM)
|
||||
# flags are detected with CXX language mode, some flags are not supported with hipclang
|
||||
|
|
|
|||
|
|
@ -111,7 +111,9 @@ function(AddTest)
|
|||
target_compile_options(${_UT_TARGET} PRIVATE ${DISABLED_WARNINGS_FOR_TVM})
|
||||
target_compile_options(${_UT_TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options -Wno-error=sign-compare>"
|
||||
"$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:-Wno-error=sign-compare>")
|
||||
target_compile_options(${_UT_TARGET} PRIVATE "-Wno-error=uninitialized")
|
||||
if (${HAS_NOERROR})
|
||||
target_compile_options(${_UT_TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-Wno-error=uninitialized>")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(TEST_ARGS ${_UT_TEST_ARGS})
|
||||
|
|
|
|||
Loading…
Reference in a new issue