Skip to contentSkip to conversation

opencv: Fix build with gcc 6.0

PATCH In review Ricardo Ribalda Delgado 3 participants 6 messages Aug 5, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 opencv: Fix build with gcc 6.0

It seems like gcc 6.0 does not have the same behaviour as previous 5.x with regards isystem flag.

---
 .../recipes-support/opencv/opencv/fixgcc60.patch   | 30 ++++++++++++++++++++++
 meta-oe/recipes-support/opencv/opencv_3.1.bb       |  4 +--
 2 files changed, 31 insertions(+), 3 deletions(-)
 create mode 100644 meta-oe/recipes-support/opencv/opencv/fixgcc60.patch
meta-oe/recipes-support/opencv/opencv/fixgcc60.patch new file +30 -0
new file mode 100644
index 000000000000..5d0bf97cab63
@@ -0,0 +1,30 @@
+diff --git a/cmake/OpenCVPCHSupport.cmake b/cmake/OpenCVPCHSupport.cmake
+index 28ccc1c6be4f..b0e1cbf77287 100644
+--- a/cmake/OpenCVPCHSupport.cmake
++++ b/cmake/OpenCVPCHSupport.cmake
+@@ -19,7 +19,7 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
+         ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
+         OUTPUT_VARIABLE gcc_compiler_version)
+     #MESSAGE("GCC Version: ${gcc_compiler_version}")
+-    IF(gcc_compiler_version VERSION_GREATER "4.2.-1")
++    IF(gcc_compiler_version VERSION_GREATER "4.2.-1" AND gcc_compiler_version VERSION_LESS "6.0.0")
+         SET(PCHSupport_FOUND TRUE)
+     ENDIF()
+ 
+diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake
+index 3a23cd73633d..1fea1578b1d9 100644
+--- a/cmake/OpenCVUtils.cmake
++++ b/cmake/OpenCVUtils.cmake
+@@ -76,7 +76,11 @@ function(ocv_include_directories)
+     if("${__abs_dir}" MATCHES "^${OpenCV_SOURCE_DIR}" OR "${__abs_dir}" MATCHES "^${OpenCV_BINARY_DIR}")
+       list(APPEND __add_before "${dir}")
+     else()
+-      include_directories(AFTER SYSTEM "${dir}")
++	    if (gcc_compiler_version VERSION_LESS "6.0.0")
++		    include_directories(AFTER SYSTEM "${dir}")
++	    else()
++		    include_directories(AFTER "${dir}")
++	    endif()
+     endif()
+   endforeach()
+   include_directories(BEFORE ${__add_before})
meta-oe/recipes-support/opencv/opencv_3.1.bb +1 -3
index c41baec7bba8..8ab9a2b4e071 100644
@@ -22,6 +22,7 @@ SRC_URI = "git://github.com/Itseez/opencv.git;name=opencv \
             git://github.com/Itseez/opencv_contrib.git;destsuffix=contrib;name=contrib \
             git://github.com/Itseez/opencv_3rdparty.git;branch=ippicv/master_20151201;destsuffix=party3;name=party3 \
             file://0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch \
+            file://fixgcc60.patch \
             file://fixpkgconfig.patch"
 
 PV = "3.1+git${SRCPV}"
@@ -145,6 +146,3 @@ do_install_append() {
     install -d ${D}${datadir}/OpenCV/samples/bin/
     cp -f bin/*-tutorial-* bin/*-example-* ${D}${datadir}/OpenCV/samples/bin/
 }
-
-# http://errors.yoctoproject.org/Errors/Details/68617/
-PNBLACKLIST[opencv] ?= "BROKEN: fails to build with gcc-6"
Signature · 1 line
2.8.1
#2 lore raw
In reply to Ricardo Ribalda Delgado
Quoted 36 lines · Ricardo Ribalda Delgado

It seems like gcc 6.0 does not have the same behaviour as previous 5.x with regards isystem flag.

---
.../recipes-support/opencv/opencv/fixgcc60.patch | 30 ++++++++++++++++++++++
meta-oe/recipes-support/opencv/opencv_3.1.bb | 4 +--

2 files changed, 31 insertions(+), 3 deletions(-)

create mode 100644 meta-oe/recipes-support/opencv/opencv/fixgcc60.patch

meta-oe/recipes-support/opencv/opencv/fixgcc60.patch new file +17 -0
new file mode 100644
index 000000000000..5d0bf97cab63
@@ -0,0 +1,30 @@
+diff --git a/cmake/OpenCVPCHSupport.cmake b/cmake/OpenCVPCHSupport.cmake
+index 28ccc1c6be4f..b0e1cbf77287 100644
+--- a/cmake/OpenCVPCHSupport.cmake
++++ b/cmake/OpenCVPCHSupport.cmake
+@@ -19,7 +19,7 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
+         ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
+         OUTPUT_VARIABLE gcc_compiler_version)
+     #MESSAGE("GCC Version: ${gcc_compiler_version}")
+-    IF(gcc_compiler_version VERSION_GREATER "4.2.-1")
++    IF(gcc_compiler_version VERSION_GREATER "4.2.-1" AND gcc_compiler_version VERSION_LESS "6.0.0")
+         SET(PCHSupport_FOUND TRUE)
+     ENDIF()
+
+diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake
+index 3a23cd73633d..1fea1578b1d9 100644
+--- a/cmake/OpenCVUtils.cmake
++++ b/cmake/OpenCVUtils.cmake

meta-oe/recipes-support/opencv/opencv/fixgcc60.patch line 27

Quoted 10 lines
meta-oe/recipes-support/opencv/opencv/fixgcc60.patch new file +10 -0
+@@ -76,7 +76,11 @@ function(ocv_include_directories)
+     if("${__abs_dir}" MATCHES "^${OpenCV_SOURCE_DIR}" OR "${__abs_dir}" MATCHES "^${OpenCV_BINARY_DIR}")
+       list(APPEND __add_before "${dir}")
+     else()
+-      include_directories(AFTER SYSTEM "${dir}")
++	    if (gcc_compiler_version VERSION_LESS "6.0.0")
++		    include_directories(AFTER SYSTEM "${dir}")
++	    else()
++		    include_directories(AFTER "${dir}")
++	    endif()

I would rather prefer to see if need for -isystem can be completely removed.

Quoted 25 lines
meta-oe/recipes-support/opencv/opencv/fixgcc60.patch new file +3 -0
+     endif()
+   endforeach()
+   include_directories(BEFORE ${__add_before})
meta-oe/recipes-support/opencv/opencv_3.1.bb +1 -0
index c41baec7bba8..8ab9a2b4e071 100644
@@ -22,6 +22,7 @@ SRC_URI = "git://github.com/Itseez/opencv.git;name=opencv \
            git://github.com/Itseez/opencv_contrib.git;destsuffix=contrib;name=contrib \
            git://github.com/Itseez/opencv_3rdparty.git;branch=ippicv/master_20151201;destsuffix=party3;name=party3 \
            file://0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch \
+            file://fixgcc60.patch \
            file://fixpkgconfig.patch"
 

PV = "3.1+git${SRCPV}"

meta-oe/recipes-support/opencv/opencv_3.1.bb +0 -4
@@ -145,6 +146,3 @@ do_install_append() {
    install -d ${D}${datadir}/OpenCV/samples/bin/
    cp -f bin/*-tutorial-* bin/*-example-* ${D}${datadir}/OpenCV/samples/bin/
 }
-
-# http://errors.yoctoproject.org/Errors/Details/68617/
-PNBLACKLIST[opencv] ?= "BROKEN: fails to build with gcc-6"
--

2.8.1

#3 lore raw

Hi Raj

Quoted 10 lines · Khem Raj
Quoted 10 lines
meta-oe/recipes-support/opencv/opencv/fixgcc60.patch new file +9 -0
+
+diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake
+index 3a23cd73633d..1fea1578b1d9 100644
+--- a/cmake/OpenCVUtils.cmake
++++ b/cmake/OpenCVUtils.cmake
+@@ -76,7 +76,11 @@ function(ocv_include_directories)
+     if("${__abs_dir}" MATCHES "^${OpenCV_SOURCE_DIR}" OR "${__abs_dir}" MATCHES "^${OpenCV_BINARY_DIR}")
+       list(APPEND __add_before "${dir}")
+     else()
Quoted 8 lines
Quoted 6 lines
+-      include_directories(AFTER SYSTEM "${dir}")
++        if (gcc_compiler_version VERSION_LESS "6.0.0")
++                include_directories(AFTER SYSTEM "${dir}")
++        else()
++                include_directories(AFTER "${dir}")
++        endif()

I would rather prefer to see if need for -isystem can be completely removed.

I googled a bit, and they use -isystem to avoid that warnings from system files scalate into build errors :S.
I prefer only modify the build with the compilers that crashes and for the others keep the upstream behaviour.

Regards!

#4 lore raw
In reply to Ricardo Ribalda Delgado
Quoted 4 lines · Ricardo Ribalda Delgado

It seems like gcc 6.0 does not have the same behaviour as previous 5.x with regards isystem flag.

Did you check if there is a new release? it may fix this error as well.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#5 lore raw

Hi Otavio

Quoted 8 lines · Otavio Salvador
Quoted 4 lines · Ricardo Ribalda Delgado

It seems like gcc 6.0 does not have the same behaviour as previous 5.x with regards isystem flag.

Did you check if there is a new release? it may fix this error as well.

There is no new release, 3.1 is still the latest version.

The master branch from their github also fails to build and has a patch that fixes the OpenCVPCHSupport.cmake file but not the other.

Regards!