linux compilation fixes for GCC 4.5
parent
4458a4e844
commit
9bd5619750
|
@ -1,7 +1,7 @@
|
|||
BUILDDIR = '#build/debug'
|
||||
DISTDIR = '#dist'
|
||||
CXX = 'g++'
|
||||
CC = 'gcc'
|
||||
CXX = 'g++-4.5'
|
||||
CC = 'gcc-4.5'
|
||||
CXXFLAGS = ['-O0', '-Wall', '-g', '-pipe', '-march=nocona', '-msse2', '-ftree-vectorize', '-mfpmath=sse', '-funsafe-math-optimizations', '-fno-rounding-math', '-fno-signaling-nans', '-fomit-frame-pointer', '-DMTS_DEBUG', '-DSINGLE_PRECISION', '-DSPECTRUM_SAMPLES=3', '-DMTS_SSE', '-DMTS_HAS_COHERENT_RT', '-fopenmp']
|
||||
LINKFLAGS = []
|
||||
SHLINKFLAGS = ['-rdynamic', '-shared', '-fPIC']
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
BUILDDIR = '#build/release'
|
||||
DISTDIR = '#dist'
|
||||
CXX = 'g++'
|
||||
CC = 'gcc'
|
||||
CXX = 'g++-4.5'
|
||||
CC = 'gcc-4.5'
|
||||
CXXFLAGS = ['-O3', '-Wall', '-g', '-pipe', '-march=nocona', '-msse2', '-ftree-vectorize', '-mfpmath=sse', '-funsafe-math-optimizations', '-fno-rounding-math', '-fno-signaling-nans', '-fomit-frame-pointer', '-DMTS_DEBUG', '-DSINGLE_PRECISION', '-DSPECTRUM_SAMPLES=3', '-DMTS_SSE', '-DMTS_HAS_COHERENT_RT', '-fopenmp']
|
||||
LINKFLAGS = []
|
||||
SHLINKFLAGS = ['-rdynamic', '-shared', '-fPIC']
|
||||
|
|
|
@ -130,6 +130,12 @@
|
|||
/* Compile with Boost filesystem v2 */
|
||||
#define BOOST_FILESYSTEM_VERSION 2
|
||||
|
||||
/* Use ELF support for thread-local storage on Linux? This
|
||||
* is potentially faster but causes problems when dynamically
|
||||
* loading Mitsuba from Python, so let's keep it disabled for now
|
||||
*/
|
||||
#define MTS_USE_ELF_TLS 0
|
||||
|
||||
#include <string>
|
||||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
|
|
@ -80,12 +80,12 @@ public:
|
|||
inline int getStackSize() const { return m_stackSize; }
|
||||
|
||||
/// Return the thread ID
|
||||
#if defined(__OSX__)
|
||||
inline static int getID() { return getThread()->m_id; }
|
||||
#elif defined(WIN32)
|
||||
#if defined(WIN32)
|
||||
inline static int getID() { return (int) GetCurrentThreadId(); }
|
||||
#else
|
||||
#elif MTS_USE_ELF_TLS == 1
|
||||
inline static int getID() { return m_id; }
|
||||
#else
|
||||
inline static int getID() { return getThread()->m_id; }
|
||||
#endif
|
||||
|
||||
/// Return the name of this thread
|
||||
|
@ -184,11 +184,12 @@ private:
|
|||
#if defined(__LINUX__) || defined(__OSX__)
|
||||
static int m_idCounter;
|
||||
static ref<Mutex> m_idMutex;
|
||||
#endif
|
||||
#if defined(__OSX__)
|
||||
#if MTS_USE_ELF_TLS == 1
|
||||
static __thread int m_id
|
||||
__attribute__((tls_model("global-dynamic")));
|
||||
#else
|
||||
int m_id;
|
||||
#elif defined(__LINUX__)
|
||||
static int __thread m_id;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -62,8 +62,9 @@ int Thread::m_idCounter;
|
|||
ref<Mutex> Thread::m_idMutex;
|
||||
#endif
|
||||
|
||||
#if defined(__LINUX__)
|
||||
int __thread __attribute__((tls_model("initial-exec"))) Thread::m_id;
|
||||
#if MTS_USE_ELF_TLS == 1
|
||||
__thread int Thread::m_id
|
||||
__attribute__((tls_model("global-dynamic")));
|
||||
#endif
|
||||
|
||||
Thread::Thread(const std::string &name, unsigned int stackSize)
|
||||
|
@ -72,7 +73,7 @@ Thread::Thread(const std::string &name, unsigned int stackSize)
|
|||
m_joinMutex = new Mutex();
|
||||
memset(&m_thread, 0, sizeof(pthread_t));
|
||||
}
|
||||
|
||||
|
||||
void Thread::start() {
|
||||
if (m_running)
|
||||
Log(EError, "Thread is already running!");
|
||||
|
@ -155,14 +156,14 @@ void *Thread::dispatch(void *par) {
|
|||
if (thread->getPriority() != ENormalPriority)
|
||||
thread->setPriority(thread->getPriority());
|
||||
|
||||
#if defined(__OSX__)
|
||||
m_idMutex->lock();
|
||||
thread->m_id = ++m_idCounter;
|
||||
m_idMutex->unlock();
|
||||
#elif defined(__LINUX__)
|
||||
#if MTS_USE_ELF_TLS == 1
|
||||
m_idMutex->lock();
|
||||
m_id = ++m_idCounter;
|
||||
m_idMutex->unlock();
|
||||
#elif defined(__LINUX__) or defined(__OSX__)
|
||||
m_idMutex->lock();
|
||||
thread->m_id = ++m_idCounter;
|
||||
m_idMutex->unlock();
|
||||
#endif
|
||||
|
||||
try {
|
||||
|
@ -263,22 +264,24 @@ void Thread::staticInitialization() {
|
|||
#endif
|
||||
|
||||
m_self = new ThreadLocal<Thread>();
|
||||
Thread *mainThread = new MainThread();
|
||||
#if defined(__LINUX__) || defined(__OSX__)
|
||||
m_idMutex = new Mutex();
|
||||
m_idCounter = 0;
|
||||
|
||||
#if MTS_USE_ELF_TLS == 1
|
||||
m_id = 0;
|
||||
#else
|
||||
mainThread->m_id = 0;
|
||||
#endif
|
||||
#endif
|
||||
Thread *mainThread = new MainThread();
|
||||
mainThread->m_running = true;
|
||||
mainThread->m_thread = pthread_self();
|
||||
mainThread->m_joinMutex = new Mutex();
|
||||
mainThread->m_joined = false;
|
||||
mainThread->m_fresolver = new FileResolver();
|
||||
m_self->set(mainThread);
|
||||
#if defined(__OSX__)
|
||||
mainThread->m_id = 0;
|
||||
#elif defined(__LINUX__)
|
||||
m_id = 0;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static std::vector<OpenMPThread *> __ompThreads;
|
||||
|
|
|
@ -65,6 +65,10 @@ BOOST_PYTHON_MODULE(mtspy) {
|
|||
def("initializeFramework", initializeFramework);
|
||||
def("shutdownFramework", shutdownFramework);
|
||||
|
||||
class_<ref<Object>, boost::noncopyable>("Object");
|
||||
// .def("getRefCount", &Object::getRefCount)
|
||||
// .def("toString", &Object::toString);
|
||||
|
||||
class_<Vector2>("Vector2", init<Float, Float>())
|
||||
.def(init<Float>())
|
||||
.def(init<Point2>())
|
||||
|
|
|
@ -2,7 +2,7 @@ Import('env', 'plugins')
|
|||
|
||||
plugins += env.SharedLibrary('obj', ['obj.cpp'])
|
||||
plugins += env.SharedLibrary('ply', ['ply/ply.cpp', 'ply/ply_parser.cpp'],
|
||||
CPPPATH = env['CPPPATH'] + ['ply'])
|
||||
CPPPATH = env['CPPPATH'] + ['ply', '#dependencies'])
|
||||
plugins += env.SharedLibrary('serialized', ['serialized.cpp'])
|
||||
plugins += env.SharedLibrary('sphere', ['sphere.cpp'])
|
||||
plugins += env.SharedLibrary('cylinder', ['cylinder.cpp'])
|
||||
|
|
|
@ -23,16 +23,6 @@
|
|||
#include <mitsuba/core/timer.h>
|
||||
#include <ply/ply_parser.hpp>
|
||||
|
||||
#if defined(__clang__)
|
||||
#define MTS_USE_BOOST_TR1 (!__has_feature(cxx_variadic_templates))
|
||||
#else
|
||||
# if defined(_MSC_VER) && (_MSC_VER < 1600)
|
||||
# define MTS_USE_BOOST_TR1 1
|
||||
# else
|
||||
# define MTS_USE_BOOST_TR1 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if MTS_USE_BOOST_TR1
|
||||
# if defined(Float)
|
||||
# define MTS_Float
|
||||
|
|
|
@ -12,16 +12,21 @@
|
|||
#if defined(__clang__)
|
||||
#define MTS_USE_BOOST_TR1 (!__has_feature(cxx_variadic_templates))
|
||||
#else
|
||||
# if defined(_MSC_VER) && (_MSC_VER < 1600)
|
||||
# define MTS_USE_BOOST_TR1 1
|
||||
# if defined(_MSC_VER)
|
||||
# if _MSC_VER < 1600
|
||||
# define MTS_USE_BOOST_TR1 1
|
||||
# else
|
||||
# define MTS_USE_BOOST_TR1 0
|
||||
# endif
|
||||
# else
|
||||
# define MTS_USE_BOOST_TR1 0
|
||||
# define MTS_USE_BOOST_TR1 0
|
||||
# endif
|
||||
#define ADT_WORKAROUND 1
|
||||
#endif
|
||||
|
||||
#if defined(__INTEL_COMPILER)
|
||||
#define ADT_WORKAROUND 1
|
||||
#else
|
||||
#define ADT_WORKAROUND 0
|
||||
#endif
|
||||
|
||||
#if MTS_USE_BOOST_TR1
|
||||
|
@ -123,7 +128,7 @@ public:
|
|||
{
|
||||
return static_cast<callbacks_element<ScalarType>&>(callbacks_).callback;
|
||||
}
|
||||
#if !defined(ADT_WORKAROUND)
|
||||
#if ADT_WORKAROUND == 0
|
||||
template <typename ScalarType>
|
||||
friend typename scalar_property_definition_callback_type<ScalarType>::type& at(scalar_property_definition_callbacks_type& scalar_property_definition_callbacks)
|
||||
{
|
||||
|
@ -215,7 +220,7 @@ public:
|
|||
{
|
||||
return static_cast<const callbacks_element<boost::mpl::pair<SizeType, ScalarType> >&>(callbacks_).callback;
|
||||
}
|
||||
#if !defined(ADT_WORKAROUND)
|
||||
#if ADT_WORKAROUND == 0
|
||||
template <typename SizeType, typename ScalarType>
|
||||
friend typename list_property_definition_callback_type<SizeType, ScalarType>::type& at(list_property_definition_callbacks_type& list_property_definition_callbacks)
|
||||
{
|
||||
|
@ -554,7 +559,7 @@ inline bool ply::ply_parser::parse_list_property(format_type format, std::istrea
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(ADT_WORKAROUND)
|
||||
#if ADT_WORKAROUND == 1
|
||||
// Horrible workaround for ADT failure as of Clang 2.8
|
||||
namespace ply
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue