Created attachment 287271 [details] build log with makeopts="-j1" media-libs/opencv-2.3.0 fails to merge with hardened-gcc-4.6.1 throwing the following error: [ 3%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/datastructs.o x86_64-pc-linux-gnu-g++: internal compiler error: Segmentation fault (program cc1plus) I found the following line in my grsec.log just before the segfault of gcc: Sep 21 14:09:32 localhost kernel: [189657.889988] grsec: denied RWX mmap of <anonymous mapping> by /usr/bin/python2.7[python2.7:13465] uid/euid:250/250 gid/egid:250/250, parent /usr/bin/cmake[cmake:13208] uid/euid:250/250 gid/egid:250/250 This seems to be correlated. Switching to vanilla-gcc-4.6.1 causes opencv to merge fine. The problem occurred also with opencv-2.2.0.
Created attachment 287273 [details] emerge --info
It seems to be related to ssp. With hardened-nopie-gcc-4.6.1 I see the same error, but with hardened-nossp-gcc-4.6.1 I see a different error connected to linking as follows. Finally when using hardened-nopie-nossp-gcc-4.6.1 the build is successful. Building CXX object modules/traincascade/CMakeFiles/opencv_traincascade.dir/imagestorage.o /var/tmp/portage/media-libs/opencv-2.3.0/work/OpenCV-2.3.0/modules/traincascade/imagestorage.cpp: In member function ‘bool CvCascadeImageReader::PosReader::get(cv::Mat&)’: /var/tmp/portage/media-libs/opencv-2.3.0/work/OpenCV-2.3.0/modules/traincascade/imagestorage.cpp:153:42: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result] /var/tmp/portage/media-libs/opencv-2.3.0/work/OpenCV-2.3.0/modules/traincascade/imagestorage.cpp:154:50: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result] Linking CXX executable ../../bin/opencv_traincascade /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.1/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/opencv_traincascade.dir/traincascade.o: relocation R_X86_64_32 against `pthread_cancel' can not be used when making a shared object; recompile with -fPIC CMakeFiles/opencv_traincascade.dir/traincascade.o: could not read symbols: Bad value collect2: ld returned 1 exit status make[2]: *** [bin/opencv_traincascade] Error 1
Please try opencv-2.3.1a ...
Still the same error with opencv-2.3.1a and gcc-4.6.2.
I can confirm the OP's problem with opencv-2.3.1a and opencv-2.3.1a-r1 when using GCC 4.6.* (hardened, pie and ssp). The problem can be solved by changing to GCC 4.5.* (4.5.3 in my case), then both 2.3.1a-r1 and 2.3.1a compile successfully, then change your gcc back to 4.6.* if you want. I only have 4.6.* for one game that requires a library not included in 4.5.* but evidently left my profile changed to this after I was done playing the game. Anyhow, I am not sure if this can actually be called a fix but 4.6.* is "testing" and masked so I really don't know how you would classify this. The point though, use GCC 4.5.* to compile opencv right now.
OK I suggest you try * opencv-2.4.0 * gcc-4.7 Sorry but I definitely cant help you much more here...
The combination hardened-gcc-4.7.0 and opencv-2.4.0 works fine for me.
*** Bug 400985 has been marked as a duplicate of this bug. ***