Commit 5bce1f4d by Antonio Maiorano

CMake: apply the warning treatment to msvc builds

* Respect WARNINGS_AS_ERRORS option for msvc builds. * Disable a bunch of warnings for msvc builds. These were gathered from all the hand-crafted vcxproj files and merged into one set. Eventually we need to disable some of these and fix the actual warnings. * Treat specific warnings as errors for msvc builds. These were gathered from the hand-crafted vcxproj files. * Fix LLVM build showing warning 4141 despite being disabled in CMakeLists. Something wonky happens when using set with the first string argument. Going with list(APPEND,...) works, and is symmetrical with the non-msvc script. * Define _SCL_SECURE_NO_WARNINGS for all modules, not just LLVM. * Fix double to float conversion warning in SprivShader.cpp * Fix mismatched type compare in IceTargetLoweringX664Traits.h Bug: b/132445520 Change-Id: I1143e9fdd386e26d4f0b0f9e34c4d6b3ac2f2311 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31149 Presubmit-Ready: Antonio Maiorano <amaiorano@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 69c37491
...@@ -226,7 +226,39 @@ endmacro() ...@@ -226,7 +226,39 @@ endmacro()
if(MSVC) if(MSVC)
set_cpp_flag("/MP") set_cpp_flag("/MP")
add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-D_SBCS) # Single Byte Character Set (ASCII) add_definitions(-D_SBCS) # Single Byte Character Set (ASCII)
if(WARNINGS_AS_ERRORS)
set_cpp_flag("/WX") # Treat all warnings as errors
endif()
# Disable specific warnings
# TODO: Not all of these should be disabled, but for now, we want a warning-free msvc build. Remove these one by one
# and fix the actual warnings in code.
list(APPEND SWIFTSHADER_COMPILE_OPTIONS
"/wd4005" # 'identifier' : macro redefinition
"/wd4018" # 'expression' : signed/unsigned mismatch
"/wd4141" # 'modifier' : used more than once
"/wd4146" # unary minus operator applied to unsigned type, result still unsigned
"/wd4244" # 'conversion' conversion from 'type1' to 'type2', possible loss of data
"/wd4267" # 'var' : conversion from 'size_t' to 'type', possible loss of data
"/wd4291" # 'void X new(size_t,unsigned int,unsigned int)': no matching operator delete found; memory will not be freed if initialization throws an exception
"/wd4309" # 'conversion' : truncation of constant value
"/wd4624" # 'derived class' : destructor was implicitly defined as deleted because a base class destructor is inaccessible or deleted
"/wd4800" # 'type' : forcing value to bool 'true' or 'false' (performance warning)
"/wd4838" # conversion from 'type_1' to 'type_2' requires a narrowing conversion
"/wd5030" # attribute 'attribute' is not recognized
"/wd5038" # data member 'member1' will be initialized after data member 'member2' data member 'member' will be initialized after base class 'base_class'
)
# Treat specific warnings as errors
list(APPEND SWIFTSHADER_COMPILE_OPTIONS
"/we4018" # 'expression' : signed/unsigned mismatch
"/we4838" # conversion from 'type_1' to 'type_2' requires a narrowing conversion
"/we5038" # data member 'member1' will be initialized after data member 'member2' data member 'member' will be initialized after base class 'base_class'
)
else() else()
set_cpp_flag("--std=c++11") set_cpp_flag("--std=c++11")
set_cpp_flag("-fno-exceptions") set_cpp_flag("-fno-exceptions")
...@@ -1236,7 +1268,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") ...@@ -1236,7 +1268,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
"-Wno-unused-but-set-variable" # variable ‘X’ set but not used "-Wno-unused-but-set-variable" # variable ‘X’ set but not used
) )
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(LLVM_DISABLE_WARNINGS list(APPEND LLVM_COMPILE_OPTIONS
"/wd4141" # 'inline': used more than once "/wd4141" # 'inline': used more than once
"/wd4146" # unary minus operator applied to unsigned type, result still unsigned "/wd4146" # unary minus operator applied to unsigned type, result still unsigned
"/wd4244" # 'X': conversion from 'uint64_t' to 'const unsigned int', possible loss of data "/wd4244" # 'X': conversion from 'uint64_t' to 'const unsigned int', possible loss of data
...@@ -1247,7 +1279,6 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") ...@@ -1247,7 +1279,6 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
"/wd4805" # 'X': unsafe mix of type 'unsigned int' and type 'bool' in operation "/wd4805" # 'X': unsafe mix of type 'unsigned int' and type 'bool' in operation
"/wd4996" # 'X': Call to 'Y' with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. "/wd4996" # 'X': Call to 'Y' with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct.
) )
set(LLVM_COMPILE_OPTIONS "/D \"_SCL_SECURE_NO_WARNINGS\" ${LLVM_DISABLE_WARNINGS}")
endif() endif()
add_library(llvm STATIC ${LLVM_LIST}) add_library(llvm STATIC ${LLVM_LIST})
...@@ -1369,6 +1400,13 @@ if(${REACTOR_BACKEND} STREQUAL "Subzero") ...@@ -1369,6 +1400,13 @@ if(${REACTOR_BACKEND} STREQUAL "Subzero")
list(APPEND SUBZERO_INCLUDE_DIR ${SUBZERO_LLVM_DIR}/build/MacOS/include/) list(APPEND SUBZERO_INCLUDE_DIR ${SUBZERO_LLVM_DIR}/build/MacOS/include/)
endif() endif()
if(WIN32)
list(APPEND SUBZERO_COMPILE_OPTIONS
"/wd4334" # ''operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
"/wd4996" # The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: new_name.
)
endif()
add_library(ReactorSubzero STATIC add_library(ReactorSubzero STATIC
${SUBZERO_LIST} ${SUBZERO_LIST}
${SUBZERO_DEPENDENCIES_LIST} ${SUBZERO_DEPENDENCIES_LIST}
...@@ -1377,7 +1415,7 @@ if(${REACTOR_BACKEND} STREQUAL "Subzero") ...@@ -1377,7 +1415,7 @@ if(${REACTOR_BACKEND} STREQUAL "Subzero")
set_target_properties(ReactorSubzero PROPERTIES set_target_properties(ReactorSubzero PROPERTIES
POSITION_INDEPENDENT_CODE 1 POSITION_INDEPENDENT_CODE 1
INCLUDE_DIRECTORIES "${SUBZERO_INCLUDE_DIR}" INCLUDE_DIRECTORIES "${SUBZERO_INCLUDE_DIR}"
COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS}" COMPILE_OPTIONS "${SUBZERO_COMPILE_OPTIONS};${SWIFTSHADER_COMPILE_OPTIONS}"
COMPILE_DEFINITIONS "SZTARGET=${SUBZERO_TARGET}; ALLOW_DUMP=0; ALLOW_TIMERS=0; ALLOW_LLVM_CL=0; ALLOW_LLVM_IR=0; ALLOW_LLVM_IR_AS_INPUT=0; ALLOW_MINIMAL_BUILD=0; ALLOW_WASM=0; ICE_THREAD_LOCAL_HACK=0;" COMPILE_DEFINITIONS "SZTARGET=${SUBZERO_TARGET}; ALLOW_DUMP=0; ALLOW_TIMERS=0; ALLOW_LLVM_CL=0; ALLOW_LLVM_IR=0; ALLOW_LLVM_IR_AS_INPUT=0; ALLOW_MINIMAL_BUILD=0; ALLOW_WASM=0; ICE_THREAD_LOCAL_HACK=0;"
FOLDER "Subzero" FOLDER "Subzero"
) )
......
...@@ -3210,7 +3210,7 @@ namespace sw ...@@ -3210,7 +3210,7 @@ namespace sw
{ {
auto abs = Abs(src.Float(i)); auto abs = Abs(src.Float(i));
auto sign = src.Int(i) & SIMD::Int(0x80000000); auto sign = src.Int(i) & SIMD::Int(0x80000000);
auto isZero = CmpLT(abs, SIMD::Float(0.000061035)); auto isZero = CmpLT(abs, SIMD::Float(0.000061035f));
auto isInf = CmpGT(abs, SIMD::Float(65504.0f)); auto isInf = CmpGT(abs, SIMD::Float(65504.0f));
auto isNaN = IsNan(abs); auto isNaN = IsNan(abs);
auto isInfOrNan = isInf | isNaN; auto isInfOrNan = isInf | isNaN;
......
...@@ -545,7 +545,7 @@ public: ...@@ -545,7 +545,7 @@ public:
// still be used by the Target Lowering (e.g., base pointer), so the // still be used by the Target Lowering (e.g., base pointer), so the
// register alias table still needs to be defined. // register alias table still needs to be defined.
(*RegisterAliases)[Entry.Val].resize(RegisterSet::Reg_NUM); (*RegisterAliases)[Entry.Val].resize(RegisterSet::Reg_NUM);
for (int J = 0; J < Entry.NumAliases; ++J) { for (Ice::SizeT J = 0; J < Entry.NumAliases; ++J) {
SizeT Alias = Entry.Aliases[J]; SizeT Alias = Entry.Aliases[J];
assert(!(*RegisterAliases)[Entry.Val][Alias] && "Duplicate alias"); assert(!(*RegisterAliases)[Entry.Val][Alias] && "Duplicate alias");
(*RegisterAliases)[Entry.Val].set(Alias); (*RegisterAliases)[Entry.Val].set(Alias);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment