From: Sascha Wildner Date: Mon, 23 Sep 2013 18:33:02 +0000 (+0200) Subject: libc: Raise WARNS to 1 and fix warnings. X-Git-Tag: v3.7.0~310 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/450f08dbfd98cded95c51be4079ef10f5adb3241 libc: Raise WARNS to 1 and fix warnings. * Raise the priorities of our constructor functions from 0 to 101 because 0-100 are reserved priorities. This results in no change in object code (as per comparison using hexdump(1)). * Provide a prototype for _pthread_init_early(). * Be less strict in the exclusion of gdtoa's files to also match the files outside contrib/ (in lib/libc/gdtoa/). Do the same for libc_rtld. * Also fix an ignored attribute warning due to __thread being defined empty in libc_rtld. Note that the most important aspect of this commit is that it causes libc to no longer be built with -w (suppress all warnings). This was the result of a hack we have to ignore warnings for gdtoa (which resides in contrib/). But in conjunction with WARNS being 0 it led to -w being set for _all_ files of libc. Removing -w causes all the warnings which are enabled by default (even without any -W options) to trigger again, in addition the few -W options that WARNS=1 actually sets. Thanks to aggelos for useful clues. --- diff --git a/lib/libc/Makefile b/lib/libc/Makefile index ec34b8b0ca..c4ad1ce966 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -38,4 +38,4 @@ libkern.${MACHINE_ARCH}:: ${KMSRCS} .include # Disable warnings in contributed sources. -CWARNFLAGS:= ${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/} +CWARNFLAGS:= ${.IMPSRC:N*dtoa*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/} diff --git a/lib/libc/Makefile.inc b/lib/libc/Makefile.inc index a7fd9bb19e..714fb6d17d 100644 --- a/lib/libc/Makefile.inc +++ b/lib/libc/Makefile.inc @@ -10,7 +10,7 @@ MDASM= MIASM= NOASM= -WARNS=0 +WARNS=1 .include "${.CURDIR}/../libc/${MACHINE_ARCH}/Makefile.inc" diff --git a/lib/libc/gen/_pthread_stubs.c b/lib/libc/gen/_pthread_stubs.c index d4e32a0304..90a34440ee 100644 --- a/lib/libc/gen/_pthread_stubs.c +++ b/lib/libc/gen/_pthread_stubs.c @@ -232,7 +232,8 @@ stub_exit(void) * If libpthread is loaded, make sure it is initialised before * other libraries call pthread functions */ -void _pthread_init(void) __constructor(0); +void _pthread_init(void) __constructor(101); +void _pthread_init_early(void); void _pthread_init(void) { diff --git a/lib/libc/stdlib/dmalloc.c b/lib/libc/stdlib/dmalloc.c index 32a51e8cac..c2bf9775dd 100644 --- a/lib/libc/stdlib/dmalloc.c +++ b/lib/libc/stdlib/dmalloc.c @@ -322,7 +322,7 @@ static void *_vmem_alloc(int ri, size_t slab_size); static void _vmem_free(void *ptr, size_t slab_size); static void _mpanic(const char *ctl, ...) __printflike(1, 2); #ifndef STANDALONE_DEBUG -static void malloc_init(void) __constructor(0); +static void malloc_init(void) __constructor(101); #else static void malloc_init(void) __constructor(101); #endif diff --git a/lib/libc/stdlib/nmalloc.c b/lib/libc/stdlib/nmalloc.c index 7c79013925..e2ea54b643 100644 --- a/lib/libc/stdlib/nmalloc.c +++ b/lib/libc/stdlib/nmalloc.c @@ -297,9 +297,16 @@ typedef struct thr_mags { int init; } thr_mags; -/* With this attribute set, do not require a function call for accessing - * this variable when the code is compiled -fPIC */ -#define TLS_ATTRIBUTE __attribute__ ((tls_model ("initial-exec"))); +/* + * With this attribute set, do not require a function call for accessing + * this variable when the code is compiled -fPIC. Empty for libc_rtld + * (like __thread). + */ +#ifdef __LIBC_RTLD +#define TLS_ATTRIBUTE +#else +#define TLS_ATTRIBUTE __attribute__ ((tls_model ("initial-exec"))) +#endif static int mtmagazine_free_live; static __thread thr_mags thread_mags TLS_ATTRIBUTE; @@ -345,7 +352,7 @@ static void mtmagazine_destructor(void *); static slzone_t zone_alloc(int flags); static void zone_free(void *z); static void _mpanic(const char *ctl, ...) __printflike(1, 2); -static void malloc_init(void) __constructor(0); +static void malloc_init(void) __constructor(101); #if defined(INVARIANTS) static void chunk_mark_allocated(slzone_t z, void *chunk); static void chunk_mark_free(slzone_t z, void *chunk); diff --git a/lib/libc_rtld/Makefile b/lib/libc_rtld/Makefile index 5071540f81..8426038c77 100644 --- a/lib/libc_rtld/Makefile +++ b/lib/libc_rtld/Makefile @@ -10,6 +10,7 @@ CFLAGS+=-I${.CURDIR}/../../include CFLAGS+=-I${.CURDIR}/../libc/${MACHINE_ARCH} CFLAGS+=-I${.OBJDIR} CFLAGS+=-D__thread= +CFLAGS+=-D__LIBC_RTLD PRECIOUSLIB= yes @@ -37,3 +38,6 @@ HIDDEN_SYSCALLS= aio_suspend.o accept.o bind.o close.o connect.o dup.o dup2.o \ .PATH: ${.CURDIR}/../libc/resolv .include + +# Disable warnings in contributed sources. +CWARNFLAGS:= ${.IMPSRC:N*dtoa*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/}