assimp: work around gcc bug on SuperH
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Sun, 26 Feb 2017 22:38:26 +0000 (23:38 +0100)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Mon, 27 Feb 2017 20:38:49 +0000 (21:38 +0100)
gcc versions earlier than gcc 6.x fail to build assimp on SuperH when
static linking:

  AssxmlExporter.cpp:623:1: error: unable to find a register to spill in class 'GENERAL_REGS'

It's the combination of -Os and *not* having -fPIC that makes gcc
fail, which explains why configurations with dynamic linking work
fine.

 -Os -fPIC -> works
 -Os       -> fails
 -O2 -fPIC -> works
 -O2       -> works

Therefore, as a workaround, we are forcing the use of -O2 on SuperH
when the gcc version is older than gcc 6.x and we're statically
linking.

Fixes:

  http://autobuild.buildroot.net/results/ec88aa8118179e30e24603cc45292047dca19216/

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
package/assimp/assimp.mk

index 08893fff00cc73c23240cbc3d91cdbe2ad534534..298e121cb8678a2950552b4c2f15fb9ef9b1f48b 100644 (file)
@@ -16,6 +16,14 @@ ifeq ($(BR2_m68k),y)
 ASSIMP_CXXFLAGS += -mxgot
 endif
 
+# workaround SuperH compiler failure when static linking (i.e -fPIC is
+# not passed) in gcc versions 5.x or older. The -Os optimization level
+# causes a "unable to find a register to spill in class
+# ‘GENERAL_REGS’" error. -O2 works fine.
+ifeq ($(BR2_sh):$(BR2_STATIC_LIBS):$(BR2_HOST_GCC_AT_LEAST_6),y:y:)
+ASSIMP_CXXFLAGS += -O2
+endif
+
 ASSIMP_CONF_OPTS += -DASSIMP_BUILD_TESTS=OFF \
        -DCMAKE_CXX_FLAGS="$(TARGET_CXXFLAGS) $(ASSIMP_CXXFLAGS)"