Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )
Bernd Roesch schrieb: without changed headers old ompiler and libs do not work, because for C there is no sqrtf and other C99 funcs and many C++ programs get also many errors. Ok, you are trying to add C99 functions to your libc. Apparently you made a mistake if you get linker errors. i see old libstdc++ contain sqrtf but get many other linker errors. What is an "old libstdc++"? AFAICT there was/is no sqrtf function in libstdc++. In the sqrt case there are inline wrapper functions with either a float or a double arg. These inlines use an appropriate sqrt builtin. Since these builtins do not exist for your target the compiler generates a call to the real function without the __builtin prefix. there is also a sqrtf not undef in cmath as many other functions are. When i define sqrtf in math.h then the sqrtf func in libstdc++ is maybe not add and this strange linker error come.but wy it work not correct when i add sqrtf to libc i dont know.only solution below work. libstdc++ _requires_ real functions to be present in your libc. If you get linker errors then the linker cannot locate functions. There really is no need to play #define games on __builtin names to get it work. Gunther
Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )
Hallo Gunther Am 22.03.09 schriebst Du > How about using the original C-library of your system together with its > headers? After all the version you are currently using is an "alien" and without changed headers old ompiler and libs do not work, because for C there is no sqrtf and other C99 funcs and many C++ programs get also many errors. i see old libstdc++ contain sqrtf but get many other linker errors. there is also a sqrtf not undef in cmath as many other functions are. When i define sqrtf in math.h then the sqrtf func in libstdc++ is maybe not add and this strange linker error come.but wy it work not correct when i add sqrtf to libc i dont know.only solution below work. only this funcs are undef. // Get rid of those macros defined in in lieu of real functions. #undef abs #undef div #undef acos #undef asin #undef atan #undef atan2 #undef ceil #undef cos #undef cosh #undef exp #undef fabs #undef floor #undef fmod #undef frexp #undef ldexp #undef log #undef log10 #undef modf #undef pow #undef sin #undef sinh #undef sqrt #undef tan #undef tanh > Bernd Roesch wrote: >> I see in my c++config.h file >> >> this stand here >> >> /* Define if the compiler/host combination has __builtin_sqrtf. */ >> /* #undef _GLIBCXX_HAVE___BUILTIN_SQRTF */ >> >> I find now a solution that work without change of cmath >> >> when i add in math.h this line then it work.the function can too stand as >> static inline in the math.h file. >> >> #define __builtin_sqrtf sqrtf > > How about using the original C-library of your system together with its > headers? After all the version you are currently using is an "alien" and > doesn't fit for your system despite the fact that it was based on your > systems C-library and its headers. Carefully merging changes back to the > original version would be the better solution. > > Gunther > >>> On Mon, Mar 9, 2009 at 3:59 PM, Gabriel Dos Reis >>> wrote: On Mon, Mar 9, 2009 at 7:11 AM, Bernd Roesch wrote: > Hello Gabriel [...] > You see there is the _ not in.normaly funcs that not find have a _ > before > > To get all work, it seem i need add the same function add in math.h > and > in > the linker > lib or change cmath file and remove all __builtin_ commands the > architecture > not have. I believe one should convince the middle end to emit libcall for __builtin_xxx when the target has no builtint support. >>> It of course does. >>> >>> Richard. >> Regards > > > > mfg Bernd
Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )
Bernd Roesch wrote: I see in my c++config.h file this stand here /* Define if the compiler/host combination has __builtin_sqrtf. */ /* #undef _GLIBCXX_HAVE___BUILTIN_SQRTF */ I find now a solution that work without change of cmath when i add in math.h this line then it work.the function can too stand as static inline in the math.h file. #define __builtin_sqrtf sqrtf How about using the original C-library of your system together with its headers? After all the version you are currently using is an "alien" and doesn't fit for your system despite the fact that it was based on your systems C-library and its headers. Carefully merging changes back to the original version would be the better solution. Gunther On Mon, Mar 9, 2009 at 3:59 PM, Gabriel Dos Reis wrote: On Mon, Mar 9, 2009 at 7:11 AM, Bernd Roesch wrote: Hello Gabriel [...] You see there is the _ not in.normaly funcs that not find have a _ before To get all work, it seem i need add the same function add in math.h and in the linker lib or change cmath file and remove all __builtin_ commands the architecture not have. I believe one should convince the middle end to emit libcall for __builtin_xxx when the target has no builtint support. It of course does. Richard. Regards
Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )
Bernd Roesch writes: > Hello Richard > > On 09.03.09, you wrote: > >>> I believe one should convince the middle end to emit libcall >>> for __builtin_xxx when the target has no builtint support. >> >> It of course does. > > On what codeplace is the redefine do in GCC source ? This is in optabs.c, as set up by gen_libfunc and friends. A call to __builtin_xxx, where xxx is a library function, is normally replaced by a call to xxx. Where xxx is not a library function, gcc normally provides the function in libgcc. Ian
Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )
On Tue, Mar 10, 2009 at 7:58 AM, Bernd Roesch wrote: > Hello Richard > > On 09.03.09, you wrote: > >>> I believe one should convince the middle end to emit libcall >>> for __builtin_xxx when the target has no builtint support. >> >> It of course does. > > On what codeplace is the redefine do in GCC source ? > > I see in my c++config.h file > > this stand here > > /* Define if the compiler/host combination has __builtin_sqrtf. */ > /* #undef _GLIBCXX_HAVE___BUILTIN_SQRTF */ So, the real problem is that somehow configure thinks your target has support for __builtin_sqrtf. -- Gaby
Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )
Hello Richard On 09.03.09, you wrote: >> I believe one should convince the middle end to emit libcall >> for __builtin_xxx when the target has no builtint support. > > It of course does. On what codeplace is the redefine do in GCC source ? I see in my c++config.h file this stand here /* Define if the compiler/host combination has __builtin_sqrtf. */ /* #undef _GLIBCXX_HAVE___BUILTIN_SQRTF */ I find now a solution that work without change of cmath when i add in math.h this line then it work.the function can too stand as static inline in the math.h file. #define __builtin_sqrtf sqrtf > On Mon, Mar 9, 2009 at 3:59 PM, Gabriel Dos Reis > wrote: >> On Mon, Mar 9, 2009 at 7:11 AM, Bernd Roesch wrote: >>> Hello Gabriel >> [...] >>> >>> You see there is the _ not in.normaly funcs that not find have a _ >>> before >>> >>> To get all work, it seem i need add the same function add in math.h and >>> in >>> the linker >>> lib or change cmath file and remove all __builtin_ commands the >>> architecture >>> not have. >> >> I believe one should convince the middle end to emit libcall >> for __builtin_xxx when the target has no builtint support. > > It of course does. > > Richard. Regards
Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )
On Mon, Mar 9, 2009 at 9:03 AM, Richard Guenther wrote: >> I believe one should convince the middle end to emit libcall >> for __builtin_xxx when the target has no builtint support. > > It of course does. Then, Bernd's report appears to be a mystery. -- Gaby
Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )
On Mon, Mar 9, 2009 at 3:59 PM, Gabriel Dos Reis wrote: > On Mon, Mar 9, 2009 at 7:11 AM, Bernd Roesch wrote: >> Hello Gabriel > [...] >> >> You see there is the _ not in.normaly funcs that not find have a _ before >> >> To get all work, it seem i need add the same function add in math.h and in >> the linker >> lib or change cmath file and remove all __builtin_ commands the architecture >> not have. > > I believe one should convince the middle end to emit libcall > for __builtin_xxx when the target has no builtint support. It of course does. Richard.
Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )
On Mon, Mar 9, 2009 at 7:11 AM, Bernd Roesch wrote: > Hello Gabriel [...] > > You see there is the _ not in.normaly funcs that not find have a _ before > > To get all work, it seem i need add the same function add in math.h and in > the linker > lib or change cmath file and remove all __builtin_ commands the architecture > not have. I believe one should convince the middle end to emit libcall for __builtin_xxx when the target has no builtint support. -- Gaby
Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )
Hello Gabriel On 09.03.09, you wrote: > The above sqrt() function is distinct from the C version, because > it has a C++ linkage. Consequently, I would expect that if > __builtin_sqrtf() is not available, the compiler would emit a > library call to the out-of-line C version. But it dont work. I have define in math.h this func.see my below example source that show important parts.look a little ugly, but this is done to avoid in -o3 the remove of some function calls. real problem i see in libdirac inline float sqrtf(float x) { return sqrt(x); } ... int main(int argc, char** argv) { printf("%f\n",sqrtf((float)argc));// work printf("%f\n",std::sqrt(static_cast(argc))); // work not printf("%f\n",std::sqrt(static_cast(argc))); // work .. when i change c++/4.3.2/cmath to this code, then all work using ::sqrt; inline float sqrt(float __x) - { return __builtin_sqrtf(__x); } + { return sqrtf(__x); } . now you can come to the idea and add it as link func, maybe then it work. But then i get error at that line, but other lines work. printf("%f\n",sqrtf((float)argc)); undefined reference to `sqrtf(float)' You see there is the _ not in.normaly funcs that not find have a _ before To get all work, it seem i need add the same function add in math.h and in the linker lib or change cmath file and remove all __builtin_ commands the architecture not have. > On Mon, Mar 9, 2009 at 2:42 AM, Bernd Roesch wrote: >> Hello Richard >> >> On 06.03.09, you wrote: >> >> ah thanks for info, i understand now too wy sqrtf, fmod (work in C >> programs) >> get linker error on C++ programs but sqrt and some other work on >> platform >> 68k. >> in c++/4.3.2/cmath include >> >> is this code. >> >> using ::sqrt; >> >> inline float >> sqrt(float __x) >> { return __builtin_sqrtf(__x); } >> >> But .md file of many architetures contain no entry for this.I see only >> i386, >> rs6000, ia64, sh contain code for this.(I search for sqrtf and list >> files >> that contain this) >> the header files are build during GCC build, i change nothing. >> >> Is there something wrong during compiler Build process ? > > The above sqrt() function is distinct from the C version, because > it has a C++ linkage. Consequently, I would expect that if > __builtin_sqrtf() is not available, the compiler would emit a > library call to the out-of-line C version. > > -- Gaby Regards
Re: cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )
On Mon, Mar 9, 2009 at 2:42 AM, Bernd Roesch wrote: > Hello Richard > > On 06.03.09, you wrote: > > ah thanks for info, i understand now too wy sqrtf, fmod (work in C programs) > get linker error on C++ programs but sqrt and some other work on platform > 68k. > in c++/4.3.2/cmath include > > is this code. > > using ::sqrt; > > inline float > sqrt(float __x) > { return __builtin_sqrtf(__x); } > > But .md file of many architetures contain no entry for this.I see only i386, > rs6000, ia64, sh contain code for this.(I search for sqrtf and list files > that contain this) > the header files are build during GCC build, i change nothing. > > Is there something wrong during compiler Build process ? The above sqrt() function is distinct from the C version, because it has a C++ linkage. Consequently, I would expect that if __builtin_sqrtf() is not available, the compiler would emit a library call to the out-of-line C version. -- Gaby
cmath call builtin sqrtf but many platforms seem miss that(was Re: lrint lrintf problems )
Hello Richard On 06.03.09, you wrote: ah thanks for info, i understand now too wy sqrtf, fmod (work in C programs) get linker error on C++ programs but sqrt and some other work on platform 68k. in c++/4.3.2/cmath include is this code. using ::sqrt; inline float sqrt(float __x) { return __builtin_sqrtf(__x); } But .md file of many architetures contain no entry for this.I see only i386, rs6000, ia64, sh contain code for this.(I search for sqrtf and list files that contain this) the header files are build during GCC build, i change nothing. Is there something wrong during compiler Build process ? >> >> How can i then implement lrint func without asm Code ? > > If the backend does not support inlining lrint then you need to link > against a C99 math library (-lm). You can add lrint > patterns to m68k.md to provide inline expansions. > > Richard. > >> please help >> >> Regards