Skip to content

Commit

Permalink
Bug #26399073: MYSQL DOES NOT COMPILE WITH CLANG ON WINDOWS [noclose]
Browse files Browse the repository at this point in the history
Make MySQL build with Clang for Windows again; bump the recommended version
to 6.0 and fix a number of smaller issues that showed up.

We're nowhere near warning-free, but at least we seem to compile again now.

Change-Id: I54e834d8a5d96820bab62c68639cdb3c1bda28b0
  • Loading branch information
Steinar H. Gunderson committed Aug 31, 2018
1 parent 4b08640 commit a8e5167
Show file tree
Hide file tree
Showing 6 changed files with 471 additions and 5 deletions.
7 changes: 5 additions & 2 deletions Docs/README.build
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,22 @@ see extra/README-wolfssl.txt on how to set this up.

It is possible to compile with Clang on Windows, which compiles faster
and also yields faster binaries, but this is experimental and not officially
supported. To compile, use LLVM 5.0.0 or newer from releases.llvm.org
supported. To compile, use LLVM 6.0.1 or newer from releases.llvm.org
(Clang/C2, which is Microsoft's own version of Clang, is not supported),
and put a Windows compile of Ninja in your path. Then execute the following
in a shell:

"c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64
set PATH=<path to Ninja>;c:\program files\llvm\msbuild-bin;%PATH%
set PATH=<path to Ninja>;%PATH%
"c:\Program Files\CMake 3.8\bin\cmake.exe" -G Ninja -DCMAKE_C_COMPILER="c:/program files/llvm/msbuild-bin/cl.exe" -DCMAKE_CXX_COMPILER="c:/program files/llvm/msbuild-bin/cl.exe" -DCMAKE_LINKER="c:/program files/llvm/bin/lld-link.exe" -DWITH_BOOST=<path to Boost> ..
ninja

This configuration also supports ASAN (-DWITH_ASAN=1), although currently only
when linking with MSVC's linker (not with LLD).

For running tests with --parallel, you may need to add --build-thread= (500 is
a reasonable value to try).

===

Note: For building with unit tests, you need to tell cmake where to find
Expand Down
58 changes: 58 additions & 0 deletions cmake/maintainer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,64 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
MY_ADD_CXX_WARNING_FLAG("Wimplicit-fallthrough=2")
ENDIF()

# Clang 6.0 and newer on Windows seems to enable -Weverything; turn off some
# that are way too verbose for us.
IF(WIN32 AND CMAKE_C_COMPILER_ID MATCHES "Clang")
# We don't need C++98 compatibility.
MY_ADD_CXX_WARNING_FLAG("Wno-c++98-compat")
MY_ADD_CXX_WARNING_FLAG("Wno-c++98-compat-pedantic")

# Also warns on using NULL.
MY_ADD_CXX_WARNING_FLAG("Wno-zero-as-null-pointer-constant")

# Should be enabled globally, but too noisy right now.
MY_ADD_CXX_WARNING_FLAG("Wno-old-style-cast")
MY_ADD_CXX_WARNING_FLAG("Wno-extra-semi")
MY_ADD_CXX_WARNING_FLAG("Wno-reserved-id-macro")
MY_ADD_CXX_WARNING_FLAG("Wno-documentation")
MY_ADD_CXX_WARNING_FLAG("Wno-documentation-pedantic")
MY_ADD_CXX_WARNING_FLAG("Wno-documentation-unknown-command")
MY_ADD_CXX_WARNING_FLAG("Wno-missing-variable-declarations")
MY_ADD_CXX_WARNING_FLAG("Wno-cast-qual")
MY_ADD_CXX_WARNING_FLAG("Wno-language-extension-token")
MY_ADD_CXX_WARNING_FLAG("Wno-shorten-64-to-32")
MY_ADD_CXX_WARNING_FLAG("Wno-shadow")
MY_ADD_CXX_WARNING_FLAG("Wno-deprecated") # FIXME
MY_ADD_CXX_WARNING_FLAG("Wno-inconsistent-missing-destructor-override")
MY_ADD_CXX_WARNING_FLAG("Wno-c++2a-compat")
MY_ADD_CXX_WARNING_FLAG("Wno-macro-redefined")
MY_ADD_CXX_WARNING_FLAG("Wno-unused-const-variable")
MY_ADD_CXX_WARNING_FLAG("Wno-gnu-anonymous-struct")

# Various things we don't want to warn about.
MY_ADD_CXX_WARNING_FLAG("Wno-global-constructors")
MY_ADD_CXX_WARNING_FLAG("Wno-exit-time-destructors")
MY_ADD_CXX_WARNING_FLAG("Wno-undefined-func-template")
MY_ADD_CXX_WARNING_FLAG("Wno-nonportable-system-include-path")
MY_ADD_CXX_WARNING_FLAG("Wno-sign-conversion")
MY_ADD_CXX_WARNING_FLAG("Wno-unused-exception-parameter")
MY_ADD_CXX_WARNING_FLAG("Wno-missing-prototypes")
MY_ADD_CXX_WARNING_FLAG("Wno-shadow-field-in-constructor")
MY_ADD_CXX_WARNING_FLAG("Wno-float-equal")
MY_ADD_CXX_WARNING_FLAG("Wno-float-conversion")
MY_ADD_CXX_WARNING_FLAG("Wno-double-promotion")
MY_ADD_CXX_WARNING_FLAG("Wno-covered-switch-default")
MY_ADD_CXX_WARNING_FLAG("Wno-used-but-marked-unused")
MY_ADD_CXX_WARNING_FLAG("Wno-conversion")
MY_ADD_CXX_WARNING_FLAG("Wno-sign-conversion")
MY_ADD_CXX_WARNING_FLAG("Wno-microsoft-pure-definition") # False positives.
MY_ADD_CXX_WARNING_FLAG("Wno-format-nonliteral")
MY_ADD_CXX_WARNING_FLAG("Wno-format-pedantic")
MY_ADD_CXX_WARNING_FLAG("Wno-cast-align")
MY_ADD_CXX_WARNING_FLAG("Wno-gnu-zero-variadic-macro-arguments")
MY_ADD_CXX_WARNING_FLAG("Wno-comma")
MY_ADD_CXX_WARNING_FLAG("Wno-sign-compare")
MY_ADD_CXX_WARNING_FLAG("Wno-switch-enum")
MY_ADD_CXX_WARNING_FLAG("Wno-implicit-fallthrough") # Does not take the same signals as GCC.
MY_ADD_CXX_WARNING_FLAG("Wno-unused-macros")
MY_ADD_CXX_WARNING_FLAG("Wno-disabled-macro-expansion")
ENDIF()

#
# Extra flags not supported on all versions/compilers
#
Expand Down
7 changes: 7 additions & 0 deletions cmake/os/Windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ IF(WITH_MSCRT_DEBUG)
ADD_DEFINITIONS(-DMY_MSCRT_DEBUG)
ADD_DEFINITIONS(-D_CRTDBG_MAP_ALLOC)
ENDIF()

IF(WIN32_CLANG)
# RapidJSON doesn't understand the Win32/Clang combination.
ADD_DEFINITIONS(-DRAPIDJSON_HAS_CXX11_RVALUE_REFS=1)
ADD_DEFINITIONS(-DRAPIDJSON_HAS_CXX11_NOEXCEPT=1)
ADD_DEFINITIONS(-DRAPIDJSON_HAS_CXX11_RANGE_FOR=1)
ENDIF()

OPTION(WIN_DEBUG_NO_INLINE "Disable inlining for debug builds on Windows" OFF)

Expand Down
Loading

0 comments on commit a8e5167

Please sign in to comment.