[PATCH] Add Berkeley qsort to libiberty to make GCC host-independent

Ian Lance Taylor iant@google.com
Wed Aug 13 13:57:00 GMT 2014


On Wed, Aug 13, 2014 at 6:31 AM, Jeff Law <law@redhat.com> wrote:
> On 08/13/14 06:12, Felix Yang wrote:
>>
>> Hi all,
>>
>>      The qsort library function may have different behavior on
>> different hosts (say Linux vs MinGW).
>>      We may have different sorting results with qsort when there are
>> elements with the same key value.
>>      GCC uses qsort a lot. And the output of certain optimizations,
>> such as IRA, relies on the sorting result of this library function.
>>      The problem is that we may have different assembly code of GCC on
>> different hosts even with the same source file.
>>      Normally this is not what a GCC user expect to see.
>>      In order to fix this issue, I am adding Berkeley qsort to
>> libiberty in order to override the one from the library.
>>
>>      Bootstrapped on x86_64-suse-linux, OK for trunk? Please help
>> commit this patch if it's OK.
>
> Or we find the cases where the sort comparison routine can be tweaked to
> make it stable which makes this class of problems go away.

I tend to agree.  When we want a fully specified sort, it seems to me
we should use a fully specified comparison routine.

Ian



More information about the Gcc-patches mailing list