From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30331 invoked by alias); 22 Feb 2011 20:13:42 -0000 Received: (qmail 30320 invoked by uid 22791); 22 Feb 2011 20:13:41 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail1.thewrittenword.com (HELO mail1.thewrittenword.com) (69.67.212.77) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Feb 2011 20:13:32 +0000 Received: from mail1.il.thewrittenword.com (emma-internal-gw.il.thewrittenword.com [192.168.13.25]) by mail1.thewrittenword.com (Postfix) with ESMTP id 778AB5C4A; Tue, 22 Feb 2011 20:37:29 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.4.4 mail1.thewrittenword.com 778AB5C4A Received: from tw.local (unknown [192.168.1.254]) by mail1.il.thewrittenword.com (Postfix) with ESMTP id 2FE551199; Tue, 22 Feb 2011 20:13:30 +0000 (UTC) Received: from tw.local (localhost.localdomain [127.0.0.1]) by tw.local (8.14.4/8.14.4) with ESMTP id p1MKDT7I008927; Tue, 22 Feb 2011 14:13:29 -0600 Received: (from pogma@localhost) by tw.local (8.14.4/8.14.4/Submit) id p1MKDSeW008925; Tue, 22 Feb 2011 14:13:28 -0600 Date: Tue, 22 Feb 2011 20:18:00 -0000 From: "Peter O'Gorman" To: gcc-help@gcc.gnu.org Cc: ro@cebitec.uni-bielefeld.de Subject: Re: -lpthread -lstdc++ crashes on IRIX 6.5 Message-ID: <20110222201327.GN5577@tw.local> References: <20110221181036.GK5577@tw.local> <20110222004912.GL5577@tw.local> <20110222012400.GM5577@tw.local> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="G4iJoqBmSsgzjUCe" Content-Disposition: inline In-Reply-To: <20110222012400.GM5577@tw.local> User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-02/txt/msg00368.txt.bz2 --G4iJoqBmSsgzjUCe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 833 On Mon, Feb 21, 2011 at 07:24:00PM -0600, Peter O'Gorman wrote: > > While I agree with all of this, adding -lpthread to the link line as > well as -pthread should not cause the resulting application to crash. > > I see I never got to that in my original mail, sorry :(. Even if we > consistently use -pthread for compiling and linking with gcc, we > sometimes end up with a -lpthread on the link line (often because > libtool has it in some .la files dependency_libs, sometimes due to > pkgconfig), and when that happens the resulting application crashes at > launch. This patch (for gcc-4.4, but if this is the right way to go, we will forward port) works around the issue. Is it the correct approach? Or perhaps the problem is specific to our build of gcc-4.4 on IRIX? Thanks, Peter -- Peter O'Gorman pogma@thewrittenword.com --G4iJoqBmSsgzjUCe Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="reorderstdcpp.patch" Content-length: 2167 Index: gcc/config/mips/iris6.h =================================================================== --- gcc/config/mips/iris6.h.orig 2009-02-20 15:20:38.000000000 +0000 +++ gcc/config/mips/iris6.h 2011-02-21 17:32:14.040113998 +0000 @@ -23,7 +23,12 @@ #undef TARGET_IRIX6 #define TARGET_IRIX6 1 +/* We need to reorder -lpthread to come after -lstdc++. */ +#undef PTHREAD_LIBRARY +#define PTHREAD_LIBRARY "-lpthread" + /* Default to -mabi=n32 and -mips3. */ + #undef MULTILIB_DEFAULTS #define MULTILIB_DEFAULTS { "mabi=n32" } Index: gcc/cp/g++spec.c =================================================================== --- gcc/cp/g++spec.c.orig 2009-02-20 15:20:38.000000000 +0000 +++ gcc/cp/g++spec.c 2011-02-21 17:33:55.979598307 +0000 @@ -30,10 +30,17 @@ #define MATHLIB (1<<2) /* This bit is set if they did `-lc'. */ #define WITHLIBC (1<<3) +/* This bit is set if they did '-lpthread'. */ +#define WITHLIBPTHREAD (1<<4) #ifndef MATH_LIBRARY #define MATH_LIBRARY "-lm" #endif + +#ifndef PTHREAD_LIBRARY +#define PTHREAD_LIBRARY "" +#endif + #ifndef MATH_LIBRARY_PROFILE #define MATH_LIBRARY_PROFILE MATH_LIBRARY #endif @@ -86,6 +93,9 @@ /* "-lm" or "-lmath" if it appears on the command line. */ const char *saw_math = 0; + /* "-lpthread" if it appears on the command line. */ + const char *saw_pthread = 0; + /* "-lc" if it appears on the command line. */ const char *saw_libc = 0; @@ -143,6 +153,8 @@ args[i] |= MATHLIB; need_math = 0; } + else if (strcmp (argv[i], PTHREAD_LIBRARY) == 0) + args[i] |= WITHLIBPTHREAD; else if (strcmp (argv[i], "-lc") == 0) args[i] |= WITHLIBC; else if (strcmp (argv[i], "-pg") == 0 || strcmp (argv[i], "-p") == 0) @@ -282,6 +294,12 @@ saw_math = argv[i]; } + if (!saw_pthread && (args[i] & WITHLIBPTHREAD) && library > 0) + { + --j; + saw_pthread = argv[i]; + } + if (!saw_libc && (args[i] & WITHLIBC) && library > 0) { --j; @@ -335,6 +353,8 @@ } if (saw_libc) arglist[j++] = saw_libc; + if (saw_pthread) + arglist[j++] = saw_pthread; if (shared_libgcc) arglist[j++] = "-shared-libgcc"; --G4iJoqBmSsgzjUCe--