Bug 56240 - -fopenmp and -pthread behave inconsistently with respect to -nostdlib
Summary: -fopenmp and -pthread behave inconsistently with respect to -nostdlib
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: 4.4.5
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: openmp
Depends on:
Blocks:
 
Reported: 2013-02-07 12:54 UTC by Yury V. Zaytsev
Modified: 2013-08-09 13:29 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yury V. Zaytsev 2013-02-07 12:54:15 UTC
Hello,

As reported in #25460, if gcc is passed -nostdlib and -pthread options, the libraries implied by -pthread are not added. It was decided that this is the correct behavior and hence the bug was closed.

Now, if gcc is passed -nostdlib and -fopenmp, the libraries implied by -fopenmp (and -pthread) are in fact added to the executable. The same test case as in #25460 can be used to verify this (you have to use libtool 2.4.2+, however, because earlier versions were filtering out OpenMP flags).

This behavior seems to be inconsistent to me.

In order to make it consistent, either the decision in #25460 can be reconsidered and gcc can be made to adhere to -pthread even if -nostdlib is specified, or the effect of -fopenmp can be changed in a way that gcc will not add -lgomp and libraries implied by -pthread anymore.

I think that the first option is better, because the current behavior of -fopenmp seems to make total sense to me, and, as a nice side effect, changing the behavior of -pthread to match -fopenmp will "unbreak" libtool linking of C++ programs that use threads.

The reasons why libtool uses -nostdlib / adds stubs directly and whether it should do it or not can be debated, but they are outside the scope of this report.

Thank you for your time,
--Yury.