mirror of
https://projects.blender.org/blender/blender.git
synced 2025-01-22 07:22:12 -05:00
Windows: Enable clang-cl for ARM64
This gets Windows ARM64 to compile with clang-cl, which gives up to 40% performance improvements in certain scenes rendered with cycles, compared to MSVC. This is all tested using LLVM 18.1.8 and a VS2022 `vcvarsall` window. Subsequent PRs with various lib version updates, etc to go in at a later point. Pull Request: https://projects.blender.org/blender/blender/pulls/124182
This commit is contained in:
parent
f30689e12c
commit
9576576039
7 changed files with 38 additions and 7 deletions
|
@ -410,6 +410,10 @@ option(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" ON)
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
option(WITH_OPENMP_STATIC "Link OpenMP statically (only used by the release environment)" OFF)
|
option(WITH_OPENMP_STATIC "Link OpenMP statically (only used by the release environment)" OFF)
|
||||||
mark_as_advanced(WITH_OPENMP_STATIC)
|
mark_as_advanced(WITH_OPENMP_STATIC)
|
||||||
|
elseif(WIN32 AND CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64")
|
||||||
|
# At time of testing (LLVM 18.1.6) OMP is not included in public LLVM builds for Windows ARM64
|
||||||
|
set(WITH_OPENMP OFF)
|
||||||
|
set(WITH_OPENMP_STATIC OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WITH_GHOST_X11)
|
if(WITH_GHOST_X11)
|
||||||
|
@ -2167,6 +2171,9 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||||
C_WARN_CLANG_CL_BITFIELD_ENUM_CONVERSION -Wno-bitfield-enum-conversion # 1
|
C_WARN_CLANG_CL_BITFIELD_ENUM_CONVERSION -Wno-bitfield-enum-conversion # 1
|
||||||
C_WARN_CLANG_CL_UNUSED_LAMBDA_CAPTURE -Wno-unused-lambda-capture # 1
|
C_WARN_CLANG_CL_UNUSED_LAMBDA_CAPTURE -Wno-unused-lambda-capture # 1
|
||||||
C_WARN_CLANG_CL_SHADOW_FIELD_IN_CONSTRUCTOR_MODIFIED -Wno-shadow-field-in-constructor-modified # 1
|
C_WARN_CLANG_CL_SHADOW_FIELD_IN_CONSTRUCTOR_MODIFIED -Wno-shadow-field-in-constructor-modified # 1
|
||||||
|
# And some additional ones that came up when using LLVM 18.1.8 on Windows ARM64
|
||||||
|
C_WARN_CLANG_CL_SWITCH_DEFAULT -Wno-switch-default
|
||||||
|
C_WARN_CLANG_CL_NAN_INFINITY_DISABLED -Wno-nan-infinity-disabled
|
||||||
)
|
)
|
||||||
|
|
||||||
add_check_cxx_compiler_flags(
|
add_check_cxx_compiler_flags(
|
||||||
|
@ -2298,6 +2305,9 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||||
CXX_WARN_CLANG_CL_BITFIELD_ENUM_CONVERSION -Wno-bitfield-enum-conversion # 1
|
CXX_WARN_CLANG_CL_BITFIELD_ENUM_CONVERSION -Wno-bitfield-enum-conversion # 1
|
||||||
CXX_WARN_CLANG_CL_UNUSED_LAMBDA_CAPTURE -Wno-unused-lambda-capture # 1
|
CXX_WARN_CLANG_CL_UNUSED_LAMBDA_CAPTURE -Wno-unused-lambda-capture # 1
|
||||||
CXX_WARN_CLANG_CL_SHADOW_FIELD_IN_CONSTRUCTOR_MODIFIED -Wno-shadow-field-in-constructor-modified # 1
|
CXX_WARN_CLANG_CL_SHADOW_FIELD_IN_CONSTRUCTOR_MODIFIED -Wno-shadow-field-in-constructor-modified # 1
|
||||||
|
# And some additional ones that came up when using LLVM 18.1.8 on Windows ARM64
|
||||||
|
CXX_WARN_CLANG_CL_SWITCH_DEFAULT -Wno-switch-default
|
||||||
|
CXX_WARN_CLANG_CL_NAN_INFINITY_DISABLED -Wno-nan-infinity-disabled
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -180,8 +180,8 @@ remove_cc_flag(
|
||||||
)
|
)
|
||||||
|
|
||||||
if(MSVC_CLANG) # Clangs version of cl doesn't support all flags
|
if(MSVC_CLANG) # Clangs version of cl doesn't support all flags
|
||||||
string(APPEND CMAKE_CXX_FLAGS " ${CXX_WARN_FLAGS} /nologo /J /Gd /EHsc -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference ")
|
string(APPEND CMAKE_CXX_FLAGS " ${CXX_WARN_FLAGS} /nologo /J /Gd /EHsc -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference /clang:-funsigned-char /clang:-fno-strict-aliasing /clang:-ffp-contract=off")
|
||||||
string(APPEND CMAKE_C_FLAGS " /nologo /J /Gd -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference")
|
string(APPEND CMAKE_C_FLAGS " /nologo /J /Gd -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference /clang:-funsigned-char /clang:-fno-strict-aliasing /clang:-ffp-contract=off")
|
||||||
else()
|
else()
|
||||||
string(APPEND CMAKE_CXX_FLAGS " /nologo /J /Gd /MP /EHsc /bigobj")
|
string(APPEND CMAKE_CXX_FLAGS " /nologo /J /Gd /MP /EHsc /bigobj")
|
||||||
string(APPEND CMAKE_C_FLAGS " /nologo /J /Gd /MP /bigobj")
|
string(APPEND CMAKE_C_FLAGS " /nologo /J /Gd /MP /bigobj")
|
||||||
|
|
|
@ -37,9 +37,14 @@ set LLVM_DIR=
|
||||||
:DetectionComplete
|
:DetectionComplete
|
||||||
set CC=%LLVM_DIR%\bin\clang-cl
|
set CC=%LLVM_DIR%\bin\clang-cl
|
||||||
set CXX=%LLVM_DIR%\bin\clang-cl
|
set CXX=%LLVM_DIR%\bin\clang-cl
|
||||||
rem build and tested against 2019 16.2
|
if "%PROCESSOR_ARCHITECTURE%" == "ARM64" (
|
||||||
set CFLAGS=-m64 -fmsc-version=1922
|
set CFLAGS=-m64
|
||||||
set CXXFLAGS=-m64 -fmsc-version=1922
|
set CXXFLAGS=-m64
|
||||||
|
) else (
|
||||||
|
rem build and tested against 2019 16.2
|
||||||
|
set CFLAGS=-m64 -fmsc-version=1922
|
||||||
|
set CXXFLAGS=-m64 -fmsc-version=1922
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if "%WITH_ASAN%"=="1" (
|
if "%WITH_ASAN%"=="1" (
|
||||||
|
|
2
extern/lzma/LzFind.c
vendored
2
extern/lzma/LzFind.c
vendored
|
@ -625,7 +625,7 @@ void MatchFinder_Init(CMatchFinder *p)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) && defined(MY_CPU_ARM64)
|
#if defined(_MSC_VER) && defined(MY_CPU_ARM64) && !defined(__clang__)
|
||||||
#include <arm64_neon.h>
|
#include <arm64_neon.h>
|
||||||
#else
|
#else
|
||||||
#include <arm_neon.h>
|
#include <arm_neon.h>
|
||||||
|
|
3
extern/lzma/README.blender
vendored
3
extern/lzma/README.blender
vendored
|
@ -2,7 +2,8 @@ Project: LZMA SDK
|
||||||
URL: https://www.7-zip.org/sdk.html
|
URL: https://www.7-zip.org/sdk.html
|
||||||
License: Public Domain
|
License: Public Domain
|
||||||
Upstream version: 23.01
|
Upstream version: 23.01
|
||||||
Local modifications: No code changes
|
Local modifications:
|
||||||
|
* Update LzFind.c to find the correct NEON header when using clang-cl + Windows ARM64
|
||||||
|
|
||||||
- Took only files needed for Blender: C source for raw LZMA1 encoder/decoder.
|
- Took only files needed for Blender: C source for raw LZMA1 encoder/decoder.
|
||||||
- CMakeLists.txt is made for Blender codebase
|
- CMakeLists.txt is made for Blender codebase
|
||||||
|
|
13
extern/lzma/patches/lzma.diff
vendored
Normal file
13
extern/lzma/patches/lzma.diff
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
diff --git a/extern/lzma/LzFind.c b/extern/lzma/LzFind.c
|
||||||
|
index 0fbd5aae563..94b4879cfdc 100644
|
||||||
|
--- a/extern/lzma/LzFind.c
|
||||||
|
+++ b/extern/lzma/LzFind.c
|
||||||
|
@@ -625,7 +625,7 @@ void MatchFinder_Init(CMatchFinder *p)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
- #if defined(_MSC_VER) && defined(MY_CPU_ARM64)
|
||||||
|
+ #if defined(_MSC_VER) && defined(MY_CPU_ARM64) && !defined(__clang__)
|
||||||
|
#include <arm64_neon.h>
|
||||||
|
#else
|
||||||
|
#include <arm_neon.h>
|
|
@ -446,6 +446,8 @@ endif()
|
||||||
if(WITH_CYCLES_BLENDER)
|
if(WITH_CYCLES_BLENDER)
|
||||||
# Not needed to make cycles automated tests pass with -march=native.
|
# Not needed to make cycles automated tests pass with -march=native.
|
||||||
# However Blender itself needs this flag.
|
# However Blender itself needs this flag.
|
||||||
|
# Note: the clang-cl style removal must go first, to avoid a dangling "/clang:"
|
||||||
|
remove_cc_flag("/clang:-ffp-contract=off")
|
||||||
remove_cc_flag("-ffp-contract=off")
|
remove_cc_flag("-ffp-contract=off")
|
||||||
add_definitions(-DWITH_BLENDER_GUARDEDALLOC)
|
add_definitions(-DWITH_BLENDER_GUARDEDALLOC)
|
||||||
add_subdirectory(blender)
|
add_subdirectory(blender)
|
||||||
|
|
Loading…
Reference in a new issue