Skip to content

Commit

Permalink
Build Qt (and client apps using it) with /permissive-
Browse files Browse the repository at this point in the history
*Not* using /permissive- exposes Qt and client apps to interesting
bugs and/or build failures, (e.g. QTBUG-87225, or
19b5520). We demand strict
conformance by any other compiler, it's time to demand it from
MSVC too.

The Windows headers themselves are clean starting from the
Windows Fall Creators SDK (10.0.16299.0), and moreover Qt 6 will
drop WinRT; therefore, the comment in the mkspecs does not apply
any more.

Since /permissive- implies /Zc:referenceBinding, drop that
option. The other implied options are set on MSVC < 2017,
but I leave them in to avoid tinkering with the fragile lists
of C/C++ flags.

Rename the CMake internal helper function to better describe
what it does.

Fixes: QTBUG-85633
Fixes: QTBUG-85637
Fixes: QTBUG-85635
Fixes: QTBUG-88244
Change-Id: Ie03fddb61aa066fdc14b7231c22e7108b4a02fbb
Reviewed-by: Friedemann Kleint <[email protected]>
Reviewed-by: Kai Koehne <[email protected]>
Reviewed-by: Volker Hilsheimer <[email protected]>
  • Loading branch information
dangelog committed Nov 10, 2020
1 parent ef051a6 commit 8780fbb
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmake/QtFlagHandlingHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,11 @@ function(qt_set_language_standards_interface_compile_features target)
target_compile_features("${target}" INTERFACE ${cpp_feature})
endfunction()

function(qt_enable_msvc_cplusplus_define target visibility)
function(qt_set_msvc_cplusplus_options target visibility)
# For MSVC we need to explicitly pass -Zc:__cplusplus to get correct __cplusplus.
# Check qt_config_compile_test for more info.
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER_EQUAL 1913)
target_compile_options("${target}" ${visibility} "-Zc:__cplusplus")
target_compile_options("${target}" ${visibility} "-Zc:__cplusplus" "-permissive-")
endif()
endfunction()

Expand Down
2 changes: 1 addition & 1 deletion cmake/QtPublicTargetsHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function(qt_internal_setup_public_platform_target)
target_link_libraries(Platform INTERFACE log)
endif()

qt_enable_msvc_cplusplus_define(Platform INTERFACE)
qt_set_msvc_cplusplus_options(Platform INTERFACE)

# Propagate minimum C++ 17 via Platform to Qt consumers (apps), after the global features
# are computed.
Expand Down
7 changes: 1 addition & 6 deletions mkspecs/common/msvc-version.conf
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ greaterThan(QMAKE_MSC_VER, 1909) {
# Visual Studio 2017 (15.0) / Visual C++ 19.10 and up
MSVC_VER = 15.0
COMPAT_MKSPEC = win32-msvc2017
QMAKE_CXXFLAGS += -Zc:referenceBinding
QMAKE_CXXFLAGS += -permissive-

# Only Visual Studio 2017 version 15.3 / Visual C++ 19.11 & up have support
# for AVX-512. We enable the switches anyway and let configure check if they
Expand All @@ -93,11 +93,6 @@ greaterThan(QMAKE_MSC_VER, 1909) {
QMAKE_CFLAGS_AVX512IFMA = -arch:AVX512
QMAKE_CFLAGS_AVX512VBMI = -arch:AVX512

# For now permissive fails as soon as UWP API comes into play. In qtbase this
# API is used in direct2d, but also in multimedia, positioning and sensors.
# We can try again with a later version of Visual Studio.
# QMAKE_CXXFLAGS_STRICTCXX = -permissive-

# MSVC partially supports the following, but '__cplusplus' definition is set
# as for C++98 until MSVC fully conforms with C++14, see
# https://developercommunity.visualstudio.com/content/problem/139261/msvc-incorrectly-defines-cplusplus.html
Expand Down
2 changes: 1 addition & 1 deletion qmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ set_target_properties(${target_name} PROPERTIES

qt_internal_apply_gc_binaries(${target_name} PRIVATE) # special case

qt_enable_msvc_cplusplus_define(${target_name} PUBLIC) # special case
qt_set_msvc_cplusplus_options(${target_name} PUBLIC) # special case
qt_skip_warnings_are_errors(${target_name}) # special case
qt_internal_apply_intel_cet(Bootstrap PUBLIC) # special case

Expand Down
2 changes: 1 addition & 1 deletion src/tools/bootstrap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,6 @@ target_link_libraries(Bootstrap PRIVATE PlatformCommonInternal)
qt_internal_apply_gc_binaries(Bootstrap PUBLIC)
set_target_properties(Bootstrap PROPERTIES AUTOMOC OFF AUTOUIC OFF AUTORCC OFF)
qt_internal_add_target_aliases(Bootstrap)
qt_enable_msvc_cplusplus_define(Bootstrap PUBLIC)
qt_set_msvc_cplusplus_options(Bootstrap PUBLIC)
qt_internal_apply_intel_cet(Bootstrap PUBLIC)
# special case end

0 comments on commit 8780fbb

Please sign in to comment.