gcc-4.7 "-march=core-avx2 -O3" -> fails gcc-4.7 "-march=core-avx2 -O2" -> succeeds gcc-4.7 "-march=core-avx-i -O3" -> succeeds gcc-4.7 "-march=core-avx-i -O2" -> succeeds gcc-4.6 "-march=core-avx-i -O3" -> succeeds gcc-4.6 "-march=core-avx-i -O2" -> succeeds Failure happens like this: building '_random' extension x86_64-pc-linux-gnu-gcc -pthread -fPIC -fno-strict-aliasing -march=core-avx2 -O2 -pipe -Wall -g -O3 -fwrapv -DNDEBUG -I. -IInclude -I/var/tmp/portage/dev-lang/python-2.7.5/work/Python-2.7.5/Include -I/var/tmp/portage/dev-lang/python-2.7.5/work/x86_64-pc-linux-gnu -c /var/tmp/portage/dev-lang/python-2.7.5/work/Python-2.7.5/Modules/_randommodule.c -o build/temp.linux-x86_64-2.7/var/tmp/portage/dev-lang/python-2.7.5/work/Python-2.7.5/Modules/_randommodule.o x86_64-pc-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -L. -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -L. -fno-strict-aliasing -march=core-avx2 -O2 -pipe -Wall -g -O3 -fwrapv -DNDEBUG -I. -IInclude -I/var/tmp/portage/dev-lang/python-2.7.5/work/Python-2.7.5/Include build/temp.linux-x86_64-2.7/var/tmp/portage/dev-lang/python-2.7.5/work/Python-2.7.5/Modules/_randommodule.o -L/usr/local/lib -L. -lpython2.7 -o build/lib.linux-x86_64-2.7/_random.so /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld: build/temp.linux-x86_64-2.7/var/tmp/portage/dev-lang/python-2.7.5/work/Python-2.7.5/Modules/_randommodule.o: relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC build/temp.linux-x86_64-2.7/var/tmp/portage/dev-lang/python-2.7.5/work/Python-2.7.5/Modules/_randommodule.o: could not read symbols: Bad value collect2: error: ld returned 1 exit status
See https://bugs.gentoo.org/show_bug.cgi?id=475482 for more information.
Please provide preprocessed source of _randommodule.c
Created attachment 30418 [details] _randommodule-preprocessed.c
The problem is in .text vpgatherqq %ymm8, mag01.10849(,%ymm6,8), %ymm5 .section .rodata .align 16 .type mag01.10849, @object .size mag01.10849, 16 mag01.10849: .quad 0 .quad 2567483615 "mag01.10849(,%ymm6,8)" isn't PC relative.
Reduced testcase for -O3 -mavx2 -fpic: void foo (unsigned long *x, int *y) { static unsigned long b[2] = { 0x0UL, 0x9908b0dfUL }; int c; for (c = 0; c < 512; c++) x[c] = b[x[c] & 1UL]; }
Created attachment 30425 [details] gcc49-pr57777.patch Untested fix.
(In reply to Jakub Jelinek from comment #6) > Created attachment 30425 [details] > gcc49-pr57777.patch > > Untested fix. I have tested that patch on gcc-4.8 and was able to compile the python module successfully with "-march=core-avx2 -O3". gcc-4.8 is affected as well without that patch, as the title correctly says.
tested with gcc-4.7.3, and it works as well for clarification: the previous test was with 4.8.1
patch tested with gcc-4.9.0_alpha20130505, works as well
Author: jakub Date: Wed Jul 3 20:23:38 2013 New Revision: 200649 URL: http://gcc.gnu.org/viewcvs?rev=200649&root=gcc&view=rev Log: PR target/57777 * config/i386/predicates.md (vsib_address_operand): Disallow SYMBOL_REF or LABEL_REF in parts.disp if TARGET_64BIT && flag_pic. * gcc.target/i386/pr57777.c: New test. Added: trunk/gcc/testsuite/gcc.target/i386/pr57777.c Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/predicates.md trunk/gcc/testsuite/ChangeLog Author: jakub Date: Wed Jul 3 20:24:19 2013 New Revision: 200650 URL: http://gcc.gnu.org/viewcvs?rev=200650&root=gcc&view=rev Log: PR target/57777 * config/i386/predicates.md (vsib_address_operand): Disallow SYMBOL_REF or LABEL_REF in parts.disp if TARGET_64BIT && flag_pic. * gcc.target/i386/pr57777.c: New test. Added: branches/gcc-4_8-branch/gcc/testsuite/gcc.target/i386/pr57777.c Modified: branches/gcc-4_8-branch/gcc/ChangeLog branches/gcc-4_8-branch/gcc/config/i386/predicates.md branches/gcc-4_8-branch/gcc/testsuite/ChangeLog Fixed for 4.8.2+ so far.
(In reply to Julian Ospald from comment #7) > (In reply to Jakub Jelinek from comment #6) > > Created attachment 30425 [details] > > gcc49-pr57777.patch > > > > Untested fix. > > I have tested that patch on gcc-4.8 and was able to compile the python > module successfully with "-march=core-avx2 -O3". > > gcc-4.8 is affected as well without that patch, as the title correctly says. I had a similar situation with gcc 4.8.1, with "-O3 -march=core-avx2" and had to pass -mno-avx2 in order to compile. For the sake of curiosity could you confirm if "-O3 -march=core-avx2 -mno-avx2" compiles? gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.1/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-isl=/builddir/build/BUILD/gcc-4.8.1-20130603/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.1-20130603/obj-x86_64-redhat-linux/cloog-install --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 4.8.1 20130603 (Red Hat 4.8.1-1) (GCC) system, fedora19
Author: jakub Date: Wed May 7 15:59:37 2014 New Revision: 210169 URL: http://gcc.gnu.org/viewcvs?rev=210169&root=gcc&view=rev Log: Backported from mainline 2013-07-03 Jakub Jelinek <jakub@redhat.com> PR target/57777 * config/i386/predicates.md (vsib_address_operand): Disallow SYMBOL_REF or LABEL_REF in parts.disp if TARGET_64BIT && flag_pic. * gcc.target/i386/pr57777.c: New test. Added: branches/gcc-4_7-branch/gcc/testsuite/gcc.target/i386/pr57777.c Modified: branches/gcc-4_7-branch/gcc/ChangeLog branches/gcc-4_7-branch/gcc/config/i386/predicates.md branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
Fixed.