From 94f00e9b1d94635238571e9bc9cc415ef5253ccd Mon Sep 17 00:00:00 2001 From: Ben Gamari <ben@smart-cactus.org> Date: Mon, 19 Dec 2022 12:23:50 -0500 Subject: [PATCH] hadrian: Ensure that -Werror is passed when compiling the RTS. Previously the `+werror` transformer would only pass `-Werror` to GHC, which does not ensure that the same is passed to the C compiler when building the RTS. Arguably this is itself a bug but for now we will just work around this by passing `-optc-Werror` to GHC. I tried to enable `-Werror` in all C compilations but the boot libraries are something of a portability nightmare. --- hadrian/src/Flavour.hs | 19 ++++++++++++++----- rts/sm/NonMovingMark.c | 6 +----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/hadrian/src/Flavour.hs b/hadrian/src/Flavour.hs index cc2d6db407cd..5dd70580ce21 100644 --- a/hadrian/src/Flavour.hs +++ b/hadrian/src/Flavour.hs @@ -123,16 +123,25 @@ addArgs args' fl = fl { extraArgs = extraArgs fl <> args' } -- from warnings. werror :: Flavour -> Flavour werror = - addArgs - ( builder Ghc + addArgs $ mconcat + [ builder Ghc ? notStage0 ? mconcat - [ arg "-Werror", - flag CrossCompiling + [ arg "-Werror" + , flag CrossCompiling ? package unix ? mconcat [arg "-Wwarn=unused-imports", arg "-Wwarn=unused-top-binds"] ] - ) + , builder Ghc + ? package rts + ? mconcat + [ arg "-optc-Werror" + -- clang complains about #pragma GCC pragmas + , arg "-optc-Wno-error=unknown-pragmas" + ] + -- N.B. We currently don't build the boot libraries' C sources with -Werror + -- as this tends to be a portability nightmare. + ] -- | Build C and Haskell objects with debugging information. enableDebugInfo :: Flavour -> Flavour diff --git a/rts/sm/NonMovingMark.c b/rts/sm/NonMovingMark.c index c493cd4dd96c..af2bce354db9 100644 --- a/rts/sm/NonMovingMark.c +++ b/rts/sm/NonMovingMark.c @@ -39,9 +39,7 @@ static void trace_PAP_payload (MarkQueue *queue, StgClosure *fun, StgClosure **payload, StgWord size); -#if defined(DEBUG) -static bool is_nonmoving_weak(StgWeak *weak); -#endif +static bool is_nonmoving_weak(StgWeak *weak) USED_IF_DEBUG; // How many Array# entries to add to the mark queue at once? #define MARK_ARRAY_CHUNK_LENGTH 128 @@ -1975,7 +1973,6 @@ void nonmovingMarkWeakPtrList (struct MarkQueue_ *queue) // Determine whether a weak pointer object is on one of the nonmoving // collector's weak pointer lists. Used for sanity checking. -#if defined(DEBUG) static bool is_nonmoving_weak(StgWeak *weak) { for (StgWeak *w = nonmoving_old_weak_ptr_list; w != NULL; w = w->link) { @@ -1986,7 +1983,6 @@ static bool is_nonmoving_weak(StgWeak *weak) } return false; } -#endif // Non-moving heap variant of `tidyWeakList` bool nonmovingTidyWeaks (struct MarkQueue_ *queue) -- GitLab