This is the mail archive of the gcc-help@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]

Re: -lpthread -lstdc++ crashes on IRIX 6.5


On 22 February 2011 00:49, Peter O'Gorman wrote:
> On Tue, Feb 22, 2011 at 12:34:44AM +0000, Jonathan Wakely wrote:
>> On 21 February 2011 18:10, Peter O'Gorman wrote:
>> > % echo 'int main() {}' >a.cpp
>> > % g++ a.cpp -lpthread; ./a.out; echo $?
>> > zsh: segmentation fault (core dumped) ?./a.out
>> > 139
>> >
>> > We're looking at reordering -lpthread to come after -lstdc++ by patching
>> > cp/g++spec.c to fix this, but perhaps that is the wrong approach?
>>
>> What if you use -D_REENTRANT as well as -lpthread?
>
> It still crashes, but I understand why you asked - the above is a
> compile and link. Here's the same thing with only a link step:
>
> % g++ -pthread -c a.cpp
> % g++ -pthread a.o -o a.out
> % ./a.out
> % g++ -D_REENTRANT -lpthread a.o -o a.out

the preprocessor option won't be used here

> % ./a.out
> zsh: segmentation fault (core dumped) ?./a.out
> % g++ -lstdc++ -lpthread a.o -o a.out
> % ./a.out
> % echo $?
> 0
>
> We're rebuilding now with a modified g++spec.c (patched to reorder
> -lpthread after -lstdc++), but still not sure that is the correct fix
> for this.

The reason I asked is that on most platforms -pthread does two things,
it uses -D_REENTRANT when compiling (technically when preprocessing)
and uses -lpthread when linking.  On some platforms doing one without
the other is not supported, so you should use -pthread when compiling
and when linking.


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