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
> I probably should go to sleep - flag_hosted == 0 implies flag_no_builtin
> - so it should work correctly. The Linux makefile(s) simply have to
> specify -ffreestanding to get this to work correctly.
Not quite:
loewis 37 ( ~/tmp ) > cat a.c
struct X{
long foo[16];
};
void docopy(struct X* a,struct X* b)
{
*b=*a;
}
loewis 38 ( ~/tmp ) > gcc -v
Reading specs from gnu/lib/gcc-lib/sparc-sun-solaris2.5.1/2.96/specs
gcc version 2.96 20000228 (experimental)
loewis 39 ( ~/tmp ) > gcc -S -O2 -ffreestanding a.c
loewis 40 ( ~/tmp ) > cat a.s
.file "a.c"
gcc2_compiled.:
.section ".text"
.align 4
.global docopy
.type docopy,#function
.proc 020
docopy:
!#PROLOGUE# 0
save %sp, -112, %sp
!#PROLOGUE# 1
mov %i1, %o0
mov %i0, %o1
call memcpy, 0
mov 64, %o2
ret
restore
.LLfe1:
.size docopy,.LLfe1-docopy
.ident "GCC: (GNU) 2.96 20000228 (experimental)"
so it generated a memcpy call even with -ffreestanding. This is
because of (what I consider) a bug in gcc, which emits a call to
memcpy even when asked not to. The technical reason is that
-fno-builtin only disables availability of inline-optimizations for
user memcpy calls - the memcpy call generated by the block mover is
hard-coded, and does not care about freestanding or not.
Regards,
Martin