From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 124298 invoked by alias); 18 Aug 2015 21:33:39 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 124279 invoked by uid 89); 18 Aug 2015 21:33:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f175.google.com Received: from mail-wi0-f175.google.com (HELO mail-wi0-f175.google.com) (209.85.212.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 18 Aug 2015 21:33:37 +0000 Received: by wicja10 with SMTP id ja10so119715636wic.1 for ; Tue, 18 Aug 2015 14:33:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=TMEGRDLDUXPE88CDMN6NHsxG0fl/au+zxl1Bl/D7APs=; b=PRjtNmLZM7TLOI2SVtOAzlyOK9yO1AEQQbkAkEIRpHe5oC6f/1MkATrM9yS2MtEYAN bQ7XCwzEkJBkxaUcWHWIq5D10GyJal0sQ2xKehPA3F/3wWR89f870Mn9jtLjYQ1tl9qX L+Mc6rnUXzLw0/j/zs4EfUtMNLt7NcgM5SG8IyO8nxQCzTOmopHgvc8M/HgTiAdVKFFh 9xsfVSGpdVkCR28EZrGXNw5zwi8ZwqFSh0ik3mMP9aenIMW6p3OsYOCwl8tEiFzsYK3H J8Fe2ow0GrFxB9lEuGEHLtLL8Ul424dxEjO++DfE9RrTtgO1mjqlwlsVyUVXxl1f+F0k rqOQ== X-Gm-Message-State: ALoCoQmHVmrB5FFel48kCB+05ifwZU8CyUtDczM0NsADdXgB1OlDVoPx1gQzYDkFGMyFzCTSNwJx MIME-Version: 1.0 X-Received: by 10.194.119.161 with SMTP id kv1mr16710038wjb.157.1439933614738; Tue, 18 Aug 2015 14:33:34 -0700 (PDT) Received: by 10.28.46.3 with HTTP; Tue, 18 Aug 2015 14:33:34 -0700 (PDT) In-Reply-To: References: Date: Tue, 18 Aug 2015 21:44:00 -0000 Message-ID: Subject: Re: [RFC] COMDAT Safe Module Level Multi versioning From: Sriraman Tallam To: Cary Coutant Cc: Xinliang David Li , Richard Biener , "H.J. Lu" , GCC Patches , binutils , Yury Gribov Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg01038.txt.bz2 On Tue, Aug 18, 2015 at 2:14 PM, Cary Coutant wrote: >>>>> Based on Richard's suggestion, I have a patch to localize comdat >>>>> functions which seems like a very effective solution to this problem. >>>>> The text size increase is limited to the extra comdat copies generated >>>>> for the specialized modules (modules with unsafe options) which is >>>>> usually only a few. Since -fweak does something similar for >>>>> functions, I have called the new option -fweak-comdat-functions. >>>>> This does not apply to virtual comdat functions as their addresses can >>>>> always be leaked via the vtable. Using this flag with virtual >>>>> functions generates a warning. > > +fweak-comdat-functions > +C++ Var(flag_weak_comdat_functions) Init(1) > +Specific to comdat functions(-fno-weak-comdat-functions : Localize > Comdat Functions). > +With -fno-weak-comdat-functions, virtual comdat functions are still linked as > +weak functions. With -fno-weak-comdat-functions, the address of the comdat > +functions that are localized will be unique and this can cause unintended > +behavior when addresses of comdat functions are used. > > Is one of those "With -fno-weak-comdat-functions" supposed to be "With > -fweak-comdat-functions"? This description doesn't really say what the > flag (without the "no") does, and doesn't explain what "localize" > means. > > +@item -fno-weak-comdat-functions > +@opindex fno-weak-comdat-functions > +Do not use weak symbol support for comdat non-virtual functions, even if it > +is provided by the linker. By default, G++ uses weak symbols if they are > +available. This option is useful when comdat functions generated in certain > +compilation units need to be kept local to the respective units and not exposed > +globally. This does not apply to virtual comdat functions as their pointers > +may be taken via virtual tables. This can cause unintended behavior if > +the addresses of comdat functions are used. > > It's not really the "weak" that is causing the problem -- it's the > "comdat". What the option really is doing is making the functions > static rather than comdat. (It's all gated under flag_weak because > weak symbols are the fall-back to link-once and comdat symbols.) I'd > suggest phrasing this more in terms of static vs. comdat. Thanks, will make those changes. Do you recommend a different name for this flag like -fmake-comdat-functions-static? Sri > > This looks like the right way to go, though. > > -cary