Skip to content

[SYCL][CMAKE] Only apply extra warnings to SYCL RT #19306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: sycl
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions llvm/cmake/modules/AddSecurityFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,21 @@ endif()

macro(append_common_extra_security_flags)
# Compiler Warnings and Error Detection
# Note: in intel/llvm we build both linux and win with --ci-defaults.
# This flag also enables -Werror or /WX.
if(is_gcc
OR is_clang
OR (is_icpx AND MSVC))
add_compile_option_ext("-Wall" WALL)
add_compile_option_ext("-Wextra" WEXTRA)
elseif(is_icpx)
add_compile_option_ext("/Wall" WALL)
elseif(is_msvc)
add_compile_option_ext("/W4" WALL)
endif()

if(CMAKE_BUILD_TYPE MATCHES "Release")
if(is_gcc
OR is_clang
OR (is_icpx AND MSVC))
add_compile_option_ext("-Wconversion" WCONVERSION)
add_compile_option_ext("-Wimplicit-fallthrough" WIMPLICITFALLTHROUGH)
endif()
endif()
# Any flags applied here will be applied globally to all LLVM sub-projects.
# Since LLVM itself is not warning-free, enabling any extra warnings globally
# will most likely cause -Werror build to fail. Therefore, any necessary
# warnings should be enabled on a per-project basis.
# Things that we care about:
# - sycl
# - sycl-jit
# - unified-runtime
# - xpti
# - xptifw
# - SYCL-specific passes in LLVM (SYCLLowerIR, sycl-post-link, etc.)
# - SYCL-specific files in clang (SemaSYCL.cpp, etc.)
# The list above may not be complete and it is given for reference in case
# someone needs to enable more flags. There is also no guarantee that all
# sub-projects above already use all necessary flags uniformly.

# Control Flow Integrity
if(is_gcc
Expand Down
20 changes: 20 additions & 0 deletions sycl/source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ if (SYCL_ENABLE_XPTI_TRACING)
include_directories(${LLVM_EXTERNAL_XPTI_SOURCE_DIR}/include)
endif()

if(is_gcc
OR is_clang
OR (is_icpx AND MSVC))
add_compile_option_ext("-Wall" WALL)
add_compile_option_ext("-Wextra" WEXTRA)
elseif(is_icpx)
add_compile_option_ext("/Wall" WALL)
elseif(is_msvc)
add_compile_option_ext("/W4" WALL)
endif()

if(CMAKE_BUILD_TYPE MATCHES "Release")
if(is_gcc
OR is_clang
OR (is_icpx AND MSVC))
add_compile_option_ext("-Wconversion" WCONVERSION)
add_compile_option_ext("-Wimplicit-fallthrough" WIMPLICITFALLTHROUGH)
endif()
endif()

function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME)
# Add an optional argument so we can get the library name to
# link with for Windows Debug version
Expand Down
Loading