[ECOS] Re: issue with floor()

Sergei Gavrikov sergei.gavrikov@gmail.com
Wed Nov 10 20:08:00 GMT 2010


On Wed, 10 Nov 2010, Sergei Gavrikov wrote:

> On Wed, 10 Nov 2010, Grant Edwards wrote:
>
>> On 2010-11-10, David Brennan <david@brennanhome.com> wrote:
>> 
>>> [...]
>>> So it looks like this may actually be an eCos source code problem. I
>>> can take a stab at fixing this. But if anyone happens to know right
>>> away how to do it, I'd welcome the help. This code is not the most
>>> straight forward.
>>> [...]
>> 
>> Yep. Things like this are bound to happen when compiler warnings are
>> ignored.
>> 
>>> the option -fno-strict-aliasing can be used as a work-around.
>> 
>> Well, I'd try adding -fno-stric-aliasing to the compile options for
>> the relevent packages.
>> 
>> If that fixes it, then you've confirmed the source of the problem, and
>> the next step is to decide whether to try fixing the libm code or not.
>
> Hi,
>
> It was surprise for me that cdl_option CYGPKG_LIBM_CFLAGS_ADD are not
> evaluated properly:
>
>  CVS libm.cdl:
>  cdl_option CYGPKG_LIBM_CFLAGS_ADD {
>      display "Additional compiler flags"
>      flavor  data
>      no_define
>      default_value { "-fno-strict-aliasing " . \
>                          ((0 == CYGPKG_HAL_I386) && (0 == 
> CYGPKG_HAL_SYNTH_I386)) ? "" : "-ffloat-store" }
>      description   "
>          This option modifies the set of compiler flags for
>          building the math library. These flags are used in addition
>          to the set of global flags."
>  }
>
> What I expected to get then? That _would_ be either
>
>  "-fno-strict-aliasing " or  "-fno-strict-aliasing -ffloat-store"
>
> Right?
>
> But final value for LIBM_CFLAGS_ADD is *always*  "" (empty string).
>
> Try, please:
>
>  % ecosconfig new {pc,linux,pid}
>  % less -p 'LIBM_CFLAGS_ADD ' ecos.ecc
>
> CDL concatenation does not work as I would expect. It seems for me
> that in the expession are missed parentheses.
>
> The below works as I could expect
>
>        default_value { "-fno-strict-aliasing " . \
>                            (((0 == CYGPKG_HAL_I386) && (0 == 
> CYGPKG_HAL_SYNTH_I386)) ? "" : "-ffloat-store") }
>
> Can anybody confirm this?
>
> RFC:
>
> Why is it used comparisons the 0s with CDL 'booldata' in the expression?
> What is about (!CYGPKG_A && !CYGPKG_B) there?

FYI: just now I tried to build libm tests for eCos synthetic target and 
invoke the built floor ELF

Environment:

eCos    AnonCVS eCos
GCC     gcc-4.4.real (Ubuntu 4.4.3-4ubuntu5) 4.4.3

Summary:

* The first built `floor' from CVS failed as described in the post;
* The second one (built with CDL fix) executable passed smoothly.

The both builds are optimizated by default, -O2.

The fix was:

     # Default value:  "-fno-strict-aliasing " .  \
         ((!CYGPKG_HAL_I386 && !CYGPKG_HAL_SYNTH_I386) ? "" : "-ffloat-store")


Sergei

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list