This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libgomp/68762] New: link error for inline function decorated with OpenMP declare simd


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68762

            Bug ID: 68762
           Summary: link error for inline function decorated with OpenMP
                    declare simd
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgomp
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gilles.civario at ichec dot ie
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

Created attachment 36941
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36941&action=edit
tarball of the bug reproducer

Hello,


I discovered that when an "inline" function is decorated with the "#pragma omp
declare simd" OpenMP directive, the linking stage sometimes fails.
More specifically, it fails if the level of optimisation makes that the
inlining is disabled. Therefore, compiling/linking with "-O3" will work whereas
compiling/linking with "-O3 -fno-inline" or "-O0" for example, will fail.

I wrote a small reproducer which fails on all versions of GCC I tried, included
the version 5.3.0.

To compile:

gcivario@vercors:~/tmp$ g++-5 -g -fopenmp simd.cc foobar.cc
/tmp/cckskwpK.o: In function `_ZGVbN2v__Z3food':
/home/gcivario/tmp/foobar.h:7: multiple definition of `_ZGVbN2v__Z3food'
/tmp/ccsxGjU2.o:/home/gcivario/tmp/foobar.h:7: first defined here
/tmp/cckskwpK.o: In function `_ZGVbM2v__Z3food':
/home/gcivario/tmp/foobar.h:7: multiple definition of `_ZGVbM2v__Z3food'
/tmp/ccsxGjU2.o:/home/gcivario/tmp/foobar.h:7: first defined here
/tmp/cckskwpK.o: In function `_ZGVcN4v__Z3food':
/home/gcivario/tmp/foobar.h:7: multiple definition of `_ZGVcN4v__Z3food'
/tmp/ccsxGjU2.o:/home/gcivario/tmp/foobar.h:7: first defined here
/tmp/cckskwpK.o: In function `_ZGVcM4v__Z3food':
/home/gcivario/tmp/foobar.h:7: multiple definition of `_ZGVcM4v__Z3food'
/tmp/ccsxGjU2.o:/home/gcivario/tmp/foobar.h:7: first defined here
/tmp/cckskwpK.o: In function `_ZGVdN4v__Z3food':
/home/gcivario/tmp/foobar.h:7: multiple definition of `_ZGVdN4v__Z3food'
/tmp/ccsxGjU2.o:/home/gcivario/tmp/foobar.h:7: first defined here
/tmp/cckskwpK.o: In function `_ZGVdM4v__Z3food':
/home/gcivario/tmp/foobar.h:7: multiple definition of `_ZGVdM4v__Z3food'
/tmp/ccsxGjU2.o:/home/gcivario/tmp/foobar.h:7: first defined here
collect2: error: ld returned 1 exit status

Whereas, if "-O3" is used:

gcivario@vercors:~/tmp$ g++-5 -g -O3 -fopenmp simd.cc foobar.cc
gcivario@vercors:~/tmp$ 

For the record:

gcivario@vercors:~/tmp$ g++-5 -v
Using built-in specs.
COLLECT_GCC=g++-5
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
5.3.0-3ubuntu1~14.04' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,java,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-5 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=gcc4-compatible --disable-libstdcxx-dual-abi
--enable-gnu-unique-object --disable-vtable-verify --enable-libmpx
--enable-plugin --with-system-zlib --disable-browser-plugin
--enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.3.0 20151204 (Ubuntu 5.3.0-3ubuntu1~14.04) 


And I asked a question about this specific issue on StackOverflow, which link
is
https://stackoverflow.com/questions/34091341/openmp-declare-simd-for-an-inline-function

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]