This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Patch to allow strlen expander to fail
- To: law at cygnus dot com
- Subject: Re: Patch to allow strlen expander to fail
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Tue, 7 Mar 2000 09:40:39 +0100
- CC: jbuck at racerx dot synopsys dot com, vonbrand at sleipnir dot valparaiso dot cl, gcc at gcc dot gnu dot org
- References: <6086.952410504@upchuck>
> The programmer can not and should not need to know the details of how that
> assignment is performed. If they think they need control over that kind of
> implementation detail, then they're barking up the wrong tree.
With the current gcc, the programmer *must* know such details. If she
ignores it, the program won't link in the end unless she provides a
memcpy implementation.
> The fix is for the linux kernel to link in libgcc or to use -nostdlib and
> provide its own memcpy routine.
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. According to C99, section
4, paragraph 6, in a freestanding environment, only the following
headers are available:
<float.h>
<iso646.h>
<limits.h>
<stdarg.h>
<stdbool.h>
<stddef.h>
<stdint.h>
As you can see, <string.h> is not required for a free-standing
environment, so the kernel is absolutely right not to provide one.
If it is a GCC requirement that <string.h> must be provided even in a
freestanding environment, then this requirement should be documented
(e.g. as an implementation restriction).
Regards,
Martin