This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Two level comdat priorities in gold
- From: Cary Coutant <ccoutant at gmail dot com>
- To: Sriraman Tallam <tmsriram at google dot com>
- Cc: Ian Lance Taylor <iant at google dot com>, Xinliang David Li <davidxl at google dot com>, binutils <binutils at sourceware dot org>, Paul Pluzhnikov <ppluzhnikov at google dot com>, Daniel Berlin <dannyb at google dot com>
- Date: Thu, 23 Jul 2015 10:17:51 -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> <CAAs8Hmyy2A8Ly-bXxVXu16pWcHkA71tmat747CGeF3aTGcJ9SQ at mail dot gmail dot com> <CAJimCsFkbsrOSRagS7aHEzxoLH_-8AF49yWS8S_Y11rV9YdsKQ at mail dot gmail dot com> <CAAs8HmyAkkA0+7jHd9HCDT-pHVDO7V446Z97CEFAJaRY+-M1aQ at mail dot gmail dot com> <CAKOQZ8xqOZ=UApsOWq5oSzDpRt_=nAOcPeYB+9CO6Foe4tvTzg at mail dot gmail dot com> <CAAs8Hmws26=3JudjXzxDNiNVDO2DV7tORG8afdVP4ZomorU_qg at mail dot gmail dot com>
>>> 2) Cary's idea of simply not applying the extra -mxxx flags on
>>> COMDATS, the out of line inlines and the instantiated template bodies.
>>>
>>> Unfortunately this idea does not work too for code like this:
>>>
>>> #ifdef __AVX__
>>> inline foo () {
>>> avx intrnsics
>>> }
>>> ...
>>> #else
>>> inline foo() {
>>> non-avx intrinsics.
>>> }
>>> ...
>>> #endif
>>>
>>> This means the AVX comdats are already there past the pre-processor
>>> once we use -mavx and we cannot undo this in the compiler. Example
>>> header : https://bitbucket.org/eigen/eigen/src/6ed647a644b8e3924800f0916a4ce4addf9e7739/Eigen/Core?at=default
>>
>>
>> If you compile this code both with and without -mavx and link the
>> results together, you have a simple, no excuses, ODR violation, so I
>> don't find this example convincing.
>
> Agreed. It is clear there is a ODR violation but this usage is also
> not uncommon. Unless multiple binaries, one for each target variant,
> are built there is going to be a ODR violation with using such
> headers. I was hoping for a mitigation mechanism.
Shouldn't these functions be declared static and/or
"__attribute__((always_inline))"? Static would take care of the ODR
violations, and always_inline ought to ensure there are no COMDATs for
out-of-line inlines.
-cary