From 57b215fc758737f55a7062cab277154c5b9626d4 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Sat, 10 Mar 2018 01:12:14 +0100 Subject: Fix build with Clang 6.0 and enable build with Clang 5.0 (#16855) * Fix build with Clang 6.0 * Add support for clang 5.0 too --- build.sh | 10 ++++++++++ compileoptions.cmake | 4 ++++ src/ToolBox/SOS/lldbplugin/CMakeLists.txt | 8 +++++--- src/inc/utilcode.h | 2 +- src/jit/ee_il_dll.cpp | 2 +- src/vm/gcenv.ee.cpp | 4 ++-- 6 files changed, 23 insertions(+), 7 deletions(-) diff --git a/build.sh b/build.sh index b7a77e33cf..63be11bb2a 100755 --- a/build.sh +++ b/build.sh @@ -725,6 +725,16 @@ while :; do __ClangMinorVersion=0 ;; + clang5.0|-clang5.0) + __ClangMajorVersion=5 + __ClangMinorVersion=0 + ;; + + clang6.0|-clang6.0) + __ClangMajorVersion=6 + __ClangMinorVersion=0 + ;; + ninja|-ninja) __UseNinja=1 ;; diff --git a/compileoptions.cmake b/compileoptions.cmake index 6f9d55fa33..9c352e8bab 100644 --- a/compileoptions.cmake +++ b/compileoptions.cmake @@ -38,6 +38,10 @@ if (CLR_CMAKE_PLATFORM_UNIX) # There are constants of type BOOL used in a condition. But BOOL is defined as int # and so the compiler thinks that there is a mistake. add_compile_options(-Wno-constant-logical-operand) + # We use pshpack1/2/4/8.h and poppack.h headers to set and restore packing. However + # clang 6.0 complains when the packing change lifetime is not contained within + # a header file. + add_compile_options(-Wno-pragma-pack) add_compile_options(-Wno-unknown-warning-option) diff --git a/src/ToolBox/SOS/lldbplugin/CMakeLists.txt b/src/ToolBox/SOS/lldbplugin/CMakeLists.txt index d780cb2e85..e87ac8bf02 100644 --- a/src/ToolBox/SOS/lldbplugin/CMakeLists.txt +++ b/src/ToolBox/SOS/lldbplugin/CMakeLists.txt @@ -55,15 +55,15 @@ endif() if (CLR_CMAKE_PLATFORM_DARWIN) # Check for LLDB library - find_library(LLDB NAMES LLDB lldb lldb-4.0 lldb-3.9 lldb-3.8 lldb-3.7 lldb-3.6 lldb-3.5 PATHS "${WITH_LLDB_LIBS}" PATH_SUFFIXES llvm NO_DEFAULT_PATH) - find_library(LLDB NAMES LLDB lldb lldb-4.0 lldb-3.9 lldb-3.8 lldb-3.7 lldb-3.6 lldb-3.5 PATH_SUFFIXES llvm) + find_library(LLDB NAMES LLDB lldb lldb-6.0 lldb-5.0 lldb-4.0 lldb-3.9 lldb-3.8 lldb-3.7 lldb-3.6 lldb-3.5 PATHS "${WITH_LLDB_LIBS}" PATH_SUFFIXES llvm NO_DEFAULT_PATH) + find_library(LLDB NAMES LLDB lldb lldb-6.0 lldb-5.0 lldb-4.0 lldb-3.9 lldb-3.8 lldb-3.7 lldb-3.6 lldb-3.5 PATH_SUFFIXES llvm) if(LLDB STREQUAL LLDB-NOTFOUND) if(REQUIRE_LLDBPLUGIN) set(MESSAGE_MODE FATAL_ERROR) else() set(MESSAGE_MODE WARNING) endif() - message(${MESSAGE_MODE} "Cannot find lldb-3.5, lldb-3.6, lldb-3.8, lldb-3.9 or lldb-4.0. Try installing liblldb-3.9-dev (or the appropriate package for your platform). You may need to set LLVM_HOME if the build still can't find it.") + message(${MESSAGE_MODE} "Cannot find lldb-3.5, lldb-3.6, lldb-3.8, lldb-3.9, lldb-4.0, lldb-5.0 or lldb-6.0. Try installing liblldb-3.9-dev (or the appropriate package for your platform). You may need to set LLVM_HOME if the build still can't find it.") return() endif() @@ -76,6 +76,8 @@ endif() # If the file in a directory is found the result is stored in the variable and the search will not be repeated unless the variable is cleared. find_path(LLDB_H "lldb/API/LLDB.h" PATHS "${WITH_LLDB_INCLUDES}" NO_DEFAULT_PATH) find_path(LLDB_H "lldb/API/LLDB.h") +find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-6.0/include") +find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-5.0/include") find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-4.0/include") find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.9/include") find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.8/include") diff --git a/src/inc/utilcode.h b/src/inc/utilcode.h index d7676cb86a..9226d682e2 100644 --- a/src/inc/utilcode.h +++ b/src/inc/utilcode.h @@ -1106,7 +1106,7 @@ inline HRESULT DecimalCanonicalize(DECIMAL* dec) // //***************************************************************************** // secure version! Specify the size of the each buffer in count of elements -void SplitPath(register const WCHAR *path, +void SplitPath(const WCHAR *path, __inout_z __inout_ecount_opt(driveSizeInWords) WCHAR *drive, int driveSizeInWords, __inout_z __inout_ecount_opt(dirSizeInWords) WCHAR *dir, int dirSizeInWords, __inout_z __inout_ecount_opt(fnameSizeInWords) WCHAR *fname, size_t fnameSizeInWords, diff --git a/src/jit/ee_il_dll.cpp b/src/jit/ee_il_dll.cpp index 81ed6cfb5d..f7ea585948 100644 --- a/src/jit/ee_il_dll.cpp +++ b/src/jit/ee_il_dll.cpp @@ -798,7 +798,7 @@ void Compiler::eeDispVar(ICorDebugInfo::NativeVarInfo* var) printf("%3d(%10s) : From %08Xh to %08Xh, in ", var->varNumber, (VarNameToStr(name) == nullptr) ? "UNKNOWN" : VarNameToStr(name), var->startOffset, var->endOffset); - switch (var->loc.vlType) + switch ((Compiler::siVarLocType)var->loc.vlType) { case VLT_REG: case VLT_REG_BYREF: diff --git a/src/vm/gcenv.ee.cpp b/src/vm/gcenv.ee.cpp index 8e2594be63..0759768126 100644 --- a/src/vm/gcenv.ee.cpp +++ b/src/vm/gcenv.ee.cpp @@ -15,8 +15,8 @@ void GCToEEInterface::SuspendEE(SUSPEND_REASON reason) { WRAPPER_NO_CONTRACT; - static_assert_no_msg(SUSPEND_FOR_GC == ThreadSuspend::SUSPEND_FOR_GC); - static_assert_no_msg(SUSPEND_FOR_GC_PREP == ThreadSuspend::SUSPEND_FOR_GC_PREP); + static_assert_no_msg(SUSPEND_FOR_GC == (int)ThreadSuspend::SUSPEND_FOR_GC); + static_assert_no_msg(SUSPEND_FOR_GC_PREP == (int)ThreadSuspend::SUSPEND_FOR_GC_PREP); _ASSERTE(reason == SUSPEND_FOR_GC || reason == SUSPEND_FOR_GC_PREP); -- cgit v1.2.3