This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH] Two level comdat priorities in gold
- From: Sriraman Tallam <tmsriram at google dot com>
- To: Xinliang David Li <davidxl at google dot com>
- Cc: Ian Lance Taylor <iant at google dot com>, binutils <binutils at sourceware dot org>, Cary Coutant <ccoutant at gmail dot com>, Paul Pluzhnikov <ppluzhnikov at google dot com>, Daniel Berlin <dannyb at google dot com>
- Date: Tue, 21 Jul 2015 10:23:14 -0700
- Subject: Re: [PATCH] Two level comdat priorities in gold
- Authentication-results: sourceware.org; auth=none
- References: <CAAs8HmwHCWKf+Onx=ERLgLpk6276f+jhuW-WiKpvhz6QDxWQ2Q at mail dot gmail dot com> <CAKOQZ8wrnsj5UZx-trKXD+RBXS64TijHQPsJ1zwYeooZ5Kufsg at mail dot gmail dot com> <CAAkRFZLOacc874KkFD4iYuPk17qEMPLB5Sy4V57+UiCg0F48fA at mail dot gmail dot com> <CAKOQZ8ximo=B65dk2t6Ojwp_KEzWWr5zX6xpkR6_bVNMquJMcg at mail dot gmail dot com> <CAAkRFZ+OacKbu1iGGGXVEJu2OucOzObF8aMiLV0646e0JONdWw at mail dot gmail dot com>
On Tue, Jul 21, 2015 at 9:07 AM, Xinliang David Li <email@example.com> wrote:
> On Tue, Jul 21, 2015 at 7:16 AM, Ian Lance Taylor <firstname.lastname@example.org> wrote:
>> On Mon, Jul 20, 2015 at 12:32 PM, Xinliang David Li <email@example.com> wrote:
>>> If a user uses __optimize__ attribute on a function to enable an ISA
>>> extension, but does not guard the call of the function with ISA
>>> feature testing, it is considered a user error. We only need to
>>> improve the tool chain here to help users where he does not have any
>>> other control -- basically when a common library function defined in
>>> the header gets implicitly versioned due to the use of -mxxx option.
>>> In other words, currently for C++ programs, using -mxxx on a module is
>>> basically broken, and this patch tries to address that.
>> So the problem is that an object file compiled with -mxxx may include
>> definitions of non-inlined functions and instantiated templates with
>> vague linkage that are compiled with -mxxx. At link time, these same
>> functions/templates may appear in object files not compiled with
>> -mxxx. When the linker happens to resolve the vague linkage by
>> selecting the -mxxx instantiations, the calls from the non-mxxx
>> objects are erroneous.
>> The proposal is to compile the -mxxx versions with a special compiler
>> option that causes the definitions with vague linkage in that object
>> to only be used if they are the only definition. The idea is that the
>> user will use the special compiler option whenever using -mxxx options
>> that are incompatible with the baseline build.
> yes, that is the exactly right.
>> One minor disadvantage is that -mxxx code will not reliably call -mxxx
>> template functions, even when such functions would be better
> yes, it is a minor disadvantage. The common library functions that
> get 'accidentally' ISA enhanced/versioned are usually not what user
> intended and not in performance critical path.
>>>> What should happen if people use the -r option to combine several
>>>> objects together?
>>> Can the linker pick the higher prirority comdat?
>> Sure, but the proposed representation is to add a special section that
>> affects the interpretation of the entire object. How should that
>> special section by handled when using -r with a combination of some
>> objects that have the section and some do not?
>> While it is possible to construct test cases for this problem using C
>> inline functions, in practice the problem is going to arise in C++.
>> In C++ it's similar to the problem solved by using ABI tags. This
>> suggests to me that we should have a compiler option allowing an ABI
>> tag to be specified for all weak definitions. As far as I can see
>> that would address the entire problem, with no confusion about -r, and
>> permitting optimized functions to call optimized versions of the vague
>> linkage definitions.
> Sounds interesting. I will leave Sri to evaluate this approach :)
Yes, thanks for the feedback. I will take a look at this.