This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.


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

Re: newlib or glibc ?


Brendan Simon wrote:
> 
> I wish to cross compile gcc to m68k and ppc embbedded systems.  I wish
> to be able to cross compile on Linux and Win32 platforms and generate
> exactly the same output files.  ie.  I prefer to use Linux while other
> coworkers prefer to use Win95.  To use the cross-compiler I need (not
> needed but prefer to have) a standard C and C++ library.
> 
> Do newlib and glibc do the same/similar thing ?
> >From my understanding they are both standard C libraries.
> If they are interchangeable then I would think that glibc would be
> better as it is used in naitive GCC ports to OSs such as Linux and
> Win95.   This would make simulating things more consistant as the same C
> libraries would be used on the hosts and the embedded systems.

Ignoring all technical issues whatsoever, the biggest issue is licensing.
glibc is covered by the LGPL (which is the GNU library general public
license), which includes sections like:

-----
"You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License.  You must supply a copy of this License.  If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License.  Also, you must do one
of these things:

    a) Accompany the work with the complete corresponding
    machine-readable source code for the Library including whatever
    changes were used in the work (which must be distributed under
    Sections 1 and 2 above); and, if the work is an executable linked
    with the Library, with the complete machine-readable "work that
    uses the Library", as object code and/or source code, so that the
    user can modify the Library and then relink to produce a modified
    executable containing the modified Library.  (It is understood
    that the user who changes the contents of definitions files in the
    Library will not necessarily be able to recompile the application
    to use the modified definitions.)

    b) Accompany the work with a written offer, valid for at
    least three years, to give the same user the materials
    specified in Subsection 6a, above, for a charge no more
    than the cost of performing this distribution.

    c) If distribution of the work is made by offering access to copy
    from a designated place, offer equivalent access to copy the above
    specified materials from the same place.

    d) Verify that the user has already received a copy of these
    materials or that you have already sent this user a copy.

  For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it."
-----

I believe most embedded software producers dislike these restrictions. For
linux systems (for example), it doesn't matter because you don't distribute
glibc with your code - most new linux systems have glibc installed.

Hence the existence of newlib, which was put together primarily for
licence-free use in embedded systems so that they did not have odd
requirements made of their end-product. Frankly it isn't as "good" as glibc,
as it doesn't have the same degree of volunteer effort put into it, but it
has everything you would want for a standard C library. For example, to
correct you, it is newlib that is used in cygwin32 for the ports of gcc to
win95.

Hope this helps,

Jonathan L.
-- 
Cygnus Solutions, 35 Cambridge Place, Cambridge, UK.  Tel: +44 (1223) 728762
"It is impossible to enjoy idling thoroughly unless||Home e-mail: jifl @ 
one has plenty of work to do" - Jerome K. Jerome   ||     jifvik.demon.co.uk
Help fight spam! http://spam.abuse.net/  These opinions are all my own fault