Skip to content
Browse files

Fix gcc 4.6 warnings; fixes #5176

Based on a patch from David Terei.

Some parts are a little ugly (e.g. defining things that only ASSERTs
use only when DEBUG is defined), so we might want to tweak things a
little.

I've also turned off -Werror for didn't-inline warnings, as we now
get a few such warnings.
  • Loading branch information...
1 parent 12b9388 commit 0a6f26f6d29c8762b254e2f1040fce5c3571feea @igfoo igfoo committed Jun 24, 2011
Showing with 89 additions and 29 deletions.
  1. +4 −1 aclocal.m4
  2. +1 −0 mk/config.mk.in
  3. +9 −0 mk/validate-settings.mk
  4. +16 −4 rts/Interpreter.c
  5. +12 −2 rts/Linker.c
  6. +9 −9 rts/ProfHeap.c
  7. +7 −0 rts/Profiling.h
  8. +2 −2 rts/STM.c
  9. +8 −2 rts/Schedule.c
  10. +2 −2 rts/Task.c
  11. +4 −3 rts/Trace.h
  12. +13 −2 rts/sm/GC.c
  13. +2 −2 rts/sm/GCUtils.c
View
5 aclocal.m4
@@ -742,7 +742,8 @@ if test -z "$GCC"
then
AC_MSG_ERROR([gcc is required])
fi
-GccLT34=
+GccLT34=NO
+GccLT46=NO
AC_CACHE_CHECK([version of gcc], [fp_cv_gcc_version],
[
fp_cv_gcc_version="`$CC -v 2>&1 | grep 'version ' | sed -e 's/.*version [[^0-9]]*\([[0-9.]]*\).*/\1/g'`"
@@ -752,9 +753,11 @@ AC_CACHE_CHECK([version of gcc], [fp_cv_gcc_version],
# isn't a very good reason for that, but for now just make configure
# fail.
FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-lt], [3.4], GccLT34=YES)
+ FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-lt], [4.6], GccLT46=YES)
])
AC_SUBST([GccVersion], [$fp_cv_gcc_version])
AC_SUBST(GccLT34)
+AC_SUBST(GccLT46)
])# FP_GCC_VERSION
dnl Small feature test for perl version. Assumes PerlCmd
View
1 mk/config.mk.in
@@ -535,6 +535,7 @@ endif
WhatGccIsCalled = @WhatGccIsCalled@
GccVersion = @GccVersion@
GccLT34 = @GccLT34@
+GccLT46 = @GccLT46@
CC = $(WhatGccIsCalled)
CC_STAGE0 = @CC_STAGE0@
CC_STAGE1 = $(CC)
View
9 mk/validate-settings.mk
@@ -4,7 +4,16 @@
WERROR = -Werror
HADDOCK_DOCS = YES
+
SRC_CC_OPTS += -Wall $(WERROR)
+# Debian doesn't turn -Werror=unused-but-set-variable on by default, so
+# we turn it on explicitly for consistency with other users
+ifeq "$(GccLT46)" "NO"
+SRC_CC_OPTS += -Werror=unused-but-set-variable
+endif
+# gcc 4.6 gives 3 warning for giveCapabilityToTask not being inlined
+SRC_CC_OPTS += -Wno-error=inline
+
SRC_HC_OPTS += -Wall $(WERROR) -H64m -O0
# Safe by default
View
20 rts/Interpreter.c
@@ -49,13 +49,21 @@
/* Sp points to the lowest live word on the stack. */
-#define BCO_NEXT instrs[bciPtr++]
-#define BCO_NEXT_32 (bciPtr += 2, (((StgWord) instrs[bciPtr-2]) << 16) + ((StgWord) instrs[bciPtr-1]))
-#define BCO_NEXT_64 (bciPtr += 4, (((StgWord) instrs[bciPtr-4]) << 48) + (((StgWord) instrs[bciPtr-3]) << 32) + (((StgWord) instrs[bciPtr-2]) << 16) + ((StgWord) instrs[bciPtr-1]))
+#define BCO_NEXT instrs[bciPtr++]
+#define BCO_NEXT_32 (bciPtr += 2)
+#define BCO_READ_NEXT_32 (BCO_NEXT_32, (((StgWord) instrs[bciPtr-2]) << 16) \
+ + ( (StgWord) instrs[bciPtr-1]))
+#define BCO_NEXT_64 (bciPtr += 4)
+#define BCO_READ_NEXT_64 (BCO_NEXT_64, (((StgWord) instrs[bciPtr-4]) << 48) \
+ + (((StgWord) instrs[bciPtr-3]) << 32) \
+ + (((StgWord) instrs[bciPtr-2]) << 16) \
+ + ( (StgWord) instrs[bciPtr-1]))
#if WORD_SIZE_IN_BITS == 32
#define BCO_NEXT_WORD BCO_NEXT_32
+#define BCO_READ_NEXT_WORD BCO_READ_NEXT_32
#elif WORD_SIZE_IN_BITS == 64
#define BCO_NEXT_WORD BCO_NEXT_64
+#define BCO_READ_NEXT_WORD BCO_READ_NEXT_64
#else
#error Cannot cope with WORD_SIZE_IN_BITS being nether 32 nor 64
#endif
@@ -776,8 +784,12 @@ interpretBCO (Capability* cap)
register StgWord16* instrs = (StgWord16*)(bco->instrs->payload);
register StgWord* literals = (StgWord*)(&bco->literals->payload[0]);
register StgPtr* ptrs = (StgPtr*)(&bco->ptrs->payload[0]);
+#ifdef DEBUG
int bcoSize;
- bcoSize = BCO_NEXT_WORD;
+ bcoSize = BCO_READ_NEXT_WORD;
+#else
+ BCO_NEXT_WORD;
+#endif
IF_DEBUG(interpreter,debugBelch("bcoSize = %d\n", bcoSize));
#ifdef INTERP_STATS
View
14 rts/Linker.c
@@ -1190,11 +1190,15 @@ initLinker( void )
compileResult = regcomp(&re_invalid,
"(([^ \t()])+\\.so([^ \t:()])*):([ \t])*(invalid ELF header|file too short)",
REG_EXTENDED);
- ASSERT( compileResult == 0 );
+ if (compileResult != 0) {
+ barf("Compiling re_invalid failed");
+ }
compileResult = regcomp(&re_realso,
"(GROUP|INPUT) *\\( *(([^ )])+)",
REG_EXTENDED);
- ASSERT( compileResult == 0 );
+ if (compileResult != 0) {
+ barf("Compiling re_realso failed");
+ }
# endif
#if !defined(ALWAYS_PIC) && defined(x86_64_HOST_ARCH)
@@ -4124,10 +4128,14 @@ do_Elf_Rel_relocations ( ObjectCode* oc, char* ehdrC,
Elf_Addr P = ((Elf_Addr)targ) + offset;
Elf_Word* pP = (Elf_Word*)P;
+#if defined(i386_HOST_ARCH) || defined(DEBUG)
Elf_Addr A = *pP;
+#endif
Elf_Addr S;
void* S_tmp;
+#ifdef i386_HOST_ARCH
Elf_Addr value;
+#endif
StgStablePtr stablePtr;
StgPtr stableVal;
@@ -4171,7 +4179,9 @@ do_Elf_Rel_relocations ( ObjectCode* oc, char* ehdrC,
(void*)P, (void*)S, (void*)A ));
checkProddableBlock ( oc, pP );
+#ifdef i386_HOST_ARCH
value = S + A;
+#endif
switch (ELF_R_TYPE(info)) {
# ifdef i386_HOST_ARCH
View
18 rts/ProfHeap.c
@@ -839,7 +839,7 @@ heapCensusChain( Census *census, bdescr *bd )
nat size;
counter *ctr;
nat real_size;
- rtsBool prim;
+ PROFILING_ONLY( rtsBool prim );
for (; bd != NULL; bd = bd->link) {
@@ -854,7 +854,7 @@ heapCensusChain( Census *census, bdescr *bd )
p = bd->start;
while (p < bd->free) {
info = get_itbl((StgClosure *)p);
- prim = rtsFalse;
+ PROFILING_ONLY( prim = rtsFalse );
switch (info->type) {
@@ -904,7 +904,7 @@ heapCensusChain( Census *census, bdescr *bd )
break;
case BCO:
- prim = rtsTrue;
+ PROFILING_ONLY ( prim = rtsTrue );
size = bco_sizeW((StgBCO *)p);
break;
@@ -915,7 +915,7 @@ heapCensusChain( Census *census, bdescr *bd )
case MUT_PRIM:
case MUT_VAR_CLEAN:
case MUT_VAR_DIRTY:
- prim = rtsTrue;
+ PROFILING_ONLY ( prim = rtsTrue );
size = sizeW_fromITBL(info);
break;
@@ -932,20 +932,20 @@ heapCensusChain( Census *census, bdescr *bd )
break;
case ARR_WORDS:
- prim = rtsTrue;
+ PROFILING_ONLY ( prim = rtsTrue );
size = arr_words_sizeW((StgArrWords*)p);
break;
case MUT_ARR_PTRS_CLEAN:
case MUT_ARR_PTRS_DIRTY:
case MUT_ARR_PTRS_FROZEN:
case MUT_ARR_PTRS_FROZEN0:
- prim = rtsTrue;
+ PROFILING_ONLY ( prim = rtsTrue );
size = mut_arr_ptrs_sizeW((StgMutArrPtrs *)p);
break;
case TSO:
- prim = rtsTrue;
+ PROFILING_ONLY ( prim = rtsTrue );
#ifdef PROFILING
if (RtsFlags.ProfFlags.includeTSOs) {
size = sizeofW(StgTSO);
@@ -961,7 +961,7 @@ heapCensusChain( Census *census, bdescr *bd )
#endif
case STACK:
- prim = rtsTrue;
+ PROFILING_ONLY ( prim = rtsTrue );
#ifdef PROFILING
if (RtsFlags.ProfFlags.includeTSOs) {
size = stack_sizeW((StgStack*)p);
@@ -977,7 +977,7 @@ heapCensusChain( Census *census, bdescr *bd )
#endif
case TREC_CHUNK:
- prim = rtsTrue;
+ PROFILING_ONLY ( prim = rtsTrue );
size = sizeofW(StgTRecChunk);
break;
View
7 rts/Profiling.h
@@ -12,6 +12,13 @@
#include <stdio.h>
#include "BeginPrivate.h"
+#include "Rts.h"
+
+#ifdef PROFILING
+#define PROFILING_ONLY(s) s
+#else
+#define PROFILING_ONLY(s) doNothing()
+#endif
void initProfiling1 (void);
void initProfiling2 (void);
View
4 rts/STM.c
@@ -1089,7 +1089,7 @@ static void disconnect_invariant(Capability *cap,
FOR_EACH_ENTRY(last_execution, e, {
StgTVar *s = e -> tvar;
StgTVarWatchQueue *q = s -> first_watch_queue_entry;
- StgBool found = FALSE;
+ DEBUG_ONLY( StgBool found = FALSE );
TRACE(" looking for trec on tvar=%p", s);
for (q = s -> first_watch_queue_entry;
q != END_STM_WATCH_QUEUE;
@@ -1110,7 +1110,7 @@ static void disconnect_invariant(Capability *cap,
}
TRACE(" found it in watch queue entry %p", q);
free_stg_tvar_watch_queue(cap, q);
- found = TRUE;
+ DEBUG_ONLY( found = TRUE );
break;
}
}
View
10 rts/Schedule.c
@@ -715,7 +715,9 @@ schedulePushWork(Capability *cap USED_IF_THREADS,
if (n_free_caps > 0) {
StgTSO *prev, *t, *next;
+#ifdef SPARK_PUSHING
rtsBool pushed_to_all;
+#endif
debugTrace(DEBUG_sched,
"cap %d: %s and %d free capabilities, sharing...",
@@ -725,7 +727,9 @@ schedulePushWork(Capability *cap USED_IF_THREADS,
n_free_caps);
i = 0;
+#ifdef SPARK_PUSHING
pushed_to_all = rtsFalse;
+#endif
if (cap->run_queue_hd != END_TSO_QUEUE) {
prev = cap->run_queue_hd;
@@ -740,7 +744,9 @@ schedulePushWork(Capability *cap USED_IF_THREADS,
setTSOPrev(cap, t, prev);
prev = t;
} else if (i == n_free_caps) {
+#ifdef SPARK_PUSHING
pushed_to_all = rtsTrue;
+#endif
i = 0;
// keep one for us
setTSOLink(cap, prev, t);
@@ -1892,7 +1898,7 @@ Capability *
scheduleWaitThread (StgTSO* tso, /*[out]*/HaskellObj* ret, Capability *cap)
{
Task *task;
- StgThreadID id;
+ DEBUG_ONLY( StgThreadID id );
// We already created/initialised the Task
task = cap->running_task;
@@ -1908,7 +1914,7 @@ scheduleWaitThread (StgTSO* tso, /*[out]*/HaskellObj* ret, Capability *cap)
appendToRunQueue(cap,tso);
- id = tso->id;
+ DEBUG_ONLY( id = tso->id );
debugTrace(DEBUG_sched, "new bound thread (%lu)", (unsigned long)id);
cap = schedule(cap,task);
View
4 rts/Task.c
@@ -347,8 +347,8 @@ taskDoneGC (Task *task, Ticks cpu_time, Ticks elapsed_time)
void
workerTaskStop (Task *task)
{
- OSThreadId id;
- id = osThreadId();
+ DEBUG_ONLY( OSThreadId id );
+ DEBUG_ONLY( id = osThreadId() );
ASSERT(task->id == id);
ASSERT(myTask() == task);
View
7 rts/Trace.h
@@ -194,7 +194,7 @@ void traceOSProcessInfo_ (void);
#define debugTrace(class, str, ...) /* nothing */
#define debugTraceCap(class, cap, str, ...) /* nothing */
#define traceThreadStatus(class, tso) /* nothing */
-#define traceEventStartup_(n_caps) /* nothing */
+INLINE_HEADER void traceEventStartup_ (int n_caps STG_UNUSED) {};
#define traceCapsetModify_(tag, capset, other) /* nothing */
#define traceOSProcessInfo_() /* nothing */
@@ -243,8 +243,9 @@ void dtraceUserMsgWrapper(Capability *cap, char *msg);
HASKELLEVENT_REQUEST_PAR_GC(cap)
#define dtraceCreateSparkThread(cap, spark_tid) \
HASKELLEVENT_CREATE_SPARK_THREAD(cap, spark_tid)
-#define dtraceStartup(num_caps) \
+INLINE_HEADER void dtraceStartup (int n_caps) {
HASKELLEVENT_STARTUP(num_caps)
+}
#define dtraceUserMsg(cap, msg) \
HASKELLEVENT_USER_MSG(cap, msg)
#define dtraceGcIdle(cap) \
@@ -278,7 +279,7 @@ void dtraceUserMsgWrapper(Capability *cap, char *msg);
#define dtraceRequestSeqGc(cap) /* nothing */
#define dtraceRequestParGc(cap) /* nothing */
#define dtraceCreateSparkThread(cap, spark_tid) /* nothing */
-#define dtraceStartup(num_caps) /* nothing */
+INLINE_HEADER void dtraceStartup (int n_caps STG_UNUSED) {};
#define dtraceUserMsg(cap, msg) /* nothing */
#define dtraceGcIdle(cap) /* nothing */
#define dtraceGcWork(cap) /* nothing */
View
15 rts/sm/GC.c
@@ -177,11 +177,15 @@ GarbageCollect (rtsBool force_major_gc,
bdescr *bd;
generation *gen;
lnat live_blocks, live_words, allocated, max_copied, avg_copied;
+#if defined(THREADED_RTS)
gc_thread *saved_gct;
+#endif
nat g, n;
// necessary if we stole a callee-saves register for gct:
+#if defined(THREADED_RTS)
saved_gct = gct;
+#endif
#ifdef PROFILING
CostCentreStack *prev_CCS;
@@ -956,7 +960,7 @@ any_work (void)
static void
scavenge_until_all_done (void)
{
- nat r;
+ DEBUG_ONLY( nat r );
loop:
@@ -973,8 +977,13 @@ scavenge_until_all_done (void)
collect_gct_blocks();
// scavenge_loop() only exits when there's no work to do
+
+#ifdef DEBUG
r = dec_running();
-
+#else
+ dec_running();
+#endif
+
traceEventGcIdle(gct->cap);
debugTrace(DEBUG_gc, "%d GC threads still running", r);
@@ -1400,8 +1409,10 @@ mark_root(void *user USED_IF_THREADS, StgClosure **root)
// so we need to save and restore it here. NB. only call
// mark_root() from the main GC thread, otherwise gct will be
// incorrect.
+#if defined(THREADED_RTS)
gc_thread *saved_gct;
saved_gct = gct;
+#endif
SET_GCT(user);
evacuate(root);
View
4 rts/sm/GCUtils.c
@@ -211,8 +211,8 @@ todo_block_full (nat size, gen_workspace *ws)
// Otherwise, push this block out to the global list.
else
{
- generation *gen;
- gen = ws->gen;
+ DEBUG_ONLY( generation *gen );
+ DEBUG_ONLY( gen = ws->gen );
debugTrace(DEBUG_gc, "push todo block %p (%ld words), step %d, todo_q: %ld",
bd->start, (unsigned long)(bd->free - bd->u.scan),
gen->no, dequeElements(ws->todo_q));

0 comments on commit 0a6f26f

Please sign in to comment.
Something went wrong with that request. Please try again.