From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32767 invoked by alias); 3 Sep 2014 03:20:10 -0000 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 Received: (qmail 32743 invoked by uid 89); 3 Sep 2014 03:20:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ig0-f179.google.com Received: from mail-ig0-f179.google.com (HELO mail-ig0-f179.google.com) (209.85.213.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 03 Sep 2014 03:20:04 +0000 Received: by mail-ig0-f179.google.com with SMTP id r2so8398792igi.6 for ; Tue, 02 Sep 2014 20:20:01 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.50.111.112 with SMTP id ih16mr32821361igb.30.1409714401858; Tue, 02 Sep 2014 20:20:01 -0700 (PDT) Received: by 10.107.172.131 with HTTP; Tue, 2 Sep 2014 20:20:01 -0700 (PDT) In-Reply-To: References: Date: Wed, 03 Sep 2014 03:20:00 -0000 Message-ID: Subject: Re: removing unused functions during final link From: Melvin Blades To: Ian Lance Taylor Cc: "gcc-help@gcc.gnu.org" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-09/txt/msg00021.txt.bz2 Using gcc instead of ld, I was able to get it to strip unused functions if all the functions in a file are not called. But I could not get it to strip unused functions if they are in the same source file as used functions . Is there a way to get it strip ALL the unused functions? Thanks for any hints, I'm running out of things to try On Wed, Aug 27, 2014 at 2:22 PM, Ian Lance Taylor wrote: > On Wed, Aug 27, 2014 at 2:02 PM, Melvin Blades wrote: >> >> What command line options can I use to get the linker to strip unused >> functions from the final executable? > > Compile with -ffunction-sections -fdata-sections. > > Link with -Wl,--gc-sections. > > Ian