From patchwork Fri May 24 13:35:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 246143 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 97FA72C0095 for ; Fri, 24 May 2013 23:35:46 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; q=dns; s=default; b=e4bYhfc6W0MRJ6rB Fg1U21rekz31RkHZOZzcQqefd+pc1HEVnAkLStvEfWaq81IQfnimFyQ4GiJv2/z6 tn2ha42XheFFTvWgEv1mCNlWDJVMo52/Ur9zK7nd0Oj1FWH1JCVgsMpgVhYHmcWG 8wxGY29sUPG3BMmq/cwVXh+bHI0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; s=default; bh=FUpe2w3WClg6siRoKXKvw8 dvRVE=; b=Gw/7xN4XF9u3W2jO0qMgRmSa2vzDtrZRGgXDNR5/4aeKgGD2KTf5Li pjFuYpIPUpXfLt89A5JE9b1xezgRDuoMPzIjG17/PHuiSZyNhnjrn/BA+uUhXYS+ xOP5OnQuEWTDHqybN0XM5Vczm2mTPrAEV6O/fYKr30HSW5C0i9i2k= Received: (qmail 9235 invoked by alias); 24 May 2013 13:35:32 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 9188 invoked by uid 89); 24 May 2013 13:35:23 -0000 X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, TW_CX, TW_DC, TW_EQ, TW_LR autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from snape.CeBiTec.Uni-Bielefeld.DE (HELO smtp-relay.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 24 May 2013 13:35:22 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id F1389A5B; Fri, 24 May 2013 15:35:19 +0200 (CEST) Received: from smtp-relay.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 7valN44cdPLR; Fri, 24 May 2013 15:35:16 +0200 (CEST) Received: from lokon.CeBiTec.Uni-Bielefeld.DE (lokon.CeBiTec.Uni-Bielefeld.DE [129.70.161.110]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id 93704A5A; Fri, 24 May 2013 15:35:16 +0200 (CEST) Received: (from ro@localhost) by lokon.CeBiTec.Uni-Bielefeld.DE (8.14.5+Sun/8.14.5/Submit) id r4ODZF03004115; Fri, 24 May 2013 15:35:15 +0200 (MEST) From: Rainer Orth To: Jakub Jelinek Cc: Jonathan Wakely , Benjamin Kosnik , Paolo Carlini , libstdc++ , gcc-patches Subject: Re: [patch] Default to --enable-libstdcxx-time=auto References: <20130523140218.GW1377@tucnak.redhat.com> <20130523162611.GA1377@tucnak.redhat.com> <20130523205022.GF1377@tucnak.redhat.com> <20130523210611.GH1377@tucnak.redhat.com> <20130524075705.GK1377@tucnak.redhat.com> <20130524132117.GT1377@tucnak.redhat.com> Date: Fri, 24 May 2013 15:35:15 +0200 In-Reply-To: <20130524132117.GT1377@tucnak.redhat.com> (Jakub Jelinek's message of "Fri, 24 May 2013 15:21:17 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (usg-unix-v) MIME-Version: 1.0 X-Virus-Found: No Jakub Jelinek writes: >> It occured to me that there might be a far less intrusive option to still >> allow a Solaris backport: instead of going the libstdc++.spec route >> (which I still think is the correct way forward), statically handle -lrt >> addition in g++spec.c, controlled by a macro defined only in config/sol2.h. >> >> Such a patch could be added to mainline and 4.8 branch now, and mainline >> later changed to use libstdc++.spec instead. > > I think a switch from not linking libstdc++ against -lrt to linking against > that is quite heavy change for the branch. Do you see why the latest patch I'm not so sure: to me, that's just an implementation detail. > I've posted today wouldn't work well on Solaris? It should work on the 4.8 branch (I'll include it in my bootstraps this weekend), but on mainline the failures due to missing nanosleep/-lrt will remain. I've just successfully bootstrapped the following patch on i386-pc-solaris2.10 and x86_64-unknown-linux-gnu. It fixes the libstdc++ testsuite failures I'd reported before. Rainer 2013-05-24 Rainer Orth gcc/cp: * g++spec.c (TIMELIB): Define. (WITHLIBC, SKIPOPT): Adjust values. (lang_specific_driver): Add TIME_LIBRARY if not passed explicitly. gcc: * config/sol2.h (TIME_LIBRARY): Define. # HG changeset patch # Parent d6881ec042d3a6328b763cbf0f38e61bdbb64d79 Add -lrt on Solaris diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h --- a/gcc/config/sol2.h +++ b/gcc/config/sol2.h @@ -194,6 +194,9 @@ along with GCC; see the file COPYING3. #endif /* HAVE_LD_EH_FRAME && TARGET_DL_ITERATE_PHDR */ #endif +/* C++11 programs need -lrt for nanosleep. */ +#define TIME_LIBRARY "rt" + #ifndef USE_GLD /* The default MFLIB_SPEC is GNU ld specific. */ #define MFLIB_SPEC "" diff --git a/gcc/cp/g++spec.c b/gcc/cp/g++spec.c --- a/gcc/cp/g++spec.c +++ b/gcc/cp/g++spec.c @@ -28,10 +28,12 @@ along with GCC; see the file COPYING3. #define LANGSPEC (1<<1) /* This bit is set if they did `-lm' or `-lmath'. */ #define MATHLIB (1<<2) +/* This bit is set if they did `-lrt' or equivalent. */ +#define TIMELIB (1<<3) /* This bit is set if they did `-lc'. */ -#define WITHLIBC (1<<3) +#define WITHLIBC (1<<4) /* Skip this option. */ -#define SKIPOPT (1<<4) +#define SKIPOPT (1<<5) #ifndef MATH_LIBRARY #define MATH_LIBRARY "m" @@ -40,6 +42,10 @@ along with GCC; see the file COPYING3. #define MATH_LIBRARY_PROFILE MATH_LIBRARY #endif +#ifndef TIME_LIBRARY +#define TIME_LIBRARY "" +#endif + #ifndef LIBSTDCXX #define LIBSTDCXX "stdc++" #endif @@ -83,16 +89,22 @@ lang_specific_driver (struct cl_decoded_ /* "-lm" or "-lmath" if it appears on the command line. */ const struct cl_decoded_option *saw_math = NULL; + /* "-lrt" or eqivalent if it appears on the command line. */ + const struct cl_decoded_option *saw_time = NULL; + /* "-lc" if it appears on the command line. */ const struct cl_decoded_option *saw_libc = NULL; /* An array used to flag each argument that needs a bit set for - LANGSPEC, MATHLIB, or WITHLIBC. */ + LANGSPEC, MATHLIB, TIMELIB, or WITHLIBC. */ int *args; /* By default, we throw on the math library if we have one. */ int need_math = (MATH_LIBRARY[0] != '\0'); + /* By default, we throw on the time library if we have one. */ + int need_time = (TIME_LIBRARY[0] != '\0'); + /* True if we saw -static. */ int static_link = 0; @@ -136,6 +148,11 @@ lang_specific_driver (struct cl_decoded_ args[i] |= MATHLIB; need_math = 0; } + else if (strcmp (arg, TIME_LIBRARY) == 0) + { + args[i] |= TIMELIB; + need_time = 0; + } else if (strcmp (arg, "c") == 0) args[i] |= WITHLIBC; else @@ -268,6 +285,12 @@ lang_specific_driver (struct cl_decoded_ saw_math = &decoded_options[i]; } + if (!saw_time && (args[i] & TIMELIB) && library > 0) + { + --j; + saw_time = &decoded_options[i]; + } + if (!saw_libc && (args[i] & WITHLIBC) && library > 0) { --j; @@ -352,6 +375,15 @@ lang_specific_driver (struct cl_decoded_ added_libraries++; j++; } + if (saw_time) + new_decoded_options[j++] = *saw_time; + else if (library > 0 && need_time) + { + generate_option (OPT_l, TIME_LIBRARY, 1, CL_DRIVER, + &new_decoded_options[j]); + added_libraries++; + j++; + } if (saw_libc) new_decoded_options[j++] = *saw_libc; if (shared_libgcc && !static_link)