
#15570: Core transformations generate bad indexCharOffAddr# call -------------------------------------+------------------------------------- Reporter: alpmestan | Owner: alpmestan Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.5 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): OK, with some help from Andrey I added to `hadrian/src/UserSettings.hs` {{{ verboseCommand :: Predicate verboseCommand = input "//*.hs" }}} Now if I touch `GHC/Real.hs` I get its command line, which is super- helpful; so I can compile with changing flags. Turns out that the reason for the strange `GHC.Real.even3` is that we have {{{ GHC.Real.even4 :: Int GHC.Real.even4 = GHC.Types.I# 1# -- RHS size: {terms: 3, types: 1, coercions: 0, joins: 0/0} GHC.Real.even3 :: Int GHC.Real.even3 = negate @ Int GHC.Num.$fNumInt GHC.Real.even4 }}} Wny aren't we negating that constant? '''Turns out that it's because we aren't optimising `GHC.Num`'''!!! It's not surprising that we get terrible code. Here are the command lines printed by Hadrian for `GHC.Num` and `GHC.Real` {{{ -- GHC.Real. Notice that it finishes with -O _build/stage0/bin/ghc -Wall -hisuf dyn_hi -osuf dyn_o -hcsuf dyn_hc -fPIC -dynamic -hide-all-packages -no-user-package-db '-package-db _build/stage1/lib/package.conf.d' '-this-unit-id base-4.12.0.0' '-package- id ghc-prim-0.5.3' '-package-id integer-gmp-1.0.2.0' '-package-id rts-1.0' -i -i_build/stage1/libraries/base/build -i_build/stage1/libraries/base/build/autogen -ilibraries/base/. -Iincludes -I_build/generated -I_build/stage1/libraries/base/build -I_build/stage1/libraries/base/build/include -Ilibraries/base/include -I/home/simonpj/code/HEAD-3/_build/stage1/lib/x86_64-linux- ghc-8.7.20180825/integer-gmp-1.0.2.0/include -I/home/simonpj/code/HEAD-3/_build/stage1/lib/x86_64-linux- ghc-8.7.20180825/rts-1.0/include -I_build/generated -optc- I_build/generated -optP-include -optP_build/stage1/libraries/base/build/autogen/cabal_macros.h -optc-fno- stack-protector -optP-DOPTIMISE_INTEGER_GCD_LCM -odir _build/stage1/libraries/base/build -hidir _build/stage1/libraries/base/build -stubdir _build/stage1/libraries/base/build -Wnoncanonical-monad-instances -optc- Werror=unused-but-set-variable -optc-Wno-error=inline -c libraries/base/GHC/Real.hs -o _build/stage1/libraries/base/build/GHC/Real.dyn_o -O0 -H64m -this-unit-id base -Wcompat -Wnoncanonical-monad-instances -XHaskell2010 -ghcversion- file=/home/simonpj/code/HEAD-3/_build/generated/ghcversion.h -O -Wno- deprecated-flags -Wno-trustworthy-safe -- GHC.Num. The -O is there but it's overridden with -O0 _build/stage0/bin/ghc -Wall -hisuf dyn_hi -osuf dyn_o -hcsuf dyn_hc -fPIC -dynamic -hide-all-packages -no-user-package-db '-package-db _build/stage1/lib/package.conf.d' '-this-unit-id base-4.12.0.0' '-package- id ghc-prim-0.5.3' '-package-id integer-gmp-1.0.2.0' '-package-id rts-1.0' -i -i_build/stage1/libraries/base/build -i_build/stage1/libraries/base/build/autogen -ilibraries/base/. -Iincludes -I_build/generated -I_build/stage1/libraries/base/build -I_build/stage1/libraries/base/build/include -Ilibraries/base/include -I/home/simonpj/code/HEAD-3/_build/stage1/lib/x86_64-linux- ghc-8.7.20180825/integer-gmp-1.0.2.0/include -I/home/simonpj/code/HEAD-3/_build/stage1/lib/x86_64-linux- ghc-8.7.20180825/rts-1.0/include -I_build/generated -optc- I_build/generated -optP-include -optP_build/stage1/libraries/base/build/autogen/cabal_macros.h -optc-fno- stack-protector -optP-DOPTIMISE_INTEGER_GCD_LCM -odir _build/stage1/libraries/base/build -hidir _build/stage1/libraries/base/build -stubdir _build/stage1/libraries/base/build -Wnoncanonical-monad-instances -optc- Werror=unused-but-set-variable -optc-Wno-error=inline -c libraries/base/GHC/Num.hs -o _build/stage1/libraries/base/build/GHC/Num.dyn_o -O0 -H64m -this-unit-id base -Wcompat -Wnoncanonical-monad-instances -XHaskell2010 -ghcversion- file=/home/simonpj/code/HEAD-3/_build/generated/ghcversion.h -O -O0 -fno- ignore-interface-pragmas -Wno-deprecated-flags -Wno-trustworthy-safe }}} Blimey. With `make` we'd be stuck: who is adding that `-O0`? But with Hadrian and it's provenance tracking, it should be easy. But I have no idea where to start: Andrey, Alp, over to you. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15570#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler