9e8c2e98eb8a2319bfaabe6f36d25838ba98ad58
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / opencv / 0001-core-fix-x86-PIC-code-compilation.patch
1 From ea50be0529c248961e1b66293f8a9e4b807294a6 Mon Sep 17 00:00:00 2001
2 From: Samuel Martin <s.martin49@gmail.com>
3 Date: Sun, 12 Oct 2014 10:17:23 +0200
4 Subject: [PATCH] core: fix x86 PIC code compilation
5
6 This bug was triggered by Buildroot autobuilders [1,2], causing this
7 kind of failures [3,4]:
8
9   [ 14%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/system.cpp.o
10   /home/test/autobuild/instance-0/output/build/opencv-2.4.10/modules/core/src/system.cpp: In function '(static initializers for /home/test/autobuild/instance-0/output/build/opencv-2.4.10/modules/core/src/system.cpp)':
11   /home/test/autobuild/instance-0/output/build/opencv-2.4.10/modules/core/src/system.cpp:280:10: error: inconsistent operand constraints in an 'asm'
12   make[3]: *** [modules/core/CMakeFiles/opencv_core.dir/src/system.cpp.o] Error 1
13
14 [1] http://buildroot.org/
15 [2] http://autobuild.buildroot.org/
16 [3] http://autobuild.buildroot.org/?reason=opencv-2.4.10
17 [4] http://autobuild.buildroot.org/results/483/4838285b25d6293a5cf0bb9eadd5040a7c75d766/build-end.log
18
19 Signed-off-by: Samuel Martin <s.martin49@gmail.com>
20 ---
21  modules/core/src/system.cpp | 5 ++++-
22  1 file changed, 4 insertions(+), 1 deletion(-)
23
24 diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp
25 index 5a970d5..e9ffdc7 100644
26 --- a/modules/core/src/system.cpp
27 +++ b/modules/core/src/system.cpp
28 @@ -267,14 +267,17 @@ struct HWFeatures
29           : "cc"
30          );
31          #else
32 +        // We need to preserve ebx since we are compiling PIC code.
33 +        // This means we cannot use "=b" for the 2nd output register.
34          asm volatile
35          (
36           "pushl %%ebx\n\t"
37           "movl $7,%%eax\n\t"
38           "movl $0,%%ecx\n\t"
39           "cpuid\n\t"
40 +         "movl %%ebx,%1\n\t"
41           "popl %%ebx\n\t"
42 -         : "=a"(cpuid_data[0]), "=b"(cpuid_data[1]), "=c"(cpuid_data[2]), "=d"(cpuid_data[3])
43 +         : "=a"(cpuid_data[0]), "=r"(cpuid_data[1]), "=c"(cpuid_data[2]), "=d"(cpuid_data[3])
44           :
45           : "cc"
46          );
47 -- 
48 2.1.2
49