Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 656580 - opencv-3.4.1: The experimental flag '--expt-relaxed-constexpr' can be used to allow this
Summary: opencv-3.4.1: The experimental flag '--expt-relaxed-constexpr' can be used to...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Amy Liffey
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-26 15:21 UTC by Samuel Bernardo
Modified: 2018-05-31 17:24 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build log file (build.log,733.18 KB, text/x-log)
2018-05-26 15:21 UTC, Samuel Bernardo
Details
emerge --info '=media-libs/opencv-3.4.1::gentoo' (opencv-info.txt,9.42 KB, text/plain)
2018-05-26 15:22 UTC, Samuel Bernardo
Details
emerge -pqv '=media-libs/opencv-3.4.1::gentoo' (opencv-pqv.txt,2.20 KB, text/plain)
2018-05-26 15:23 UTC, Samuel Bernardo
Details
add --expt-relaxed-constexpr to CUDA_NVCC_FLAGS (opencv-3.4.1-cmake.patch,707 bytes, patch)
2018-05-26 16:16 UTC, Samuel Bernardo
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Samuel Bernardo 2018-05-26 15:21:30 UTC
Created attachment 533356 [details]
build log file

Build fails with the following compile error:

/var/tmp/portage/media-libs/opencv-3.4.1/work/opencv-3.4.1/modules/core/include/opencv2/core/cuda/vec_math.hpp(205): error: calling a constexpr __host__ function("abs") from a __device__ function("abs") is not allowed. The experimental flag '--expt-relaxed-constexpr' can be used to allow this.

20 errors detected in the compilation of "/var/tmp/portage/media-libs/opencv-3.4.1/temp/tmpxft_000012a1_00000000-13_row_filter.8uc4.compute_70.cpp1.ii".
-- Removing /var/tmp/portage/media-libs/opencv-3.4.1/work/opencv-3.4.1-abi_x86_64.amd64/modules/cudafilters/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_row_filter.8uc4.cu.o
/usr/bin/cmake -E remove /var/tmp/portage/media-libs/opencv-3.4.1/work/opencv-3.4.1-abi_x86_64.amd64/modules/cudafilters/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_row_filter.8uc4.cu.o
CMake Error at cuda_compile_generated_row_filter.8uc4.cu.o.cmake:266 (message):
  Error generating file
  /var/tmp/portage/media-libs/opencv-3.4.1/work/opencv-3.4.1-abi_x86_64.amd64/modules/cudafilters/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_row_filter.8uc4.cu.o


make[2]: *** [modules/cudafilters/CMakeFiles/opencv_cudafilters.dir/build.make:282: modules/cudafilters/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_row_filter.8uc4.cu.o] Error 1
make[2]: Leaving directory '/var/tmp/portage/media-libs/opencv-3.4.1/work/opencv-3.4.1-abi_x86_64.amd64'
make[1]: *** [CMakeFiles/Makefile2:2860: modules/cudafilters/CMakeFiles/opencv_cudafilters.dir/all] Error 2
make[1]: Leaving directory '/var/tmp/portage/media-libs/opencv-3.4.1/work/opencv-3.4.1-abi_x86_64.amd64'
make: *** [Makefile:163: all] Error 2
Comment 1 Samuel Bernardo 2018-05-26 15:22:30 UTC
Created attachment 533358 [details]
emerge --info '=media-libs/opencv-3.4.1::gentoo'
Comment 2 Samuel Bernardo 2018-05-26 15:23:02 UTC
Created attachment 533360 [details]
emerge -pqv '=media-libs/opencv-3.4.1::gentoo'
Comment 3 Samuel Bernardo 2018-05-26 15:34:51 UTC
There is an issue related to this compile error closed in opencv project on github:

https://github.com/opencv/opencv/issues/8704

The suggestion is:
If I add --expt-relaxed-constexpr to CUDA_NVCC_FLAGS then it compiles.

It seems to be related with opencv not supporting c++11 yet:

> The current OpenCV compilation mode is equal to default settings of system compiler. It is likely C++98 (gnu++98) for Ubuntu/Fedora/etc.
> You should disable C++11 mode during VTK build or enable C++11 mode for in your custom OpenCV build (something like CXXFLAGS="-std=c++11" or gnu++11).
Comment 4 Samuel Bernardo 2018-05-26 16:16:43 UTC
Created attachment 533364 [details, diff]
add --expt-relaxed-constexpr to CUDA_NVCC_FLAGS

I applied this patch to correct the compilation problem.

Now it compiles with C++14, the default in profile 17.0... Let see if the runtime is also working as expected...
Comment 5 Samuel Bernardo 2018-05-26 16:52:48 UTC
After upgrading opencv, vlc-2.2.8 don't compile with the following error:

opencv_example.cpp: In function ‘picture_t* Filter(filter_t*, picture_t*)’:
opencv_example.cpp:203:59: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
             p_sys->event_info.p_region[i].p_description = "Face Detected";
                                                           ^~~~~~~~~~~~~~~
make[5]: Leaving directory '/var/tmp/portage/media-video/vlc-2.2.8-r1/work/vlc-2.2.8/modules/video_filter'

So this opencv upgrade would break at least vlc current stable version in profile 17.0.
Comment 6 Samuel Bernardo 2018-05-26 16:59:44 UTC
(In reply to Samuel Bernardo from comment #5)
> After upgrading opencv, vlc-2.2.8 don't compile with the following error:
> 
> opencv_example.cpp: In function ‘picture_t* Filter(filter_t*, picture_t*)’:
> opencv_example.cpp:203:59: warning: ISO C++ forbids converting a string
> constant to ‘char*’ [-Wwrite-strings]
>              p_sys->event_info.p_region[i].p_description = "Face Detected";
>                                                            ^~~~~~~~~~~~~~~
> make[5]: Leaving directory
> '/var/tmp/portage/media-video/vlc-2.2.8-r1/work/vlc-2.2.8/modules/
> video_filter'
> 
> So this opencv upgrade would break at least vlc current stable version in
> profile 17.0.

Actually the errors of vlc is the following just for reference:

/usr/include/opencv2/core/cvdef.h:485:1: error: unknown type name ‘namespace’                          
 namespace cv {                                                                                        
 ^~~~~~~~~                                                                                             
/usr/include/opencv2/core/cvdef.h:485:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ befor
e ‘{’ token                                                                                            
 namespace cv {                                                                                        
              ^
Comment 7 Samuel Bernardo 2018-05-26 17:16:33 UTC
(In reply to Samuel Bernardo from comment #6)
> 
> Actually the errors of vlc is the following just for reference:
> 
> /usr/include/opencv2/core/cvdef.h:485:1: error: unknown type name
> ‘namespace’                          
>  namespace cv {                                                             
> 
>  ^~~~~~~~~                                                                  
> 
> /usr/include/opencv2/core/cvdef.h:485:14: error: expected ‘=’, ‘,’, ‘;’,
> ‘asm’ or ‘__attribute__’ befor
> e ‘{’ token                                                                 
> 
>  namespace cv {                                                             
> 
>               ^

This is related to C API not being supported in opencv anymore, as mentioned in the following opencv issue:
https://github.com/opencv/opencv/issues/10963

There is a pull request that wasn't accepted since there is problems in runtime with opencv when compiled with C API, as I understood in the above issue.
Pull request to correct C API that will not be accepted:
https://github.com/opencv/opencv/pull/11431
Comment 8 Samuel Bernardo 2018-05-26 18:23:15 UTC
(In reply to Samuel Bernardo from comment #7)
> (In reply to Samuel Bernardo from comment #6)
> > 
> > Actually the errors of vlc is the following just for reference:
> > 
> > /usr/include/opencv2/core/cvdef.h:485:1: error: unknown type name
> > ‘namespace’                          
> >  namespace cv {                                                             
> > 
> >  ^~~~~~~~~                                                                  
> > 
> > /usr/include/opencv2/core/cvdef.h:485:14: error: expected ‘=’, ‘,’, ‘;’,
> > ‘asm’ or ‘__attribute__’ befor
> > e ‘{’ token                                                                 
> > 
> >  namespace cv {                                                             
> > 
> >               ^
> 
> This is related to C API not being supported in opencv anymore, as mentioned
> in the following opencv issue:
> https://github.com/opencv/opencv/issues/10963
> 
> There is a pull request that wasn't accepted since there is problems in
> runtime with opencv when compiled with C API, as I understood in the above
> issue.
> Pull request to correct C API that will not be accepted:
> https://github.com/opencv/opencv/pull/11431

Applying the following opencv-3.4.1 unsupported patch allows to get vlc compiling again:
https://github.com/opencv/opencv/pull/11431.patch

Already tested it and is working.
Comment 9 Amy Liffey gentoo-dev 2018-05-31 06:56:36 UTC
(In reply to Samuel Bernardo from comment #8)
> (In reply to Samuel Bernardo from comment #7)
> > (In reply to Samuel Bernardo from comment #6)
> > > 
> > > Actually the errors of vlc is the following just for reference:
> > > 
> > > /usr/include/opencv2/core/cvdef.h:485:1: error: unknown type name
> > > ‘namespace’                          
> > >  namespace cv {                                                             
> > > 
> > >  ^~~~~~~~~                                                                  
> > > 
> > > /usr/include/opencv2/core/cvdef.h:485:14: error: expected ‘=’, ‘,’, ‘;’,
> > > ‘asm’ or ‘__attribute__’ befor
> > > e ‘{’ token                                                                 
> > > 
> > >  namespace cv {                                                             
> > > 
> > >               ^
> > 
> > This is related to C API not being supported in opencv anymore, as mentioned
> > in the following opencv issue:
> > https://github.com/opencv/opencv/issues/10963
> > 
> > There is a pull request that wasn't accepted since there is problems in
> > runtime with opencv when compiled with C API, as I understood in the above
> > issue.
> > Pull request to correct C API that will not be accepted:
> > https://github.com/opencv/opencv/pull/11431
> 
> Applying the following opencv-3.4.1 unsupported patch allows to get vlc
> compiling again:
> https://github.com/opencv/opencv/pull/11431.patch
> 
> Already tested it and is working.

Is the cuda cmake patch also necessary or not? We do not have cuda for testing right now so I cannot test it. And I got a bit lost in your comments.

Thank you
Comment 10 Larry the Git Cow gentoo-dev 2018-05-31 17:24:54 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fbadf5fc3cdc26df32995e2e1cad1ed47f40efad

commit fbadf5fc3cdc26df32995e2e1cad1ed47f40efad
Author:     Amy Liffey <amynka@gentoo.org>
AuthorDate: 2018-05-31 17:15:58 +0000
Commit:     Amy Liffey <amynka@gentoo.org>
CommitDate: 2018-05-31 17:24:32 +0000

    media-libs/opencv: workaround C compilation mode
    
    - Add nvcc flags to fix compilation with cuda
    - Fix issue with C compilation mode for vlc
    - Fix python installation path
    
    Closes: https://bugs.gentoo.org/656530
    Closes: https://bugs.gentoo.org/656580
    Package-Manager: Portage-2.3.24, Repoman-2.3.6

 .../files/opencv-3.4.1-compilation-C-mode.patch    | 56 ++++++++++++++++++++++
 .../opencv-3.4.1-cuda-add-relaxed-constexpr.patch  | 14 ++++++
 .../opencv-3.4.1-python-lib-suffix-hack.patch      | 13 +++++
 ...encv-3.4.1-r1.ebuild => opencv-3.4.1-r2.ebuild} |  6 ++-
 4 files changed, 88 insertions(+), 1 deletion(-)