This is the mail archive of the cygwin mailing list for the Cygwin 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: Cygwin Perl and -Duselongdouble


Sisyphus wrote:

> >> I haven't checked for 'modfl' and 'frexpl', but 'sqrtl' at least seems to
> >> be
> >> available in the C compiler. Why does configure report that it's not
> >
> > Why do you say this?
> 
> Oh ... it's probably just ignorance on my part.
> If I can successfully run 'gcc script.c' (where 'script.c' contains a call
> to 'sqrtl') then I'm inclined to say that sqrtl is "available in the C
> compiler" (or something like that).

But you can't.  That command should fail on Cygwin.

> I gather from your response (and Corinna's) that there are also a couple of
> things called 'newlib' and 'libc' that enter into the equation. I don't know
> how they fit in. Feel free to enlighten me (but only if you're so inclined,
> as I realise that such an explanation is probably not on topic for this
> list).

libc is the generic name for the C standard library of functions.  It
has to come from somewhere; it's not part of gcc.  On Linux it is
typically the GNU libc (glibc), though on embedded Linux it might be
something else such as uclibc or dietlibc or newlib or ...  On Cygwin,
the libc functionality is provided by the Cygwin DLL, which internally
uses newlib to implement substantial portions (such as the stdio and
math related functions.)  On MinGW the libc is the Microsoft C library,
MSVCRT.DLL.

Again, note that this is totally independent of the compiler.  gcc runs
on all three of those systems but gcc is just a compiler, *not* a C
library.  It uses whatever the system provides.  Now gcc may provide
built-in replacements of some standard C library functions which it uses
when inlining -- for example it might know that it can replace a call to
the library function memcpy() with a simple direct assembly copy loop. 
But there always must be a library copy of the function backing these
builtins, they are only suppliments.

> I find it all quite confusing. My MinGW version of math.h specifically
> prototypes the "long double" version of a number of functions (ceill,
> floorl, sqrtl, modfl, ...), yet I can't find any mention of those functions
> in any of the gcc headers on Linux or Cygwin.

Thing these are three separate platforms, so don't expect them to behave
the same.  
glibc most definitely provides all those functions.  If you blindly grep
for them in header files you may not find them as glibc uses a twisty
maze of macros to implement headers.  Instead of blindly grepping around
in the dark though, use the manual.  There is a nice index that shows
precisely what the library supports:
<http://www.gnu.org/software/libc/manual/html_node/Function-Index.html>.

On MinGW, most of those C99 math functions don't exist in MSVCRT.DLL so
there is the mingwex helper library that implements them.

> If I call sqrtl on linux I have to link to -lm, on Cygwin I don't.

This is just a bit of historical trivia.  Back before shared libraries
were common and everything was statically linked, you had to be mindful
of the size of the executable and it was an "optimization" to leave all
the math stuff in a separate library so that it wouldn't accidently get
pulled in unless you wanted it.  This separation continues to this day
on some POSIX platforms even though nobody uses static linking any more,
so there's no real point to it.  Cygwin just puts everything in one
library, cygwin1.dll, so there is no point in this superfluous "-lm"
business, but it provides a "libm" for Makefiles that hard-code -lm.

> On linux I can build perl with -Duselongdouble, on Cygwin I can't.

Because linux has a C99-conforming libc where Cygwin doesn't.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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