From patchwork Mon Apr 8 12:20:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 234753 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 0A5B52C00C3 for ; Mon, 8 Apr 2013 22:20:40 +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:date:message-id:mime-version:content-type; q=dns; s=default; b=UNs4FAJzdYYCYfLjUXnL6rAaMsmhSVBaNzUAD6xncxooQS1etY z5SFfgQW0Em+NR3M7sKNJ7ymiBAqd01xN5a9EjumuHYU3J2QGq0nGn9ot8xTvOus wUVLxPbaKinxhEFRl7nqHVpZHKe+O9pE9ikYQZEl+mB6BPpiTh5EsiXag= 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:date:message-id:mime-version:content-type; s= default; bh=KKu0jwa7G/6JiOQckB90GRZkIJc=; b=pTT7xzMQuq4TTGlJ63HR xZI1K3ENNH0pbLiQA4LMpEq0wJ7h7D6hPKHRTbPBduoKF6RQEGnrYwitq1m49i6D rptoXBaLj3eqYojo6XKKrFRPC8GmO/CE6UsYOQOidvjzvn2omRjK3MsAiqEJoTZa AIAOelbxlRro8Jf6HEK55Zs= Received: (qmail 19324 invoked by alias); 8 Apr 2013 12:20: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 19313 invoked by uid 89); 8 Apr 2013 12:20:32 -0000 X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, TW_LG autolearn=ham version=3.3.1 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; Mon, 08 Apr 2013 12:20:28 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id AF442F20; Mon, 8 Apr 2013 14:20:26 +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 8YTAldqx80Bm; Mon, 8 Apr 2013 14:20:23 +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 729DBF1E; Mon, 8 Apr 2013 14:20:23 +0200 (CEST) Received: (from ro@localhost) by lokon.CeBiTec.Uni-Bielefeld.DE (8.14.5+Sun/8.14.5/Submit) id r38CKNZg006140; Mon, 8 Apr 2013 14:20:23 +0200 (MEST) From: Rainer Orth To: gcc-patches@gcc.gnu.org Cc: Paolo Bonzini Subject: [build] Use -z ignore instead of --as-needed on Solaris Date: Mon, 08 Apr 2013 14:20:22 +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 While the Solaris linker doesn't support the --as-needed/--no-as-needed options (yet), it long has provided the equivalent -z ignore/-z record options. This patch makes use of them, avoiding unnecessary dependencies on libgcc_s.so.1. Bootstrapped without regressions on i386-pc-solaris2.11 (and checking that many dependencies on libgcc_s.so.1 in runtime libraries are gone that were flagged as unused by ldd -u) and x86_64-unknown-linux-gnu (gcc/specs unchanged, make check still running). Ok for mainline if it passes? Thanks. Rainer 2013-04-05 Rainer Orth * configure.ac (gcc_cv_ld_as_needed): Set gcc_cv_ld_as_needed_option, gcc_cv_no_as_needed_option. Use -z ignore, -z record on *-*-solaris2*. (HAVE_LD_AS_NEEDED): Update comment. (LD_AS_NEEDED_OPTION, LD_NO_AS_NEEDED_OPTION): Define. * configure: Regenerate. * config.in: Regenerate. * gcc.c (init_gcc_specs) [USE_LD_AS_NEEDED]: Use LD_AS_NEEDED_OPTION, LD_NO_AS_NEEDED_OPTION. * config/sol2.h [HAVE_LD_AS_NEEDED] (USE_LD_AS_NEEDED): Define. * doc/tm.texi.in (USE_LD_AS_NEEDED): Allow for --as-needed equivalents. Fix markup. * doc/tm.texi: Regenerate. # HG changeset patch # Parent 602ad5b6c5e29819082e386836c33220c78ae4b7 Use -z ignore instead of --as-needed on Solaris diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h --- a/gcc/config/sol2.h +++ b/gcc/config/sol2.h @@ -181,6 +181,11 @@ along with GCC; see the file COPYING3. %(link_arch) \ %{Qy:} %{!Qn:-Qy}" +/* Use --as-needed/-z ignore -lgcc_s for eh support. */ +#ifdef HAVE_LD_AS_NEEDED +#define USE_LD_AS_NEEDED 1 +#endif + #ifdef USE_GLD /* Solaris 11 build 135+ implements dl_iterate_phdr. GNU ld needs --eh-frame-hdr to create the required .eh_frame_hdr sections. */ diff --git a/gcc/configure.ac b/gcc/configure.ac --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -4538,6 +4538,8 @@ AC_MSG_RESULT($gcc_cv_ld_eh_gc_sections_ AC_CACHE_CHECK(linker --as-needed support, gcc_cv_ld_as_needed, [gcc_cv_ld_as_needed=no +gcc_cv_ld_as_needed_option='--as-needed' +gcc_cv_ld_no_as_needed_option='--no-as-needed' if test $in_tree_ld = yes ; then if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2 \ && test $in_tree_ld_is_elf = yes; then @@ -4547,12 +4549,25 @@ elif test x$gcc_cv_ld != x; then # Check if linker supports --as-needed and --no-as-needed options if $gcc_cv_ld --help 2>/dev/null | grep as-needed > /dev/null; then gcc_cv_ld_as_needed=yes + else + case "$target" in + # Solaris 2 ld always supports -z ignore/-z record. + *-*-solaris2*) + gcc_cv_ld_as_needed=yes + gcc_cv_ld_as_needed_option="-z ignore" + gcc_cv_ld_no_as_needed_option="-z record" + ;; + esac fi fi ]) if test x"$gcc_cv_ld_as_needed" = xyes; then AC_DEFINE(HAVE_LD_AS_NEEDED, 1, -[Define if your linker supports --as-needed and --no-as-needed options.]) +[Define if your linker supports --as-needed/--no-as-needed or equivalent options.]) + AC_DEFINE_UNQUOTED(LD_AS_NEEDED_OPTION, "$gcc_cv_ld_as_needed_option", +[Define to the linker option to ignore unused dependencies.]) + AC_DEFINE_UNQUOTED(LD_NO_AS_NEEDED_OPTION, "$gcc_cv_ld_no_as_needed_option", +[Define to the linker option to keep unused dependencies.]) fi case "$target:$tm_file" in diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -260,7 +260,8 @@ line, but, unlike @code{LIBGCC_SPEC}, it @defmac USE_LD_AS_NEEDED A macro that controls the modifications to @code{LIBGCC_SPEC} mentioned in @code{REAL_LIBGCC_SPEC}. If nonzero, a spec will be -generated that uses --as-needed and the shared libgcc in place of the +generated that uses @option{--as-needed} or equivalent options and the +shared @file{libgcc} in place of the static exception handler library, when linking without any of @code{-static}, @code{-static-libgcc}, or @code{-shared-libgcc}. @end defmac diff --git a/gcc/gcc.c b/gcc/gcc.c --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -1361,7 +1361,8 @@ init_gcc_specs (struct obstack *obstack, "%{!static:%{!static-libgcc:" #if USE_LD_AS_NEEDED "%{!shared-libgcc:", - static_name, " --as-needed ", shared_name, " --no-as-needed" + static_name, " " LD_AS_NEEDED_OPTION " ", + shared_name, " " LD_NO_AS_NEEDED_OPTION "}" "%{shared-libgcc:", shared_name, "%{!shared: ", static_name, "}"