Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Molenkamp <github@lazydodo.com>2018-05-28 23:34:47 +0300
committerRay Molenkamp <github@lazydodo.com>2018-05-28 23:34:47 +0300
commit81060ff6b26c22331d2066bb83d492bbe61e936c (patch)
tree1d173513b053c0cbbae6ab3b5f4b0a420bedb30f
parentdc0eed178a0f71634399a61b929a544e554ef6aa (diff)
Windows: Add support for building with clang.
This commit contains the minimum to make clang build/work with blender, asan and ninja build support is forthcoming Things to note: 1) Builds and runs, and is able to pass all tests (except for the freestyle_stroke_material.blend test which was broken at that time for all platforms by the looks of it) 2) It's slightly faster than msvc when using cycles. (time in seconds, on an i7-3370) victor_cpu msvc:3099.51 clang:2796.43 pavillon_barcelona_cpu msvc:1872.05 clang:1827.72 koro_cpu msvc:1097.58 clang:1006.51 fishy_cat_cpu msvc:815.37 clang:722.2 classroom_cpu msvc:1705.39 clang:1575.43 bmw27_cpu msvc:552.38 clang:561.53 barbershop_interior_cpu msvc:2134.93 clang:1922.33 3) clang on windows uses a drop in replacement for the Microsoft cl.exe (takes some of the Microsoft parameters, but not all, and takes some of the clang parameters but not all) and uses ms headers + libraries + linker, so you still need visual studio installed and will use our existing vc14 svn libs. 4) X64 only currently, X86 builds but crashes on startup. 5) Tested with llvm/clang 6.0.0 6) Requires visual studio integration, available at https://github.com/LazyDodo/llvm-vs2017-integration 7) The Microsoft compiler spawns a few copies of cl in parallel to get faster build times, clang doesn't, so the build time is 3-4x slower than with msvc. 8) No openmp support yet. Have not looked at this much, the binary distribution of clang doesn't seem to include it on windows. 9) No ASAN support yet, some of the sanitizers can be made to work, but it was decided to leave support out of this commit. Reviewers: campbellbarton Differential Revision: https://developer.blender.org/D3304
-rw-r--r--CMakeLists.txt7
-rw-r--r--build_files/build_environment/patches/boost.diff22
-rw-r--r--build_files/build_environment/patches/osl.diff26
-rw-r--r--build_files/cmake/platform/platform_win32.cmake17
-rw-r--r--build_files/windows/configure_msbuild.cmd4
-rw-r--r--build_files/windows/configure_ninja.cmd6
-rw-r--r--build_files/windows/parse_arguments.cmd3
-rw-r--r--build_files/windows/reset_variables.cmd1
-rw-r--r--extern/Eigen3/Eigen/src/Core/arch/SSE/PacketMath.h2
-rw-r--r--extern/Eigen3/patches/blender.diff12
-rw-r--r--extern/bullet2/patches/blender.patch31
-rw-r--r--extern/bullet2/src/LinearMath/btScalar.h7
-rw-r--r--intern/atomic/intern/atomic_ops_msvc.h11
-rw-r--r--intern/cycles/CMakeLists.txt4
-rw-r--r--intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h2
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c4
-rw-r--r--source/blender/blenlib/BLI_utildefines.h4
-rw-r--r--source/blender/bmesh/CMakeLists.txt2
-rw-r--r--source/blender/makesrna/intern/makesrna.c2
-rw-r--r--source/blender/python/intern/stubs.c2
20 files changed, 151 insertions, 18 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0388e251b6f..6ffe87da673 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1612,7 +1612,12 @@ else()
endif()
# Visual Studio has all standards it supports available by default
-if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "Intel")
+# Clang on windows copies this behavior and does not support these switches
+if(
+ CMAKE_COMPILER_IS_GNUCC OR
+ (CMAKE_C_COMPILER_ID MATCHES "Clang" AND (NOT MSVC)) OR
+ (CMAKE_C_COMPILER_ID MATCHES "Intel")
+)
# Use C99 + GNU extensions, works with GCC, Clang, ICC
if(WITH_C11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
diff --git a/build_files/build_environment/patches/boost.diff b/build_files/build_environment/patches/boost.diff
index ea3ec035518..41b40d7a915 100644
--- a/build_files/build_environment/patches/boost.diff
+++ b/build_files/build_environment/patches/boost.diff
@@ -13,3 +13,25 @@
-# pragma message("Unknown compiler version - please run the configure tests and report the results")
-# endif
-#endif
+--- a/boost/type_traits/has_nothrow_assign.hpp 2015-12-13 05:49:42 -0700
++++ b/boost/type_traits/has_nothrow_assign.hpp 2018-05-27 11:11:02 -0600
+@@ -24,7 +24,7 @@
+ #include <boost/type_traits/remove_reference.hpp>
+ #endif
+ #endif
+-#if defined(__GNUC__) || defined(__SUNPRO_CC)
++#if defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__clang__)
+ #include <boost/type_traits/is_const.hpp>
+ #include <boost/type_traits/is_volatile.hpp>
+ #include <boost/type_traits/is_assignable.hpp>
+--- a/boost/type_traits/has_nothrow_constructor.hpp 2015-12-13 05:49:42 -0700
++++ b/boost/type_traits/has_nothrow_constructor.hpp 2018-05-27 11:11:02 -0600
+@@ -17,7 +17,7 @@
+ #if defined(BOOST_MSVC) || defined(BOOST_INTEL)
+ #include <boost/type_traits/has_trivial_constructor.hpp>
+ #endif
+-#if defined(__GNUC__ ) || defined(__SUNPRO_CC)
++#if defined(__GNUC__ ) || defined(__SUNPRO_CC) || defined(__clang__)
+ #include <boost/type_traits/is_default_constructible.hpp>
+ #endif
+
diff --git a/build_files/build_environment/patches/osl.diff b/build_files/build_environment/patches/osl.diff
index fcb5ec4165f..960a2506374 100644
--- a/build_files/build_environment/patches/osl.diff
+++ b/build_files/build_environment/patches/osl.diff
@@ -10,3 +10,29 @@ diff -Naur osl/src/external_osl/src/cmake/flexbison.cmake osl_bak/src/external_o
MAIN_DEPENDENCY ${flexsrc}
DEPENDS ${${compiler_headers}}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
+--- a/src/include/OSL/oslconfig.h 2016-10-31 16:48:19 -0600
++++ b/src/include/OSL/oslconfig.h 2018-05-27 11:18:08 -0600
+@@ -44,12 +44,18 @@
+ // same if another packages is compiling against OSL and using these headers
+ // (OSL may be C++11 but the client package may be older, or vice versa --
+ // use these two symbols to differentiate these cases, when important).
+-#if (__cplusplus >= 201402L)
+-# define OSL_CPLUSPLUS_VERSION 14
+-#elif (__cplusplus >= 201103L)
+-# define OSL_CPLUSPLUS_VERSION 11
++
++// Force C++03 for MSVC in blender since svn the libraries are build with that
++#if !defined(_MSC_VER)
++ #if (__cplusplus >= 201402L)
++ # define OSL_CPLUSPLUS_VERSION 14
++ #elif (__cplusplus >= 201103L)
++ # define OSL_CPLUSPLUS_VERSION 11
++ #else
++ # define OSL_CPLUSPLUS_VERSION 3 /* presume C++03 */
++ #endif
+ #else
+-# define OSL_CPLUSPLUS_VERSION 3 /* presume C++03 */
++ # define OSL_CPLUSPLUS_VERSION 3 /* presume C++03 */
+ #endif
+
+ // Symbol export defines
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake
index 3520ac9c075..205040ac0cf 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -29,7 +29,10 @@ if(NOT MSVC)
message(FATAL_ERROR "Compiler is unsupported")
endif()
-# Libraries configuration for Windows when compiling with MSVC.
+if(CMAKE_C_COMPILER_ID MATCHES "Clang")
+ set(MSVC_CLANG On)
+ file(TO_CMAKE_PATH $ENV{VCToolsRedistDir} MSVC_REDIST_DIR)
+endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ${WINDOWS_USE_VISUAL_STUDIO_FOLDERS})
@@ -121,8 +124,16 @@ include(InstallRequiredSystemLibraries)
remove_cc_flag("/MDd" "/MD")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /nologo /J /Gd /MP /EHsc")
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd /MP")
+if(MSVC_CLANG) # Clangs version of cl doesn't support all flags
+ if(NOT WITH_CXX11) # C++11 is on by default in clang-cl and can't be turned off, if c++11 is not enabled in blender repress some c++11 related warnings.
+ set(CXX_WARN_FLAGS "-Wno-inconsistent-missing-override")
+ endif()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_WARN_FLAGS} /nologo /J /Gd /EHsc -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference ")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference")
+else()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /nologo /J /Gd /MP /EHsc")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd /MP")
+endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
diff --git a/build_files/windows/configure_msbuild.cmd b/build_files/windows/configure_msbuild.cmd
index 135b7933ab2..95a8882a9ab 100644
--- a/build_files/windows/configure_msbuild.cmd
+++ b/build_files/windows/configure_msbuild.cmd
@@ -4,6 +4,10 @@ if "%BUILD_ARCH%"=="x64" (
set MSBUILD_PLATFORM=x64
) else if "%BUILD_ARCH%"=="x86" (
set MSBUILD_PLATFORM=win32
+ if "%WITH_CLANG%"=="1" (
+ echo Clang not supported for X86
+ exit /b 1
+ )
)
if NOT EXIST %BUILD_DIR%\nul (
diff --git a/build_files/windows/configure_ninja.cmd b/build_files/windows/configure_ninja.cmd
index 13797543bcc..24911a10275 100644
--- a/build_files/windows/configure_ninja.cmd
+++ b/build_files/windows/configure_ninja.cmd
@@ -1,4 +1,10 @@
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Ninja" %TESTS_CMAKE_ARGS% -DCMAKE_BUILD_TYPE=%BUILD_TYPE%
+
+if "%WITH_CLANG%" == "1" (
+ echo Building with ninja and clang not supported yet.
+ exit /b 1
+)
+
:DetectionComplete
if NOT "%verbose%" == "" (
echo BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS%
diff --git a/build_files/windows/parse_arguments.cmd b/build_files/windows/parse_arguments.cmd
index 5a82bf3cf04..1cb2e1f3e8c 100644
--- a/build_files/windows/parse_arguments.cmd
+++ b/build_files/windows/parse_arguments.cmd
@@ -36,6 +36,9 @@ if NOT "%1" == "" (
) else if "%1" == "bpy" (
set TARGET=Bpy
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -C"%BLENDER_DIR%\build_files\cmake\config\bpy_module.cmake"
+ ) else if "%1" == "clang" (
+ set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -T"LLVM-vs2017"
+ set WITH_CLANG=1
) else if "%1" == "release" (
set TARGET=Release
) else if "%1" == "x86" (
diff --git a/build_files/windows/reset_variables.cmd b/build_files/windows/reset_variables.cmd
index 34af3ff9389..d9a50a7f809 100644
--- a/build_files/windows/reset_variables.cmd
+++ b/build_files/windows/reset_variables.cmd
@@ -21,3 +21,4 @@ set BUILD_UPDATE=
set BUILD_SHOW_HASHES=
set SHOW_HELP=
set BUILD_WITH_NINJA=
+set WITH_CLANG= \ No newline at end of file
diff --git a/extern/Eigen3/Eigen/src/Core/arch/SSE/PacketMath.h b/extern/Eigen3/Eigen/src/Core/arch/SSE/PacketMath.h
index fc8ae50fed7..cb535e1b78f 100644
--- a/extern/Eigen3/Eigen/src/Core/arch/SSE/PacketMath.h
+++ b/extern/Eigen3/Eigen/src/Core/arch/SSE/PacketMath.h
@@ -335,7 +335,7 @@ template<> EIGEN_STRONG_INLINE void prefetch<float>(const float* addr) { _mm_p
template<> EIGEN_STRONG_INLINE void prefetch<double>(const double* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }
template<> EIGEN_STRONG_INLINE void prefetch<int>(const int* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }
-#if defined(_MSC_VER) && defined(_WIN64) && !defined(__INTEL_COMPILER)
+#if defined(_MSC_VER) && defined(_WIN64) && !defined(__INTEL_COMPILER) && !defined(__clang__)
// The temporary variable fixes an internal compilation error in vs <= 2008 and a wrong-result bug in vs 2010
// Direct of the struct members fixed bug #62.
template<> EIGEN_STRONG_INLINE float pfirst<Packet4f>(const Packet4f& a) { return a.m128_f32[0]; }
diff --git a/extern/Eigen3/patches/blender.diff b/extern/Eigen3/patches/blender.diff
new file mode 100644
index 00000000000..3d7ba6e7006
--- /dev/null
+++ b/extern/Eigen3/patches/blender.diff
@@ -0,0 +1,12 @@
+diff -Naur c:\blender-git\blender\extern\Eigen3/Eigen/src/Core/arch/SSE/PacketMath.h k:\BlenderGit\blender\extern\Eigen3/Eigen/src/Core/arch/SSE/PacketMath.h
+--- c:\blender-git\blender\extern\Eigen3/Eigen/src/Core/arch/SSE/PacketMath.h 2018-05-25 13:29:14 -0600
++++ k:\BlenderGit\blender\extern\Eigen3/Eigen/src/Core/arch/SSE/PacketMath.h 2018-05-26 19:56:36 -0600
+@@ -335,7 +335,7 @@
+ template<> EIGEN_STRONG_INLINE void prefetch<double>(const double* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }
+ template<> EIGEN_STRONG_INLINE void prefetch<int>(const int* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }
+
+-#if defined(_MSC_VER) && defined(_WIN64) && !defined(__INTEL_COMPILER)
++#if defined(_MSC_VER) && defined(_WIN64) && !defined(__INTEL_COMPILER) && !defined(__clang__)
+ // The temporary variable fixes an internal compilation error in vs <= 2008 and a wrong-result bug in vs 2010
+ // Direct of the struct members fixed bug #62.
+ template<> EIGEN_STRONG_INLINE float pfirst<Packet4f>(const Packet4f& a) { return a.m128_f32[0]; }
diff --git a/extern/bullet2/patches/blender.patch b/extern/bullet2/patches/blender.patch
index 96357ddd315..cb3bf2ba38a 100644
--- a/extern/bullet2/patches/blender.patch
+++ b/extern/bullet2/patches/blender.patch
@@ -1,3 +1,34 @@
+diff --git a/extern/bullet2/src/LinearMath/btScalar.h b/extern/bullet2/src/LinearMath/btScalar.h
+--- a/extern/bullet2/src/LinearMath/btScalar.h
++++ b/extern/bullet2/src/LinearMath/btScalar.h
+@@ -16,6 +16,9 @@
+
+ #ifndef BT_SCALAR_H
+ #define BT_SCALAR_H
++#if defined(_MSC_VER) && defined(__clang__) /* clang supplies it's own overloads already */
++#define BT_NO_SIMD_OPERATOR_OVERLOADS
++#endif
+
+ #ifdef BT_MANAGED_CODE
+ //Aligned data types not supported in managed code
+@@ -83,7 +86,7 @@
+ #ifdef BT_USE_SSE
+
+ #if (_MSC_FULL_VER >= 170050727)//Visual Studio 2012 can compile SSE4/FMA3 (but SSE4/FMA3 is not enabled by default)
+- #define BT_ALLOW_SSE4
++ //#define BT_ALLOW_SSE4 //disable this cause blender targets sse2
+ #endif //(_MSC_FULL_VER >= 160040219)
+
+ //BT_USE_SSE_IN_API is disabled under Windows by default, because
+@@ -102,7 +105,7 @@
+ #endif //__MINGW32__
+
+ #ifdef BT_DEBUG
+- #ifdef _MSC_VER
++ #if defined(_MSC_VER) && !defined(__clang__)
+ #include <stdio.h>
+ #define btAssert(x) { if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);__debugbreak(); }}
+ #else//_MSC_VER
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h
index be9eca6..ec40c96 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h
diff --git a/extern/bullet2/src/LinearMath/btScalar.h b/extern/bullet2/src/LinearMath/btScalar.h
index 0bfd255bdb4..898669f86e2 100644
--- a/extern/bullet2/src/LinearMath/btScalar.h
+++ b/extern/bullet2/src/LinearMath/btScalar.h
@@ -16,6 +16,9 @@ subject to the following restrictions:
#ifndef BT_SCALAR_H
#define BT_SCALAR_H
+#if defined(_MSC_VER) && defined(__clang__) /* clang supplies it's own overloads already */
+#define BT_NO_SIMD_OPERATOR_OVERLOADS
+#endif
#ifdef BT_MANAGED_CODE
//Aligned data types not supported in managed code
@@ -83,7 +86,7 @@ inline int btGetVersion()
#ifdef BT_USE_SSE
#if (_MSC_FULL_VER >= 170050727)//Visual Studio 2012 can compile SSE4/FMA3 (but SSE4/FMA3 is not enabled by default)
- #define BT_ALLOW_SSE4
+ //#define BT_ALLOW_SSE4 //disable this cause blender targets sse2
#endif //(_MSC_FULL_VER >= 160040219)
//BT_USE_SSE_IN_API is disabled under Windows by default, because
@@ -102,7 +105,7 @@ inline int btGetVersion()
#endif //__MINGW32__
#ifdef BT_DEBUG
- #ifdef _MSC_VER
+ #if defined(_MSC_VER) && !defined(__clang__)
#include <stdio.h>
#define btAssert(x) { if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);__debugbreak(); }}
#else//_MSC_VER
diff --git a/intern/atomic/intern/atomic_ops_msvc.h b/intern/atomic/intern/atomic_ops_msvc.h
index c24a9095735..39ed4efe3a8 100644
--- a/intern/atomic/intern/atomic_ops_msvc.h
+++ b/intern/atomic/intern/atomic_ops_msvc.h
@@ -40,7 +40,11 @@
#include <windows.h>
#include <intrin.h>
-/******************************************************************************/
+#if defined (__clang__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
+#endif
+
/* 64-bit operations. */
#if (LG_SIZEOF_PTR == 8 || LG_SIZEOF_INT == 8)
/* Unsigned */
@@ -205,4 +209,9 @@ ATOMIC_INLINE int8_t atomic_fetch_and_or_int8(int8_t *p, int8_t b)
#endif
}
+
+#if defined (__clang__)
+# pragma GCC diagnostic pop
+#endif
+
#endif /* __ATOMIC_OPS_MSVC_H__ */
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt
index c3305ac3dd8..100a52625d1 100644
--- a/intern/cycles/CMakeLists.txt
+++ b/intern/cycles/CMakeLists.txt
@@ -31,7 +31,7 @@ elseif(NOT WITH_CPU_SSE)
set(CXX_HAS_SSE FALSE)
set(CXX_HAS_AVX FALSE)
set(CXX_HAS_AVX2 FALSE)
-elseif(WIN32 AND MSVC)
+elseif(WIN32 AND MSVC AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CXX_HAS_SSE TRUE)
set(CXX_HAS_AVX TRUE)
set(CXX_HAS_AVX2 TRUE)
@@ -306,7 +306,7 @@ if(WITH_CYCLES_CUDA_BINARIES AND (NOT WITH_CYCLES_CUBIN_COMPILER))
elseif(${CUDA_VERSION} EQUAL "9.1")
set(MAX_MSVC 1911)
endif()
- if(NOT MSVC_VERSION LESS ${MAX_MSVC})
+ if(NOT MSVC_VERSION LESS ${MAX_MSVC} OR CMAKE_C_COMPILER_ID MATCHES "Clang")
message(STATUS "nvcc not supported for this compiler version, using cycles_cubin_cc instead.")
set(WITH_CYCLES_CUBIN_COMPILER ON)
endif()
diff --git a/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h b/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h
index 56c38d8101c..7bf833eadbc 100644
--- a/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h
+++ b/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h
@@ -349,7 +349,7 @@ template<typename T> struct TextureInterpolator {
* Only happens for AVX2 kernel and global __KERNEL_SSE__ vectorization
* enabled.
*/
-#ifdef __GNUC__
+#if defined(__GNUC__) || defined(__clang__)
static ccl_always_inline
#else
static ccl_never_inline
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index b8873cca0fb..ecb8814dd70 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -1658,7 +1658,7 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime)
#else /* WITH_BULLET */
/* stubs */
-#ifdef __GNUC__
+#if defined(__GNUC__) || defined(__clang__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
@@ -1684,7 +1684,7 @@ void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw) {}
void BKE_rigidbody_rebuild_world(Scene *scene, float ctime) {}
void BKE_rigidbody_do_simulation(Scene *scene, float ctime) {}
-#ifdef __GNUC__
+#if defined(__GNUC__) || defined(__clang__)
# pragma GCC diagnostic pop
#endif
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index c0b76aa9cbf..75ddb5e739c 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -552,13 +552,13 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size);
/* UNUSED macro, for function argument */
-#ifdef __GNUC__
+#if defined(__GNUC__) || defined(__clang__)
# define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
#else
# define UNUSED(x) UNUSED_ ## x
#endif
-#ifdef __GNUC__
+#if defined(__GNUC__) || defined(__clang__)
# define UNUSED_FUNCTION(x) __attribute__((__unused__)) UNUSED_ ## x
#else
# define UNUSED_FUNCTION(x) UNUSED_ ## x
diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt
index 5245d24a075..320bebc9958 100644
--- a/source/blender/bmesh/CMakeLists.txt
+++ b/source/blender/bmesh/CMakeLists.txt
@@ -169,7 +169,7 @@ set(SRC
bmesh_tools.h
)
-if(MSVC)
+if(MSVC AND NOT MSVC_CLANG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX /wd4101")
endif()
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 26ce24d5911..e197a8a3a4d 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -3445,7 +3445,7 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const
/* we want the included C files to have warnings enabled but for the generated code
* ignore unused-parameter warnings which are hard to prevent */
-#ifdef __GNUC__
+#if defined( __GNUC__) || defined(__clang__)
fprintf(f, "#pragma GCC diagnostic ignored \"-Wunused-parameter\"\n\n");
#endif
diff --git a/source/blender/python/intern/stubs.c b/source/blender/python/intern/stubs.c
index cc186be60ea..3b3a4d6d2fe 100644
--- a/source/blender/python/intern/stubs.c
+++ b/source/blender/python/intern/stubs.c
@@ -32,7 +32,7 @@
#include "BPY_extern.h"
-#if defined(__GNUC__)
+#if defined(__GNUC__) || defined(__clang__)
# pragma GCC diagnostic error "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wunused-parameter"
#endif