Recent libgcc builds have been triggering -Wbuiltin-declaration-mismatch due to the declaration of the __clear_cache built-in being incompatible with how GCC declares it internally. The attached patch adjusts the libgcc declaration and the one in the manual to match what GCC expects.
Tested on x86_64-linux. Martin
libgcc/ChangeLog: * libgcc2.h (__clear_cache): Correct signature. * libgcc2.c (__clear_cache): Same. gcc/ChangeLog: * doc/extend.texi (__clear_cache): Correct signature. gcc/testsuite/ChangeLog: * gcc.dg/Wbuiltin-declaration-mismatch-12.c: New test. Index: libgcc/libgcc2.h =================================================================== --- libgcc/libgcc2.h (revision 268583) +++ libgcc/libgcc2.h (working copy) @@ -30,7 +30,7 @@ see the files COPYING3 and COPYING.RUNTIME respect #endif extern int __gcc_bcmp (const unsigned char *, const unsigned char *, size_t); -extern void __clear_cache (char *, char *); +extern void __clear_cache (void *, void *); extern void __eprintf (const char *, const char *, unsigned int, const char *) __attribute__ ((__noreturn__)); Index: libgcc/libgcc2.c =================================================================== --- libgcc/libgcc2.c (revision 268583) +++ libgcc/libgcc2.c (working copy) @@ -2162,11 +2162,14 @@ __eprintf (const char *string, const char *express /* Clear part of an instruction cache. */ void -__clear_cache (char *beg __attribute__((__unused__)), - char *end __attribute__((__unused__))) +__clear_cache (void *beg __attribute__((__unused__)), + void *end __attribute__((__unused__))) { #ifdef CLEAR_INSN_CACHE - CLEAR_INSN_CACHE (beg, end); + /* Cast the void* pointers to char* as some implementations + of the macro assume the pointers can be subtracted from + one another. */ + CLEAR_INSN_CACHE ((char *) beg, (char *) end); #endif /* CLEAR_INSN_CACHE */ } Index: gcc/doc/extend.texi =================================================================== --- gcc/doc/extend.texi (revision 268583) +++ gcc/doc/extend.texi (working copy) @@ -13073,7 +13073,7 @@ void foo (void) @end deftypefn -@deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end}) +@deftypefn {Built-in Function} void __builtin___clear_cache (void *@var{begin}, void *@var{end}) This function is used to flush the processor's instruction cache for the region of memory between @var{begin} inclusive and @var{end} exclusive. Some targets require that the instruction cache be Index: gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-12.c =================================================================== --- gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-12.c (nonexistent) +++ gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-12.c (working copy) @@ -0,0 +1,8 @@ +/* Verify that declaring the __clear_cache and __builtin_prefetch + intrinsic functions with the wrong signature is diagnosed. + { dg-do compile } + { dg-options "-Wbuiltin-declaration-mismatch -Wextra" } */ + +extern void __clear_cache (char*, char*); /* { dg-warning "mismatch in argument 1 type of built-in function .__clear_cache.; expected .void \\\*." } */ + +void __builtin_prefetch (const char *, ...); /* { dg-warning "mismatch in argument 1 type of built-in function .__builtin_prefetch.; expected .const void \\\*." } */