From 947dbe82fb800801ccbc053c9b4b2e994d734dc8 Mon Sep 17 00:00:00 2001 From: Vlad Sytchenko Date: Mon, 15 Jun 2020 15:17:10 -0400 Subject: [PATCH] Enable the use of some warnings when building ROCclr Enabling anything beyond -Wall like -Wextra or -pedantic seems impossible as our code base explodes in thousands of warnings. -Wno-unused-{variable/function} is not present in the p4 build, but with gcc7.4.0 we get hundreds of instances of this warning being triggered in the code base. With this change only two warnings show up during the build - -Wsequence-point and -Wunused-but-set-variable. The fix for the first is alredy in review. Change-Id: I2ff37981377487b0e07fd9490498e38a60792c0c --- rocclr/CMakeLists.txt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/rocclr/CMakeLists.txt b/rocclr/CMakeLists.txt index 122277eec2..274d0c2bc7 100644 --- a/rocclr/CMakeLists.txt +++ b/rocclr/CMakeLists.txt @@ -40,10 +40,6 @@ endif() option(USE_COMGR_LIBRARY "Use comgr library" ON) -if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - add_compile_options("-Wno-ignored-attributes") -endif() - find_package(amd_comgr REQUIRED CONFIG PATHS /opt/rocm/ @@ -86,6 +82,21 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_POSITION_INDEPENDENT_CODE ON) +if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR + (CMAKE_${COMPILER}_COMPILER_ID MATCHES "Clang")) + add_definitions( + # Enabling -Wextra or -pedantic will cause + # thousands of warnings. Keep things simple for now. + -Wall + # Makefile build adds -fno-strict-aliasing instead. + -Wno-strict-aliasing + # This one seems impossible to fix for now. + # There are hundreds of instances of unused vars/functions + # throughout the code base. + -Wno-unused-variable + -Wno-unused-function) +endif() + add_definitions(-D__x86_64__ -DOPENCL_MAJOR=2 -DOPENCL_MINOR=1 -DCL_TARGET_OPENCL_VERSION=220 -DATI_OS_LINUX -DATI_ARCH_X86 -DLITTLEENDIAN_CPU -DATI_BITS_64 -DWITH_TARGET_AMDGCN -DOPENCL_EXPORTS -DCL_USE_DEPRECATED_OPENCL_1_0_APIS -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DCL_USE_DEPRECATED_OPENCL_1_2_APIS -DCL_USE_DEPRECATED_OPENCL_2_0_APIS -DVEGA10_ONLY=false -DWITH_LIGHTNING_COMPILER) add_definitions(-DOPENCL_C_MAJOR=2 -DOPENCL_C_MINOR=0)