Closed Quuxplusone closed 14 years ago
Bugzilla Link | PR3592 |
Status | RESOLVED FIXED |
Importance | P normal |
Reported by | bolzoni (bolzoni@cs.unipr.it) |
Reported on | 2009-02-16 03:27:34 -0800 |
Last modified on | 2010-03-12 00:57:46 -0800 |
Version | unspecified |
Hardware | All All |
CC | bagnara@cs.unipr.it, dgregor@apple.com, llvm-bugs@lists.llvm.org |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
This has been fixed in r64639. We now:
- Warn when a builtin is redeclared with an incompatible signature
- Error when a builtin is defined (if used as a hosted implementation)
- Suppress the generation of builtins when the option -ffreestanding is provided
I assume that the Linux kernel is building with -ffreestanding?
The linux kernel 2.4.37 does not need using `-ffreestanding' gcc flag.
So it is still impossible compile it with clang.
Ah, I see. Statics won't collide with standard library functions, since they aren't visible outside of that translation unit. This probably is fixed in r64736, for real.
Compilation of linux-2.4.37 still fails in linux-2.4.37/lib. There, string.c
is compiled with
-D__KERNEL__ -I/home/roberto/eclair/eclair/tests/linux/linux-2.4.37/include \
-Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common \
-fno-builtin-strpbrk -fno-builtin-sprintf -fomit-frame-pointer -mno-red-zone \
-mcmodel=kernel -pipe -fno-reorder-blocks -finline-limit=2000 \
-fno-strength-reduce -Wno-sign-compare -fno-asynchronous-unwind-tables \
-fno-unit-at-a-time -march=nocona -nostdinc -iwithprefix include \
-DKBUILD_BASENAME=string -c -o string.o string.c
which results into the following errors:
string.c:63:8: error: definition of library function 'strcpy' in a hosted implem
entation
char * strcpy(char * dest,const char *src)
^
string.c:63:8: note: use -ffreestanding to compile as a freestanding implementat
ion
string.c:84:8: error: definition of library function 'strncpy' in a hosted imple
mentation
char * strncpy(char * dest,const char *src,size_t count)
^
string.c:84:8: note: use -ffreestanding to compile as a freestanding implementat
ion
string.c:101:8: error: definition of library function 'strcat' in a hosted imple
mentation
char * strcat(char * dest, const char * src)
^
string.c:101:8: note: use -ffreestanding to compile as a freestanding implementa
tion
string.c:124:8: error: definition of library function 'strncat' in a hosted impl
ementation
char * strncat(char *dest, const char *src, size_t count)
^
string.c:124:8: note: use -ffreestanding to compile as a freestanding implementa
tion
string.c:189:8: error: definition of library function 'strchr' in a hosted imple
mentation
char * strchr(const char * s, int c)
^
string.c:189:8: note: use -ffreestanding to compile as a freestanding implementa
tion
string.c:204:8: error: definition of library function 'strrchr' in a hosted impl
ementation
char * strrchr(const char * s, int c)
^
string.c:204:8: note: use -ffreestanding to compile as a freestanding implementa
tion
string.c:220:8: error: definition of library function 'strlen' in a hosted imple
mentation
size_t strlen(const char * s)
^
string.c:220:8: note: use -ffreestanding to compile as a freestanding implementa
tion
string.c:253:8: error: definition of library function 'strspn' in a hosted imple
mentation
size_t strspn(const char *s, const char *accept)
^
string.c:253:8: note: use -ffreestanding to compile as a freestanding implementa
tion
string.c:279:8: error: definition of library function 'strpbrk' in a hosted impl
ementation
char * strpbrk(const char * cs,const char * ct)
^
string.c:279:8: note: use -ffreestanding to compile as a freestanding implementa
tion
string.c:493:8: error: definition of library function 'strstr' in a hosted imple
mentation
char * strstr(const char * s1,const char * s2)
^
string.c:493:8: note: use -ffreestanding to compile as a freestanding implementa
tion
The compilation of vsprintf.c in the same directory fails in the same way:
vsprintf.c:234:5: error: definition of library function 'vsnprintf' in a hosted
implementation
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
^
vsprintf.c:234:5: note: use -ffreestanding to compile as a freestanding implemen
tation
vsprintf.c:481:5: error: definition of library function 'snprintf' in a hosted i
mplementation
int snprintf(char * buf, size_t size, const char *fmt, ...)
^
vsprintf.c:481:5: note: use -ffreestanding to compile as a freestanding implemen
tation
vsprintf.c:501:5: error: definition of library function 'vsprintf' in a hosted i
mplementation
int vsprintf(char *buf, const char *fmt, va_list args)
^
vsprintf.c:501:5: note: use -ffreestanding to compile as a freestanding implemen
tation
vsprintf.c:513:5: error: definition of library function 'sprintf' in a hosted im
plementation
int sprintf(char * buf, const char *fmt, ...)
^
vsprintf.c:513:5: note: use -ffreestanding to compile as a freestanding implemen
tation
In linux-2.4.37/arch/x86_64/lib, the compilation of memmove.c fails:
memmove.c:8:7: error: definition of library function 'memmove' in a hosted imple
mentation
void *memmove(void * dest,const void *src,size_t count)
^
memmove.c:8:7: note: use -ffreestanding to compile as a freestanding implementat
ion
I've removed the offending diagnostic in r64767.