This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Two level comdat priorities in gold


>>> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]