Page MenuHome

Unbreak the blender build on FreeBSD
Closed, ResolvedPublicPATCH


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

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:

Fix an issue with clang++ and libc++ in the triangulator code:

Fix a libstdc++ specific pass-through that is not covered by the C++ standard using an explicit assignment operator for Range structs:

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):

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

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

Event Timeline

Marcus von Appen (mva) raised the priority of this task from to 90.
Marcus von Appen (mva) updated the task description. (Show Details)
Marcus von Appen (mva) edited a custom field.

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

Brecht Van Lommel (brecht) lowered the priority of this task from 90 to Normal.

@Sergey Sharybin (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 <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()));

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.

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.

@Marcus von Appen (mva) as discussed in IRC would try just

#  define __is_heap is_heap

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.

Pushed latest Ceres at rBde6c1c928784. 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.

Brecht Van Lommel (brecht) changed the task status from Unknown Status to Resolved.Nov 28 2013, 9:44 PM

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

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

Brecht Van Lommel (brecht) edited this Maniphest Task.
Brecht Van Lommel (brecht) edited this Maniphest Task.