Skip to contentSkip to conversation

libfreeimage: add patch to fix x86 build problem

PATCH New Thomas Petazzoni 2 participants 4 messages May 3, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 libfreeimage: add patch to fix x86 build problem

Add a patch to fix an x86 build problem caused by invalid register usage when -fPIC is used.

Fixes:

http://autobuild.buildroot.org/results/fe7/fe72243a84a91b68ef3138847294674b36f16c58/

---
 package/libfreeimage/0002-fix-cpuid-x86.patch | 67 +++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 package/libfreeimage/0002-fix-cpuid-x86.patch
package/libfreeimage/0002-fix-cpuid-x86.patch new file +67 -0
new file mode 100644
index 0000000..98b0e9c
@@ -0,0 +1,67 @@
+Fix build issue caused by invalid register usage on x86
+
+Patch taken from https://github.com/openexr/openexr/issues/128.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+
+Index: b/Source/OpenEXR/IlmImf/ImfSystemSpecific.cpp
+===================================================================
+--- a/Source/OpenEXR/IlmImf/ImfSystemSpecific.cpp
++++ b/Source/OpenEXR/IlmImf/ImfSystemSpecific.cpp
+@@ -40,21 +40,19 @@
+ 
+ namespace {
+ #if defined(IMF_HAVE_SSE2) &&  defined(__GNUC__)
+-
++#include <cpuid.h>
+     // Helper functions for gcc + SSE enabled
+-    void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
++    void cpuid(unsigned int n, unsigned int &eax, unsigned int &ebx,
++					unsigned int &ecx, unsigned int &edx)
+     {
+-        __asm__ __volatile__ (
+-            "cpuid"
+-            : /* Output  */ "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) 
+-            : /* Input   */ "a"(n)
+-            : /* Clobber */);
++		__get_cpuid(n, &eax, &ebx, &ecx, &edx);
+     }
+ 
+ #else // IMF_HAVE_SSE2 && __GNUC__
+ 
+     // Helper functions for generic compiler - all disabled
+-    void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
++    void cpuid(unsigned int n, unsigned int &eax, unsigned int &ebx,
++					unsigned int &ecx, unsigned int &edx)
+     {
+         eax = ebx = ecx = edx = 0;
+     }
+@@ -64,7 +62,7 @@
+ 
+ #ifdef OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
+ 
+-    void xgetbv(int n, int &eax, int &edx)
++    void xgetbv(unsigned int n, unsigned int &eax, unsigned int &edx)
+     {
+         __asm__ __volatile__ (
+             "xgetbv"
+@@ -75,7 +73,7 @@
+ 
+ #else //  OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
+ 
+-    void xgetbv(int n, int &eax, int &edx)
++    void xgetbv(unsigned int n, unsigned int &eax, unsigned int &edx)
+     {
+         eax = edx = 0;
+     }
+@@ -94,8 +92,8 @@
+     f16c(false)
+ {
+     bool osxsave = false;
+-    int  max     = 0;
+-    int  eax, ebx, ecx, edx;
++    unsigned int  max     = 0;
++    unsigned int  eax, ebx, ecx, edx;
+ 
+     cpuid(0, max, ebx, ecx, edx);
+     if (max > 0)
Signature · 1 line
2.1.0
#1 lore raw

PATCH 2/2 libfreeimage: disable on ARC and Blackfin

libfreeimage fails to build on ARC, due to compiler issues:

Error: invalid register number `63'

This should probably be fixed at the compiler level.

It also fails to build on Blackfin, due to numerous libfreeimage issues:

1/ Missing LL suffixes in Source/OpenEXR/IlmImf/ImfFastHuf.cpp. This
can be fixed by backporting upstream OpenEXR commit
https://github.com/openexr/openexr/commit/57ecf581d053f5cacf2e8fc3c024490e0bbe536f.patch.

2/ Invalid characters in libraw_x3f.cpp. This can be fixed by
applying dos2unix on the file.

3/ Usage of too long constants in an unsigned long in
dcraw_common.cpp, in code like "id == 0x4434303430" where id is an "unsigned long" i.e 32 bits on 32 bits platform.

Due to (3) being apparently unsolved upstream, and causing a build error on Blackfin, we disable libfreeimage on this architecture. However, this code seems so broken that making libfreeimage as entirely broken would maybe be a better option.

Fixes:

http://autobuild.buildroot.org/results/b33/b3372581c82786cc0a87f8cc2e78f047cc079255/ (ARC issue)
http://autobuild.buildroot.org/results/f3b/f3bd6be448cffed3caae7850233168e6d0f6a5bd/ (Blackfin issue)

---
 package/libfreeimage/Config.in | 6 ++++++
 1 file changed, 6 insertions(+)
package/libfreeimage/Config.in +6 -0
index 914c0af..04fb278 100644
@@ -2,6 +2,10 @@ config BR2_PACKAGE_LIBFREEIMAGE
 	bool "libfreeimage"
 	depends on BR2_INSTALL_LIBSTDCPP
 	depends on !BR2_STATIC_LIBS
+	# compiler issue: "Error: invalid register number `63'"
+	depends on !BR2_arc
+	# Numerous build issues
+	depends on !BR2_bfin
 	help
 	  FreeImage is an Open Source library project for developers who
 	  would like to support popular graphics image formats like PNG,
@@ -11,4 +15,6 @@ config BR2_PACKAGE_LIBFREEIMAGE
 	  http://freeimage.sourceforge.net
 
 comment "libfreeimage needs a toolchain w/ C++, dynamic library"
+	depends on !BR2_arc
+	depends on !BR2_bfin
 	depends on BR2_STATIC_LIBS || !BR2_INSTALL_LIBSTDCPP
Signature · 1 line
2.1.0
#2 lore raw

PATCH 2/2 libfreeimage: disable on ARC and Blackfin

Quoted 26 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

libfreeimage fails to build on ARC, due to compiler issues:
Error: invalid register number `63'

This should probably be fixed at the compiler level.

It also fails to build on Blackfin, due to numerous libfreeimage issues:

1/ Missing LL suffixes in Source/OpenEXR/IlmImf/ImfFastHuf.cpp. This
can be fixed by backporting upstream OpenEXR commit
https://github.com/openexr/openexr/commit/57ecf581d053f5cacf2e8fc3c024490e0bbe536f.patch.

2/ Invalid characters in libraw_x3f.cpp. This can be fixed by
applying dos2unix on the file.

3/ Usage of too long constants in an unsigned long in
dcraw_common.cpp, in code like "id == 0x4434303430" where id is an "unsigned long" i.e 32 bits on 32 bits platform.

Due to (3) being apparently unsolved upstream, and causing a build error on Blackfin, we disable libfreeimage on this architecture. However, this code seems so broken that making libfreeimage as entirely broken would maybe be a better option.

Quoted 6 lines

Fixes:

http://autobuild.buildroot.org/results/b33/b3372581c82786cc0a87f8cc2e78f047cc079255/ (ARC issue)
http://autobuild.buildroot.org/results/f3b/f3bd6be448cffed3caae7850233168e6d0f6a5bd/ (Blackfin issue)

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH 1/2 libfreeimage: add patch to fix x86 build problem

In reply to Thomas Petazzoni
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Add a patch to fix an x86 build problem caused by invalid register usage when -fPIC is used.

Fixes:

http://autobuild.buildroot.org/results/fe7/fe72243a84a91b68ef3138847294674b36f16c58/

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard