x86-clang-support #120317
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#120317
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "Ben-7/blender:x86-clang-support"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This pull request adds clang on Windows (clang-cl) support for Blender builds. There are some specific steps to get a build working.
Dependencies
Build Steps
In a Visual Studio Developer Prompt, perform the following:
make update
lib\windows_x64
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -T "ClangCl" ..
blender
projectINSTALL
projectTest Coverage
With these instructions the build passes all 280 tests on my machine
Performance
Using the Classroom scene as a reference - available on the demo files page - I am seeing a 5% reduction in render time on both an AMD 7700x and Intel 14900k.
@ -82,0 +81,4 @@
// TBB has a check in tbb/include/task_group.h where __TBB_CPP11_RVALUE_REF_PRESENT should evaluate to true as with
// the other MSVC build. However, because of the clang compiler it does not and we attempt to call a deleted constructor
// in the tbb_task_pool_run function. This check fixes this issue and keeps our Task constructor valid
#if defined(WITH_TBB) && TBB_INTERFACE_VERSION_MAJOR < 10 || defined(_MSC_VER) && defined(__clang__)
I assume it's fixed with newer versions of (one)TBB so it's best to keep this workaround to current version (2020u3 = TBB_INTERFACE_VERSION_MAJOR 11). I propose:
(defined(WITH_TBB) && TBB_INTERFACE_VERSION_MAJOR < 10) || (defined(_MSC_VER) && defined(__clang__) && TBB_INTERFACE_VERSION_MAJOR < 12)
I've committed your recommendation. I attempted to build with the latest version of opentbb and your change in attempt to check if the latest version of tbb fixed the issue. Due to changes in namespaces - e.g.
tbb::task
becomingtbb::detail:d1::task
- I needed to omit the usd library. Then ran into issues with openvdb and an undeclared symbol during linking.However, since building with the latest opentbb headers and the check for
TBB > 12
got all the way to linking without error I assume those errors are related to the libraries and old tbb versions as a dependency.The USD library has open issues for opentbb here and here.
Haven't been able to test, but at first glance there are fewer changes than I feared
@ -78,3 +76,4 @@
${dna_header_string_file}
)
# If the cmake compiler is not the specific match we're looking for (clang-cl compiling on windows)
This smells a little, i made cleanup PR in #120490
I've pulled in new commits from main including that PR and have dropped the commits affecting these lines.
@ -234,0 +230,4 @@
# If the cmake compiler is not the specific match we're looking for (clang-cl compiling on windows)
# we can add these specific files. Otherwise we run into multiple symbol issues due to these
# same files being compiled in bf_intern_guardedalloc.lib
if(NOT(CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC" AND WIN32))
This smells a little, i made cleanup PR in #120490
@ -289,1 +289,4 @@
# If compiling with msvc clang we need to add the D_LIBCPP_VERSION define
# so we don't run into tbb errors when compiling with lib
if(MSVC_CLANG)
if this is TBB specific, test if
WITH_TBB
is on before adding the flagAdded
WITH_TBB
check in 8556e4147f110.@ -1127,1 +1127,3 @@
if(WITH_WINDOWS_RELEASE_STRIPPED_PDB)
# Skip install of stripped pdb if compiling with clang since there doesn't seem
# to be a pdbstripped version for clang-cl
if(WITH_WINDOWS_RELEASE_STRIPPED_PDB AND NOT(CMAKE_C_COMPILER_ID MATCHES "Clang"))
why are you not using
MSVC_CLANG
here?@ -1861,12 +1863,22 @@ endif()
# `vcpkg` substitutes our libraries with theirs, which will cause issues when you you run
# these builds on other systems due to missing DLL's. So we opt out the use of `vcpkg`.
if(WIN32)
# Additional post build step to re-embed the manifest file
Can you see if #111683 also resolves this problem without having a post build step
Your PR resolves the problem without needing the post build step.
However,
blender-launcher
fails to compile properly since the manifest was left as a dependency for it - unsure if that's intentional and haven't tried building it with the msvc compiler. Removing that line fixed the issue for me.Removed the post build and brought in the commit from your PR b44a7169c8117e937c74d1134c7a2f97ae93b8c9.
@ -1868,2 +1879,3 @@
)
if(WITH_WINDOWS_RELEASE_PDB AND WITH_WINDOWS_RELEASE_STRIPPED_PDB)
# If compiling with clang-cl we skip PDBSTRIPPED. There's doesn't seem to be a switch for it currently
if(WITH_WINDOWS_RELEASE_PDB AND WITH_WINDOWS_RELEASE_STRIPPED_PDB AND NOT(CMAKE_C_COMPILER_ID MATCHES "Clang"))
why are you not using
MSVC_CLANG
here?Good question. Switched both checks using
CMAKE_C_COMPILER_ID
toMSVC_CLANG
in 8556e4147f110.What version of llvm/clang did you use for testing? Using my somewhat dated 16.0.0 it wasn't able to successfully build, i'll update to something more recent tomorrow
edit: build with 17.0.6 and vs2022 headers completed successfully, single failed test but i suspect my tests folder may not have been in sync.
I ended up removing the manifest post build step, since ninja wasn't super fond of the syntax there and errored out on it, the resulting binary ran just fine though, maybe it's just a problem with the VS generator?
x86-clang-supportto WIP: x86-clang-support6daa45bdad
to5c3e37dbb3
I also ran into that issue with an older version of clang. If it's necessary to have older clang versions functioning, I can push a fix for the casting errors.
For the manifest post build step: if you have the external manifest in the same directory as
blender.exe
all issues go away. Without the post build step, the manifest being copied into the binary was being malformed. Never figured out the reason why (perhaps related to an llvm resource compiler?) The malformed manifest caused the binary to produce side by side configuration error preventing startup.With commit b44a7169c8117e937c74d1134c7a2f97ae93b8c9 the build process is working fine for
blender.exe
without re-embedding the manifest usingmt.exe
.I'll do another cleanup pass #111683 so we can toggle it on/off on demand, in the mean time small improvement for your patch:
This bit of code will fix
make.bat
so you can just usemake 2022 clang nobuild
to generate the VS project, and you don't have to mess with cmake your self, the oldllvm
toolset can be replaced as it's from a time when llvm still shipped their own bindings given VS ships with a clang workload now, best to prefer that one. (also not entirely convinced llvm still ships bindings these days?)I've landed #111683 which should resolve the manifest issues which can be removed from this PR
@ -1108,1 +1117,3 @@
if(WITH_WINDOWS_RELEASE_STRIPPED_PDB)
# Skip install of stripped pdb if compiling with clang since there doesn't seem
# to be a pdbstripped version for clang-cl
if(WITH_WINDOWS_RELEASE_STRIPPED_PDB AND NOT(MSVC_CLANG))
I'm not sure what the parenthesis adds here, MSVC_CLANG should be an on/off style variable evaluating it first shouldn't change the results, if it's for readability
AND (NOT MSVC_CLANG)
is likely better? but even there i'm not convinced it's needed as it's not followed up by any additional conditions, what was the rationale for adding them?No particular reason. I've removed them in
edd2f667b9
@ -1849,2 +1860,3 @@
)
if(WITH_WINDOWS_RELEASE_PDB AND WITH_WINDOWS_RELEASE_STRIPPED_PDB)
# If compiling with clang-cl we skip PDBSTRIPPED. There's doesn't seem to be a switch for it currently
if(WITH_WINDOWS_RELEASE_PDB AND WITH_WINDOWS_RELEASE_STRIPPED_PDB AND NOT(MSVC_CLANG))
same as above
3395e85656
toedd2f667b9
I've refactored removing all commits associated with the manifest embedding and updated to the current main. I also removed the parentheses for the
NOT(MSVC_CLANG)
cmake sections.I can verify on my side, it continues to build and the binary opens successfully.
WIP: x86-clang-supportto x86-clang-support