Unbreak the blender build on FreeBSD #37477

Closed
opened 2013-11-15 18:21:51 +01:00 by Marcus von Appen · 21 comments

System: FreeBSD 8.x to -CURRENT, amd64 and i386

Brief:
The current blender release 2.69 is broken on FreeBSD, since the OpenShadingLanguage implementation as well as all upcoming FreeBSD versions (starting with 10.0) will use LLVM and Clang as default compile and linker environment.

Instead of GCC and libstdc++, Clang, Clang++ and LLVM (version 3.3) are used.

Find below links to the current set of patches (against 2.69) that enable blender to build, link and work on FreeBSD.

Patch to remove the hardcoded libstdc++ linker argument. The correct c++ library is picked by the compiler:
http://svnweb.freebsd.org/ports/head/graphics/blender/files/patch-CMakelists.txt?revision=333890&view=co

Fix an issue with clang++ and libc++ in the triangulator code:
http://svnweb.freebsd.org/ports/head/graphics/blender/files/patch-extern_carve_lib_triangulator.cpp?revision=333890&view=co

Fix a libstdc++ specific pass-through that is not covered by the C++ standard using an explicit assignment operator for Range structs:
http://svnweb.freebsd.org/ports/head/graphics/blender/files/patch-extern_rangetree_range_tree.hh?revision=333890&view=co

Fix the itasc KDL::TreeElement implementation by not using SegmentMap, but a standard compliant std::pair implementation.
A minor caveat might be that you can't safely increment/decrement the parent member anymore, but the code does not
use such an approach (and it also would not make any sense to inc/dec over the parent):
http://svnweb.freebsd.org/ports/head/graphics/blender/files/patch-intern_itasc_kdl_tree.hpp?revision=333890&view=co

Fix an issue with libc++ bringing in several parts of C++11 that are already in the std:: namespace. It does not have a std::tr1 namespace
http://svnweb.freebsd.org/ports/head/graphics/blender/files/patch-extern_libmv_third_party_ceres_internal_ceres_collections_port.h?revision=333890&view=co

Furthermore, the current cycles implementation violates the OpenCL standard due to the definition of reserved compiler keywords, such as __global, __local, ... Right now, libc++ only gets hickups with __global and __align, so those were replaced with
cycles_global and cycles_align in the following headers:

  • intern/cycles/util/util_types.h
  • intern/cycles/kernel/kernel_compat_cuda.h
  • intern/cycles/kernel/kernel_displace.h
  • intern/cycles/kernel/kernel_film.h
  • intern/cycles/kernel/kernel_passes.h
  • intern/cycles/kernel/kernel_path.h
  • intern/cycles/kernel/kernel_random.h
System: FreeBSD 8.x to -CURRENT, amd64 and i386 Brief: The current blender release 2.69 is broken on FreeBSD, since the OpenShadingLanguage implementation as well as all upcoming FreeBSD versions (starting with 10.0) will use LLVM and Clang as default compile and linker environment. Instead of GCC and libstdc++, Clang, Clang++ and LLVM (version 3.3) are used. Find below links to the current set of patches (against 2.69) that enable blender to build, link and work on FreeBSD. Patch to remove the hardcoded libstdc++ linker argument. The correct c++ library is picked by the compiler: http://svnweb.freebsd.org/ports/head/graphics/blender/files/patch-CMakelists.txt?revision=333890&view=co Fix an issue with clang++ and libc++ in the triangulator code: http://svnweb.freebsd.org/ports/head/graphics/blender/files/patch-extern_carve_lib_triangulator.cpp?revision=333890&view=co Fix a libstdc++ specific pass-through that is not covered by the C++ standard using an explicit assignment operator for Range structs: http://svnweb.freebsd.org/ports/head/graphics/blender/files/patch-extern_rangetree_range_tree.hh?revision=333890&view=co Fix the itasc KDL::TreeElement implementation by not using SegmentMap, but a standard compliant std::pair implementation. A minor caveat might be that you can't safely increment/decrement the parent member anymore, but the code does not use such an approach (and it also would not make any sense to inc/dec over the parent): http://svnweb.freebsd.org/ports/head/graphics/blender/files/patch-intern_itasc_kdl_tree.hpp?revision=333890&view=co Fix an issue with libc++ bringing in several parts of C++11 that are already in the std:: namespace. It does not have a std::tr1 namespace http://svnweb.freebsd.org/ports/head/graphics/blender/files/patch-extern_libmv_third_party_ceres_internal_ceres_collections_port.h?revision=333890&view=co Furthermore, the current cycles implementation violates the OpenCL standard due to the definition of reserved compiler keywords, such as __global, __local, ... Right now, libc++ only gets hickups with __global and __align, so those were replaced with cycles_global and cycles_align in the following headers: - intern/cycles/util/util_types.h - intern/cycles/kernel/kernel_compat_cuda.h - intern/cycles/kernel/kernel_displace.h - intern/cycles/kernel/kernel_film.h - intern/cycles/kernel/kernel_passes.h - intern/cycles/kernel/kernel_path.h - intern/cycles/kernel/kernel_random.h

Changed status to: 'Open'

Changed status to: 'Open'

Added subscriber: @mva

Added subscriber: @mva

The Range struct fix has already been committed in commit cf9edb2610.

The Range struct fix has already been committed in commit cf9edb2610f51730378029c1c4fa5f12b382664a.

This issue was referenced by blender/blender-addons-contrib@c18712e868

This issue was referenced by blender/blender-addons-contrib@c18712e86814d176433cea781fe1e68715c23bd4

This issue was referenced by c18712e868

This issue was referenced by c18712e86814d176433cea781fe1e68715c23bd4
Brecht Van Lommel self-assigned this 2013-11-25 20:59:42 +01:00

Added subscriber: @Sergey

Added subscriber: @Sergey

@Sergey, the carve and ceres patches look ok to me but I'm not sure what the policy was to commit these things again?

The libstdc++ and itasc changes I can review and commit.

@Sergey, the carve and ceres patches look ok to me but I'm not sure what the policy was to commit these things again? The libstdc++ and itasc changes I can review and commit.

Changes to carve is to be put to extern/carve/patches.

But they're suspicious. You basically disabled that ASSERT for all clang compilers which doesn't define _LIBCPP_VERSION. And the thing is, carve used to compile with Clang here on linux some time ago. This makes me believe this assert would not be compiled with that Clang version which i used here?

Also, is it possible somehow define std::__is_heap to std::is_heap (or maybe other way around) somewhere in the utility/platform header so code itself is free of #ifdef branches?

As for ceres couple of moments:

  • I'm about to upgrade to ceres 1.8.0

  • Changes there i would rather send directly to the upstream

  • Changes like this no-go for the upstream. This is all about making it so CERES_HASH_NAMESPACE_START is defined by the build system. Easy to do with the CMake. With SCons it's a bit more tricky but we have to do it anyway to support MSVC10 there.

    #if defined(_LIBCPP_VERSION)

namespace std {

#else

CERES_HASH_NAMESPACE_START

#endif

  • This is also no-go for the upstream.You are inside #if !defined(CERES_NO_TR1) branch and adds an extra branch inside it to not use TR1. Proper way to do it is to define CERES_NO_TR1 from the build system.This would require re-shuffling includes bliock.

    #if defined(_LIBCPP_VERSION)

template<typename K, typename V>
struct HashMap : std::unordered_map<K, V> {};
template<typename K>
struct HashSet : std::unordered_set<K> {};

#else

template<typename K, typename V>
struct HashMap : std::tr1::unordered_map<K, V> {};
template<typename K>
struct HashSet : std::tr1::unordered_set<K> {};

#endif

  • Also not sure why to move #include
Changes to carve is to be put to extern/carve/patches. But they're suspicious. You basically disabled that ASSERT for all clang compilers which doesn't define _LIBCPP_VERSION. And the thing is, carve used to compile with Clang here on linux some time ago. This makes me believe this assert would not be compiled with that Clang version which i used here? Also, is it possible somehow define std::__is_heap to std::is_heap (or maybe other way around) somewhere in the utility/platform header so code itself is free of #ifdef branches? As for ceres couple of moments: - I'm about to upgrade to ceres 1.8.0 - Changes there i would rather send directly to the upstream - Changes like this no-go for the upstream. This is all about making it so CERES_HASH_NAMESPACE_START is defined by the build system. Easy to do with the CMake. With SCons it's a bit more tricky but we have to do it anyway to support MSVC10 there. #if defined(_LIBCPP_VERSION) ``` namespace std { ``` #else ``` CERES_HASH_NAMESPACE_START ``` #endif - This is also no-go for the upstream.You are inside #if !defined(CERES_NO_TR1) branch and adds an extra branch inside it to not use TR1. Proper way to do it is to define CERES_NO_TR1 from the build system.This would require re-shuffling includes bliock. #if defined(_LIBCPP_VERSION) ``` template<typename K, typename V> struct HashMap : std::unordered_map<K, V> {}; ``` ``` template<typename K> struct HashSet : std::unordered_set<K> {}; ``` #else ``` template<typename K, typename V> struct HashMap : std::tr1::unordered_map<K, V> {}; ``` ``` template<typename K> struct HashSet : std::tr1::unordered_set<K> {}; ``` #endif - Also not sure why to move #include <utilities>

The carve patch could be changed to something like:

+#if defined(__GNUC__) && !defined(_LIBCPP_VERSION)
       CARVE_ASSERT(std::__is_heap(queue.begin(), queue.end(), vertex_info_ordering()));
+#elif defined(__clang__) && defined(_LIBCPP_VERSION)
+      CARVE_ASSERT(std::is_heap(queue.begin(), queue.end(), vertex_info_ordering()));

#endif

     }

At the moment, clang/libcxx also defines GNUC, so a change like the one should work at the moment. I do not know, if and how long GNUC will remain.

Note that the patches are just to make it work, not to be nice and shiny - especially not, if the knowledge about the codebase is limited as it is in my case.

The carve patch could be changed to something like: ``` +#if defined(__GNUC__) && !defined(_LIBCPP_VERSION) CARVE_ASSERT(std::__is_heap(queue.begin(), queue.end(), vertex_info_ordering())); +#elif defined(__clang__) && defined(_LIBCPP_VERSION) + CARVE_ASSERT(std::is_heap(queue.begin(), queue.end(), vertex_info_ordering())); ``` #endif ``` } ``` At the moment, clang/libcxx also defines __GNUC__, so a change like the one should work at the moment. I do not know, if and how long __GNUC__ will remain. Note that the patches are just to make it work, not to be nice and shiny - especially not, if the knowledge about the codebase is limited as it is in my case.
Member

Added subscriber: @Keir

Added subscriber: @Keir
Member

Also note that Ceres has changed the handling of the hash stuff upstream; the proper solution is probably to upgrade Ceres first, then add the appropriate defines.

Also note that Ceres has changed the handling of the hash stuff upstream; the proper solution is probably to upgrade Ceres first, then add the appropriate defines.

@mva as discussed in IRC would try just

  • ifdef _LIBCPP_VERSION
  • define __is_heap is_heap
    #endif

in the beginning of the file. We would need to put it as a patch to extern/carve/patches and list this patch in extern/carve/patches/series.

This i would call as clean as we can be ATM :) Would contact Tobias about this later, maybe he'll have some suggestions about where to put such a things.

@mva as discussed in IRC would try just - ifdef _LIBCPP_VERSION - define __is_heap is_heap #endif in the beginning of the file. We would need to put it as a patch to `extern/carve/patches` and list this patch in `extern/carve/patches/series`. This i would call as clean as we can be ATM :) Would contact Tobias about this later, maybe he'll have some suggestions about where to put such a things.

@Sergey the define on __is_heap works.

@Sergey the define on __is_heap works.

@mva, pushed changes to Carve library, hash dc71cb5f6e.

@mva, pushed changes to Carve library, hash dc71cb5f6e.

Pushed latest Ceres at de6c1c9287. Collections part was re-worked there and since Ceres by itself works fine in FreeBSD hopefully now Blender wil lwork as well :)

Please give it a try and tell how it goes.

Pushed latest Ceres at de6c1c9287. Collections part was re-worked there and since Ceres by itself works fine in FreeBSD hopefully now Blender wil lwork as well :) Please give it a try and tell how it goes.

This issue was referenced by blender/blender-addons-contrib@683093b5c8

This issue was referenced by blender/blender-addons-contrib@683093b5c8df391eac957cfe0c76c33d46c3503e

This issue was referenced by 683093b5c8

This issue was referenced by 683093b5c8df391eac957cfe0c76c33d46c3503e

This issue was referenced by blender/blender-addons-contrib@19a41e5a10

This issue was referenced by blender/blender-addons-contrib@19a41e5a1095504a524333879593b8945fe8ea06

This issue was referenced by 19a41e5a10

This issue was referenced by 19a41e5a1095504a524333879593b8945fe8ea06

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Committed fix for iTaSC as well now, with some modifications.

Thanks for your patches, I think everything has been committed now.

Committed fix for iTaSC as well now, with some modifications. Thanks for your patches, I think everything has been committed now.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
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
EEVEE & Viewport
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
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
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
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#37477
No description provided.