http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56240
Bug #: 56240 Summary: -fopenmp and -pthread behave inconsistently with respect to -nostdlib Classification: Unclassified Product: gcc Version: 4.4.5 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other AssignedTo: unassig...@gcc.gnu.org ReportedBy: y...@shurup.com 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.