openvdb icon indicating copy to clipboard operation
openvdb copied to clipboard

Fix undefined aliasing issue when compiling with clang-cl

Open bgottamd opened this issue 1 year ago • 8 comments

Fixes the inner ValueT alias throw an undefined error when compiling with clang/clang-cl on Windows by converting the convertValue into a template function.

bgottamd avatar Apr 04 '24 22:04 bgottamd

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: bgottamd (776b6fd6beaa4805baf73f0fc731af08659087fd)

Adding a quick bump. This small code change is essential so that Blender can support both clang - merged PR here - and openvdb. Without it, blender fails to build due to the cited issue.

bgottamd avatar Apr 26 '24 16:04 bgottamd

any progress here? We'd like to get this working out of the box for blender, and while i have no issue including selected upstream landed patches for our dependencies, upstream unreviewed patches are a bit of a different story.

LazyDodo avatar Jun 06 '24 20:06 LazyDodo

I've hit the same clang bug before and reported it: llvm/llvm-project#64996. Using -fno-delayed-template-parsing, as was suggested there, makes OpenVDB compile successfully with clang-cl.

jo-rn avatar Jul 05 '24 18:07 jo-rn

Thanks @jo-rn - this does fix the issue with the header file compilation in blender. However, there is some performance degradation when this flag is used:

File args fastest slowest avg
classroom 3840x2160 256 samples header template fix 1209 1217 1213
-fno-delayed-template-parsing 1218 1228 1223

This equates to ~1% drop in performance just from this flag. Hoping this templating change or a modification of the alias can still be merged in.

bgottamd avatar Jul 18 '24 23:07 bgottamd

Odd result, classroom is a blender 2.79 scene, openvdb wasn't integrated till blender 2.83, so the odds of it having an openvdb volume has to be near the low end of things. Did you put the -fno-delayed-template-parsing flag globally on the whole blender project? or isolated it to just the few openvdb related files that needed this fix?

LazyDodo avatar Jul 19 '24 14:07 LazyDodo

I isolated the flag to projects that complained about the header issue. This ended up being only extern_mantaflow and cycles_scene

bgottamd avatar Jul 19 '24 17:07 bgottamd

For those keeping track of this issue affecting Blender, I have created a PR to work around the issue using the approach described in this thread: https://projects.blender.org/blender/blender/pulls/126236

anthony-linaro avatar Aug 13 '24 09:08 anthony-linaro