
Hi Eric, definitely not bit-rotted - the #if DEBUG code is what you get when you compile with -debug. Short roadmap: In general, GHC is built in many "ways", the -debug way is one. Some ways (like -threaded, -eventlog, -debug) are RTS-only, others (like -prof) lead to different library code. Ways are defined in compiler/main/DynFlags.hs as a Haskell data structure. In _dynamic_flags_, the actual flag strings for the ghc invocation are defined (like -prof, -threaded), they will activate the respective _Way_. _wayTag_, in turn, defines short names used as a suffix for *.o and *.a files, for instance *.p_o for profiling, *.l_o for eventlog. A number of other functions in there customise behaviour depending on the ways. Note _wayOptc_ which sets some options for the C compiler, like -DTRACING for the -eventlog way. However, it does not define DEBUG for the debug way! In mk/ways.mk you will find all the short names, and some more options are defined (WAY_*_HC_OPTS). These definitions are for the driver script, and pass on the right (long-name) options to the Haskell compiler to activate what is inside DynFlags (like -prof for WAY_p_HC_OPTS). Here we find WAY_debug_HC_OPTS= -static -optc-DDEBUG -ticky -DTICKY_TICKY which is what you were looking for To build a GHC with debug-way RTS, you need to add GhcRtsWays += debug to your build.mk (also see mk/config.mk{.in}, which gathers the default ways to build depending on platform and build configuration). I guess this might produce quite a number of new warnings and errors if you do it on a new platform... Once you have built this, you can compile with -debug and pass RTS options to get debug traces and activate sanity checks, like so: ghc -debug -myprogram.hs -o myprogramDebug ./myprogramDebug +RTS -Ds -DS (-DS = sanity checks on, -Ds = scheduler tracing) The usage message (see /rts/RtsFlags.c) tells you more options you can use. Happy debugging! / Jost On 05/14/2015 10:00 PM, ghc-devs-request@haskell.org wrote:
Date: Thu, 14 May 2015 18:36:04 +1000 From: Erik de Castro Lopo
To: ghc-devs@haskell.org Subject: Debugging the RTS Message-ID: <20150514183604.2476baaaacd6a85ef1430b37@mega-nerd.com> Content-Type: text/plain; charset=US-ASCII Hi all,
I'm trying to debug a AArch64/Linux specific RTS issue and digging around in the rts C code, I see a large amount of code wrapped in "#if DEBUG" type statements, but no way to enable in either mk/build.mk or it seems in any of the other build related settings files in the mk/ directory.
The only way I have found to enable this debug code that actually works is to enable this DEBUG code is to edit mk/ghc.mk as follows:
-STANDARD_OPTS += -DCOMPILING_RTS +STANDARD_OPTS += -DCOMPILING_RTS -DDEBUG
However, once I do that I get a bunch of C synatx errors.
I am doing this wrong or has the DEBUG code bit rotted?
Cheers, Erik

Searching for online resources brought me to
https://ghc.haskell.org/trac/ghc/wiki/Debugging and
https://ghc.haskell.org/trac/ghc/wiki/Debugging/RuntimeSystem
This mail seems to be a more detailed description than available on the
wiki. That page refers to GHC 6.12.
Would it make sense to add some info to the RuntimeSystem
https://ghc.haskell.org/trac/ghc/wiki/Debugging/RuntimeSystem page?
2015-05-14 16:21 GMT+02:00 Jost Berthold : Hi Eric, definitely not bit-rotted - the #if DEBUG code is what you get when you
compile with -debug. Short roadmap: In general, GHC is built in many "ways", the -debug way is one.
Some ways (like -threaded, -eventlog, -debug) are RTS-only, others (like
-prof) lead to different library code. Ways are defined in compiler/main/DynFlags.hs as a Haskell data structure.
In _dynamic_flags_, the actual flag strings for the ghc invocation are
defined (like -prof, -threaded), they will activate the respective _Way_.
_wayTag_, in turn, defines short names used as a suffix for *.o and *.a
files, for instance *.p_o for profiling, *.l_o for eventlog.
A number of other functions in there customise behaviour depending on the
ways. Note _wayOptc_ which sets some options for the C compiler, like
-DTRACING for the -eventlog way. However, it does not define DEBUG for the
debug way! In mk/ways.mk you will find all the short names, and some more options
are defined (WAY_*_HC_OPTS). These definitions are for the driver script,
and pass on the right (long-name) options to the Haskell compiler to
activate what is inside DynFlags (like -prof for WAY_p_HC_OPTS).
Here we find
WAY_debug_HC_OPTS= -static -optc-DDEBUG -ticky -DTICKY_TICKY
which is what you were looking for To build a GHC with debug-way RTS, you need to add GhcRtsWays += debug to
your build.mk (also see mk/config.mk{.in}, which gathers the default ways
to build depending on platform and build configuration).
I guess this might produce quite a number of new warnings and errors if
you do it on a new platform... Once you have built this, you can compile with -debug and pass RTS options
to get debug traces and activate sanity checks, like so:
ghc -debug -myprogram.hs -o myprogramDebug
./myprogramDebug +RTS -Ds -DS
(-DS = sanity checks on, -Ds = scheduler tracing)
The usage message (see /rts/RtsFlags.c) tells you more options you can use. Happy debugging!
/ Jost On 05/14/2015 10:00 PM, ghc-devs-request@haskell.org wrote: Date: Thu, 14 May 2015 18:36:04 +1000
From: Erik de Castro Lopo Hi all, I'm trying to debug a AArch64/Linux specific RTS issue and digging
around in the rts C code, I see a large amount of code wrapped in
"#if DEBUG" type statements, but no way to enable in either
mk/build.mk or it seems in any of the other build related settings
files in the mk/ directory. The only way I have found to enable this debug code that actually
works is to enable this DEBUG code is to edit mk/ghc.mk as follows: -STANDARD_OPTS += -DCOMPILING_RTS
+STANDARD_OPTS += -DCOMPILING_RTS -DDEBUG However, once I do that I get a bunch of C synatx errors. I am doing this wrong or has the DEBUG code bit rotted? Cheers,
Erik _______________________________________________
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

Good idea. I think it’d great if Jost (or someone else) felt able to update those wiki pages with the info in his email.
thanks!
Simon
From: ghc-devs [mailto:ghc-devs-bounces@haskell.org] On Behalf Of Lennart Kolmodin
Sent: 15 May 2015 11:31
To: Jost Berthold
Cc: ghc-devs@haskell.org
Subject: Re: Debugging the RTS
Searching for online resources brought me to
https://ghc.haskell.org/trac/ghc/wiki/Debugging and
https://ghc.haskell.org/trac/ghc/wiki/Debugging/RuntimeSystem
This mail seems to be a more detailed description than available on the wiki. That page refers to GHC 6.12.
Would it make sense to add some info to the RuntimeSystemhttps://ghc.haskell.org/trac/ghc/wiki/Debugging/RuntimeSystem page?
2015-05-14 16:21 GMT+02:00 Jost Berthold

On 05/15/2015 09:17 PM, Simon Peyton Jones wrote:
Good idea. I think it’d great if Jost (or someone else) felt able to update those wiki pages with the info in his email.
Sure, will do that. I am not sure whether either of those pages is the best place for information about the GHC ways. Maybe there is already a page about them in the commentary - I will take a look tomorrow and add the information about ways from the mail. If no page exists I'll add a page, and link to it from the Debugging/RuntimeSystem page. A few years ago, I wrote one page specifically about the parallel ways, http://ghc.haskell.org/trac/ghc/wiki/GpHEden/CompilerWays but the information is outdated. / Jost
thanks!
Simon
*From:*ghc-devs [mailto:ghc-devs-bounces@haskell.org] *On Behalf Of *Lennart Kolmodin *Sent:* 15 May 2015 11:31 *To:* Jost Berthold *Cc:* ghc-devs@haskell.org *Subject:* Re: Debugging the RTS
Searching for online resources brought me to
https://ghc.haskell.org/trac/ghc/wiki/Debugging and
https://ghc.haskell.org/trac/ghc/wiki/Debugging/RuntimeSystem
This mail seems to be a more detailed description than available on the wiki. That page refers to GHC 6.12.
Would it make sense to add some info to the RuntimeSystem https://ghc.haskell.org/trac/ghc/wiki/Debugging/RuntimeSystem page?
2015-05-14 16:21 GMT+02:00 Jost Berthold
mailto:berthold@mathematik.uni-marburg.de>: Hi Eric,
definitely not bit-rotted - the #if DEBUG code is what you get when you compile with -debug.
Short roadmap:
In general, GHC is built in many "ways", the -debug way is one. Some ways (like -threaded, -eventlog, -debug) are RTS-only, others (like -prof) lead to different library code.
Ways are defined in compiler/main/DynFlags.hs as a Haskell data structure. In _dynamic_flags_, the actual flag strings for the ghc invocation are defined (like -prof, -threaded), they will activate the respective _Way_. _wayTag_, in turn, defines short names used as a suffix for *.o and *.a files, for instance *.p_o for profiling, *.l_o for eventlog. A number of other functions in there customise behaviour depending on the ways. Note _wayOptc_ which sets some options for the C compiler, like -DTRACING for the -eventlog way. However, it does not define DEBUG for the debug way!
In mk/ways.mk http://ways.mk you will find all the short names, and some more options are defined (WAY_*_HC_OPTS). These definitions are for the driver script, and pass on the right (long-name) options to the Haskell compiler to activate what is inside DynFlags (like -prof for WAY_p_HC_OPTS). Here we find WAY_debug_HC_OPTS= -static -optc-DDEBUG -ticky -DTICKY_TICKY which is what you were looking for
To build a GHC with debug-way RTS, you need to add GhcRtsWays += debug to your build.mk http://build.mk (also see mk/config.mk http://config.mk{.in}, which gathers the default ways to build depending on platform and build configuration). I guess this might produce quite a number of new warnings and errors if you do it on a new platform...
Once you have built this, you can compile with -debug and pass RTS options to get debug traces and activate sanity checks, like so: ghc -debug -myprogram.hs -o myprogramDebug ./myprogramDebug +RTS -Ds -DS (-DS = sanity checks on, -Ds = scheduler tracing) The usage message (see /rts/RtsFlags.c) tells you more options you can use.
Happy debugging! / Jost
On 05/14/2015 10:00 PM, ghc-devs-request@haskell.org mailto:ghc-devs-request@haskell.org wrote:
Date: Thu, 14 May 2015 18:36:04 +1000 From: Erik de Castro Lopo
mailto:mle%2Bhs@mega-nerd.com> To: ghc-devs@haskell.org mailto:ghc-devs@haskell.org Subject: Debugging the RTS Message-ID: <20150514183604.2476baaaacd6a85ef1430b37@mega-nerd.com mailto:20150514183604.2476baaaacd6a85ef1430b37@mega-nerd.com> Content-Type: text/plain; charset=US-ASCII Hi all,
I'm trying to debug a AArch64/Linux specific RTS issue and digging around in the rts C code, I see a large amount of code wrapped in "#if DEBUG" type statements, but no way to enable in either mk/build.mk http://build.mk or it seems in any of the other build related settings files in the mk/ directory.
The only way I have found to enable this debug code that actually works is to enable this DEBUG code is to edit mk/ghc.mk http://ghc.mk as follows:
-STANDARD_OPTS += -DCOMPILING_RTS +STANDARD_OPTS += -DCOMPILING_RTS -DDEBUG
However, once I do that I get a bunch of C synatx errors.
I am doing this wrong or has the DEBUG code bit rotted?
Cheers, Erik
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org mailto:ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

On 05/15/2015 09:17 PM, Simon Peyton Jones wrote:
Good idea. I think it’d great if Jost (or someone else) felt able to update those wiki pages with the info in his email.
I have added https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/CompilerWays and linked to it from the debugging page and the commentary main page. Maybe someone can complete/correct the text about the options definitions inside mk/ways.mk, I was not 100% sure I explained this part correctly. / Jost

On Sat, May 16, 2015 at 4:30 AM, Jost Berthold < berthold@mathematik.uni-marburg.de> wrote:
I have added https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/CompilerWays
Excellent. This page also has some information on ways, maybe they could be merged: https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Config It is linked from here: https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts

Jost Berthold wrote:
To build a GHC with debug-way RTS, you need to add GhcRtsWays += debug to your build.mk (also see mk/config.mk{.in}, which gathers the default ways to build depending on platform and build configuration).
Since we're talking about updating the documentation, I would like to note that the identifuer "GhcRtsWays" is not present at all, anywhere in the GHC tree :-). I do however notice that the debug way is built by default. I was also able to build a ghc-stage2 with the debug RTS by adding "-debug" to GhcStage2HcOpts in mk/build.mk. Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
participants (5)
-
Erik de Castro Lopo
-
Jost Berthold
-
Lennart Kolmodin
-
Simon Peyton Jones
-
Thomas Miedema