Patch to allow strlen expander to fail

Phil Edwards pedwards@jaj.com
Tue Mar 7 14:11:00 GMT 2000


Toon Moene wrotes:
> Martin v. Loewis wrote:
>
> > I can't see how linking libgcc helps; it does not provide a version of
> > memcpy, either. GCC currently assumes that the programs it generates
> > will be linked with the system's standard C library; that assumption
> > is incorrect for a freestanding environment. 
>
> Well, that's great, but the C Standard only asserts that there are two
> execution environments defined - it doesn't say how a particular
> compiler discerns whether it is compiling for one or the other
> environment.
>
> I think this can only be solved by having a compile time switch that
> makes clear which of the two environments one compiles for.  It's
> amazing to me that a compiler that's used so much in the embedded
> community, doesn't even _have_ -hosted and -freestanding options.

We're still talking about GCC, right?  Your wish has already been granted.
:-)  From the pages for 2.95.2:

#  `-fhosted'
#       Assert that compilation takes place in a hosted environment.  This
#       implies `-fbuiltin'.  A hosted environment is one in which the
#       entire standard library is available, and in which `main' has a
#       return type of `int'.  Examples are nearly everything except a
#       kernel.  This is equivalent to `-fno-freestanding'.
#  
#  `-ffreestanding'
#       Assert that compilation takes place in a freestanding environment.
#       This implies `-fno-builtin'.  A freestanding environment is one
#       in which the standard library may not exist, and program startup
#       may not necessarily be at `main'.  The most obvious example is an
#       OS kernel.  This is equivalent to `-fno-hosted'.

I couldn't tell you how those switches get used in the source, or what
they currently affect.


Luck++;
Phil



More information about the Gcc mailing list