Bug 679491

Summary: OpenMP flags are disregarded by libtool in library link mode
Product: [Fedora] Fedora Reporter: Enrique <cquike>
Component: libtoolAssignee: Karsten Hopp <karsten>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 15CC: karsten, rhbugs
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-07 16:43:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
bug demo package none

Description Enrique 2011-02-22 17:55:39 UTC
Created attachment 480191 [details]
bug demo package

Description of problem:

 I am trying to create an OpenMP library. I am using autotools+libtool to comile it. However, the -fopenmp is not properly handled by libtool, which leaves a library with missing symbols, due to the missing linked library libgomp (part of the OpenMP implementation).
 
 I have created a small package which shows the problem. The package creates a library called libompl which uses OpenMP constructions. I have used AC_OPENMP macro in configure.ac to get the flags used by OpenMP. I then pass those flags when linking the library (AM_LDFLAGS = $(OPENMP_CFLAGS)). One can see from the compilation that the proper flags are passed to libtool:
/bin/sh ../libtool  --tag=CC   --mode=link gcc -fopenmp -g -O2 -fopenmp  -o libompl.la -rpath /usr/local/lib omp_lib.lo -lm
libtool: link: rm -fr  .libs/libompl.a .libs/libompl.la .libs/libompl.lai .libs/libompl.so .libs/libompl.so.0 .libs/libompl.so.0.0.0
libtool: link: gcc -shared  .libs/omp_lib.o   -lm    -Wl,-soname -Wl,libompl.so.0 -o .libs/libompl.so.0.0.0

 However, the third line shows that libtool actual call has trimmed the -fopenmp option. This can be check asking the library for its dynamic dependencies:
 # ldd libompl/.libs/libompl.so
        linux-vdso.so.1 =>  (0x00007fffdffff000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fac2853d000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fac281be000)
        /lib64/ld-linux-x86-64.so.2 (0x00000038b9c00000)

 which misses libgomp.so

 The package also contains a small program that makes use of the library and fails at link time with these expected errors:
libtool: link: gcc -g -O2 -o .libs/omp_test omp_test.o  ../libompl/.libs/libompl.so -lm -Wl,-rpath -Wl,/usr/local/lib
../libompl/.libs/libompl.so: undefined reference to `GOMP_parallel_end'
../libompl/.libs/libompl.so: undefined reference to `omp_get_num_threads'
../libompl/.libs/libompl.so: undefined reference to `GOMP_barrier'
../libompl/.libs/libompl.so: undefined reference to `GOMP_parallel_start'
../libompl/.libs/libompl.so: undefined reference to `omp_get_thread_num'

 One might argue that the $(OPENMP_CFLAGS) should be added to the compilation of omp_test. However, the program does not use OpenMP directly, only trough libompl. In fact, as a "client" of the library, it doesn't have to know which other libraries are used by libgompl. As an example, the -lm dependency has been added automatically, even if not explicitly stated in the Makefile.am which compiles omp_test.c.


How reproducible:

Always.

Steps to Reproduce:
1. # tar xvf omp_bug.tar
2. # cd omp_bug
3. # autoreconf -i -f -m
4. # ./configure
5. # make
  
Actual results:

Error messages:
../libompl/.libs/libompl.so: undefined reference to `GOMP_parallel_end'
../libompl/.libs/libompl.so: undefined reference to `omp_get_num_threads'
../libompl/.libs/libompl.so: undefined reference to `GOMP_barrier'
../libompl/.libs/libompl.so: undefined reference to `GOMP_parallel_start'
../libompl/.libs/libompl.so: undefined reference to `omp_get_thread_num'

Expected results:

 Proper linking with libgomp.

Comment 1 Enrique 2011-03-22 15:17:14 UTC
 I also reported it upstream, and it seems that there is already a patch:
http://lists.gnu.org/archive/html/bug-libtool/2011-03/msg00022.html
 Could this patch enter in Fedora 15?
 Chao, 
 Enrique

Comment 2 Karsten Hopp 2011-03-22 15:40:51 UTC
Upstream patch witch complete signoff is at 
http://lists.gnu.org/archive/html/bug-libtool/2011-03/msg00024.html

Comment 3 Enrique 2011-07-27 16:20:03 UTC
 It is still present in Fedora 15. Version bumped

Comment 4 Fedora End Of Life 2012-08-07 16:43:28 UTC
This message is a notice that Fedora 15 is now at end of life. Fedora
has stopped maintaining and issuing updates for Fedora 15. It is
Fedora's policy to close all bug reports from releases that are no
longer maintained. At this time, all open bugs with a Fedora 'version'
of '15' have been closed as WONTFIX.

(Please note: Our normal process is to give advanced warning of this
occurring, but we forgot to do that. A thousand apologies.)

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, feel free to reopen
this bug and simply change the 'version' to a later Fedora version.

Bug Reporter: Thank you for reporting this issue and we are sorry that
we were unable to fix it before Fedora 15 reached end of life. If you
would still like to see this bug fixed and are able to reproduce it
against a later version of Fedora, you are encouraged to click on
"Clone This Bug" (top right of this page) and open it against that
version of Fedora.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

The process we are following is described here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping