Skip to content

LLVM backend doesn't support MacOS dead code stripping

Building recent HEAD (e.g. 669333d8) with llvm via quick-llvm fails.

The stage2 compiler is broken.

Building the compiler with quick-llvm

"inplace/bin/ghc-stage1" -o ghc/stage2/build/tmp/ghc-stage2 -hisuf dyn_hi -osuf  dyn_o -hcsuf dyn_hc -fPIC -dynamic  -O0 -H64m -fllvm -Wall      -hide-all-packages -i -ighc/. -ighc/stage2/build -Ighc/stage2/build -ighc/stage2/build/ghc/autogen -Ighc/stage2/build/ghc/autogen    -optP-DGHCI -optP-include -optPghc/stage2/build/ghc/autogen/cabal_macros.h -package-id base-4.10.0.0 -package-id array-0.5.1.2 -package-id bytestring-0.10.8.2 -package-id directory-1.3.0.2 -package-id process-1.4.3.0 -package-id filepath-1.4.1.1 -package-id ghc-boot-8.1 -package-id ghc-8.1 -package-id unix-2.7.2.1 -package-id containers-0.5.10.2 -package-id deepseq-1.4.3.0 -package-id ghci-8.1 -package-id haskeline-0.7.3.0 -package-id time-1.8 -package-id transformers-0.5.2.0 -Wall -fno-warn-name-shadowing -XHaskell2010  -O0 -no-hs-main -threaded -no-user-package-db -rtsopts      -Wnoncanonical-monad-instances  -odir ghc/stage2/build -hidir ghc/stage2/build -stubdir ghc/stage2/build    -optl-optl-Wl,-arch -optl-optl-Wl,x86_64 -fPIC -dynamic  -O0 -H64m -fllvm -Wall      -hide-all-packages -i -ighc/. -ighc/stage2/build -Ighc/stage2/build -ighc/stage2/build/ghc/autogen -Ighc/stage2/build/ghc/autogen    -optP-DGHCI -optP-include -optPghc/stage2/build/ghc/autogen/cabal_macros.h -package-id base-4.10.0.0 -package-id array-0.5.1.2 -package-id bytestring-0.10.8.2 -package-id directory-1.3.0.2 -package-id process-1.4.3.0 -package-id filepath-1.4.1.1 -package-id ghc-boot-8.1 -package-id ghc-8.1 -package-id unix-2.7.2.1 -package-id containers-0.5.10.2 -package-id deepseq-1.4.3.0 -package-id ghci-8.1 -package-id haskeline-0.7.3.0 -package-id time-1.8 -package-id transformers-0.5.2.0 -Wall -fno-warn-name-shadowing -XHaskell2010  -O0 -no-hs-main -threaded -no-user-package-db -rtsopts      -Wnoncanonical-monad-instances  -fno-use-rpaths -optl-Wl,-rpath -optl-Wl,'@loader_path/../haskeline-0.7.3.0' -optl-Wl,-rpath -optl-Wl,'@loader_path/../ghc-8.1' -optl-Wl,-rpath -optl-Wl,'@loader_path/../terminfo-0.4.0.2' -optl-Wl,-rpath -optl-Wl,'@loader_path/../hoopl-3.10.2.2' -optl-Wl,-rpath -optl-Wl,'@loader_path/../ghci-8.1' -optl-Wl,-rpath -optl-Wl,'@loader_path/../ghc-boot-8.1' -optl-Wl,-rpath -optl-Wl,'@loader_path/../transformers-0.5.2.0' -optl-Wl,-rpath -optl-Wl,'@loader_path/../hpc-0.6.0.3' -optl-Wl,-rpath -optl-Wl,'@loader_path/../template-haskell-2.12.0.0' -optl-Wl,-rpath -optl-Wl,'@loader_path/../pretty-1.1.3.3' -optl-Wl,-rpath -optl-Wl,'@loader_path/../ghc-boot-th-8.1' -optl-Wl,-rpath -optl-Wl,'@loader_path/../process-1.4.3.0' -optl-Wl,-rpath-optl-Wl,'@loader_path/../directory-1.3.0.2' -optl-Wl,-rpath -optl-Wl,'@loader_path/../unix-2.7.2.1' -optl-Wl,-rpath -optl-Wl,'@loader_path/../filepath-1.4.1.1' -optl-Wl,-rpath -optl-Wl,'@loader_path/../time-1.8' -optl-Wl,-rpath -optl-Wl,'@loader_path/../binary-0.8.4.1' -optl-Wl,-rpath -optl-Wl,'@loader_path/../containers-0.5.10.2' -optl-Wl,-rpath -optl-Wl,'@loader_path/../bytestring-0.10.8.2' -optl-Wl,-rpath -optl-Wl,'@loader_path/../deepseq-1.4.3.0' -optl-Wl,-rpath -optl-Wl,'@loader_path/../array-0.5.1.2' -optl-Wl,-rpath -optl-Wl,'@loader_path/../base-4.10.0.0' -optl-Wl,-rpath -optl-Wl,'@loader_path/../integer-gmp-1.0.0.1' -optl-Wl,-rpath -optl-Wl,'@loader_path/../ghc-prim-0.5.0.0' -optl-Wl,-rpath -optl-Wl,'@loader_path/../rts' ghc/stage2/build/Main.dyn_o ghc/stage2/build/GHCi/UI.dyn_o ghc/stage2/build/GHCi/UI/Info.dyn_o ghc/stage2/build/GHCi/UI/Monad.dyn_o ghc/stage2/build/GHCi/UI/Tags.dyn_o ghc/stage2/build/hschooks.dyn_o
Warning: -rtsopts and -with-rtsopts have no effect with -no-hs-main.
    Call hs_init_ghc() from your main() function to set these options.
/usr/bin/install -c -m 755 ghc/stage2/build/tmp/ghc-stage2 inplace/lib/bin/ghc-stage2
"rm" -f                                                     inplace/bin/ghc-stage2
echo '#!/bin/sh'                                                   >> inplace/bin/ghc-stage2
echo 'executablename="/ghc/inplace/lib/bin/ghc-stage2"'                                  >> inplace/bin/ghc-stage2
echo 'datadir="/ghc/inplace/lib"'                             >> inplace/bin/ghc-stage2
echo 'bindir="/ghc/inplace/bin"'                              >> inplace/bin/ghc-stage2
echo 'topdir="/ghc/inplace/lib"'                           >> inplace/bin/ghc-stage2
echo 'pgmgcc="gcc"'                                               >> inplace/bin/ghc-stage2
echo 'export DYLD_LIBRARY_PATH="/ghc/libraries/haskeline/dist-install/build:/ghc/compiler/stage2/build:/ghc/libraries/terminfo/dist-install/build:/ghc/libraries/hoopl/dist-install/build:/ghc/libraries/ghci/dist-install/build:/ghc/libraries/ghc-boot/dist-install/build:/ghc/libraries/transformers/dist-install/build:/ghc/libraries/hpc/dist-install/build:/ghc/libraries/template-haskell/dist-install/build:/ghc/libraries/pretty/dist-install/build:/ghc/libraries/ghc-boot-th/dist-install/build:/ghc/libraries/process/dist-install/build:/ghc/libraries/directory/dist-install/build:/ghc/libraries/unix/dist-install/build:/ghc/libraries/filepath/dist-install/build:/ghc/libraries/time/dist-install/build:/ghc/libraries/binary/dist-install/build:/ghc/libraries/containers/dist-install/build:/ghc/libraries/bytestring/dist-install/build:/ghc/libraries/deepseq/dist-install/build:/ghc/libraries/array/dist-install/build:/ghc/libraries/base/dist-install/build:/ghc/libraries/integer-gmp/dist-install/build:/ghc/libraries/ghc-prim/dist-install/build:/ghc/rts/dist/build${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}"' >> inplace/bin/ghc-stage2
cat ghc/ghc.wrapper                                     >> inplace/bin/ghc-stage2
chmod +x                                                     inplace/bin/ghc-stage2
"inplace/bin/ghc-stage2" -hisuf dyn_hi -osuf  dyn_o -hcsuf dyn_hc -fPIC -dynamic  -O0 -H64m -fllvm -Wall      -hide-all-packages -i -iutils/ghctags/. -iutils/ghctags/dist-install/build -Iutils/ghctags/dist-install/build -iutils/ghctags/dist-install/build/ghctags/autogen -Iutils/ghctags/dist-install/build/ghctags/autogen     -optP-include -optPutils/ghctags/dist-install/build/ghctags/autogen/cabal_macros.h -package-id base-4.10.0.0 -package-id containers-0.5.10.2 -package-id Cabal-2.0.0.0 -package-id ghc-8.1 -XHaskell2010  -no-user-package-db -rtsopts      -Wnoncanonical-monad-instances  -odir utils/ghctags/dist-install/build -hidir utils/ghctags/dist-install/build -stubdir utils/ghctags/dist-install/build    -c utils/ghctags/./Main.hs -o utils/ghctags/dist-install/build/Main.dyn_o
"inplace/bin/ghc-stage2" -hisuf dyn_hi -osuf  dyn_o -hcsuf dyn_hc -fPIC -dynamic  -O0 -H64m -fllvm -Wall      -hide-all-packages -i -iutils/check-api-annotations/. -iutils/check-api-annotations/dist-install/build -Iutils/check-api-annotations/dist-install/build -iutils/check-api-annotations/dist-install/build/check-api-annotations/autogen -Iutils/check-api-annotations/dist-install/build/check-api-annotations/autogen     -optP-include -optPutils/check-api-annotations/dist-install/build/check-api-annotations/autogen/cabal_macros.h -package-id base-4.10.0.0 -package-id containers-0.5.10.2 -package-id Cabal-2.0.0.0 -package-id directory-1.3.0.2 -package-id ghc-8.1 -Wall -XHaskell2010  -no-user-package-db -rtsopts      -Wnoncanonical-monad-instances  -odir utils/check-api-annotations/dist-install/build -hidir utils/check-api-annotations/dist-install/build -stubdir utils/check-api-annotations/dist-install/build    -c utils/check-api-annotations/./Main.hs -o utils/check-api-annotations/dist-install/build/Main.dyn_o
"inplace/bin/ghc-stage2" -hisuf dyn_hi -osuf  dyn_o -hcsuf dyn_hc -fPIC -dynamic  -O0 -H64m -fllvm -Wall      -hide-all-packages -i -iutils/check-ppr/. -iutils/check-ppr/dist-install/build -Iutils/check-ppr/dist-install/build -iutils/check-ppr/dist-install/build/check-ppr/autogen -Iutils/check-ppr/dist-install/build/check-ppr/autogen     -optP-include -optPutils/check-ppr/dist-install/build/check-ppr/autogen/cabal_macros.h -package-id base-4.10.0.0 -package-id bytestring-0.10.8.2 -package-id containers-0.5.10.2 -package-id Cabal-2.0.0.0 -package-id directory-1.3.0.2 -package-id filepath-1.4.1.1 -package-id ghc-8.1 -Wall -XHaskell2010  -no-user-package-db -rtsopts      -Wnoncanonical-monad-instances  -odir utils/check-ppr/dist-install/build -hidir utils/check-ppr/dist-install/build -stubdir utils/check-ppr/dist-install/build    -c utils/check-ppr/./Main.hs -o utils/check-ppr/dist-install/build/Main.dyn_o
ghc-stage2: internal error: ghc-stage2: internal error: ghc-stage2: internal error: evacuate(static): strange closure type 0evacuate(static): strange closure type 0evacuate(static): strange closure type 0
    (GHC version 8.1.20170304 for x86_64_apple_darwin)


    (GHC version 8.1.20170304 for x86_64_apple_darwin)
    (GHC version 8.1.20170304 for x86_64_apple_darwin)
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
make[1]: *** [utils/check-ppr/dist-install/build/Main.dyn_o] Abort trap: 6
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [utils/check-api-annotations/dist-install/build/Main.dyn_o] Abort trap: 6
make[1]: *** [utils/ghctags/dist-install/build/Main.dyn_o] Abort trap: 6
make: *** [all] Error 2

Building and linking against the debug rts, gives the following result in lldb.

(lldb) settings set -- target.run-args  "+RTS" "-DS" "-Dl" "-Ds" "-RTS"
(lldb) run
Process 3546 launched: '/ghc/inplace/lib/bin/ghc-stage2' (x86_64)
7fffae4753c0: created capset 0 of type 2
7fffae4753c0: created capset 1 of type 3
7fffae4753c0: cap 0: initialised
7fffae4753c0: assigned cap 0 to capset 0
7fffae4753c0: assigned cap 0 to capset 1
7fffae4753c0: allocated 1 more capabilities
7fffae4753c0: new task (taskCount: 1)
7fffae4753c0: returning; I want capability 0
7fffae4753c0: resuming capability 0
7fffae4753c0: cap 0: created thread 1
7fffae4753c0: new bound thread (1)
7fffae4753c0: cap 0: schedule()
ghc-stage2: internal error: ASSERTION FAILED: file rts/sm/Sanity.c, line 88

    (GHC version 8.1.20170304 for x86_64_apple_darwin)
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
Process 3546 stopped
* thread #1: tid = 0x6df55a1, 0x00007fffa5756dd6 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00007fffa5756dd6 libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill:
->  0x7fffa5756dd6 <+10>: jae    0x7fffa5756de0            ; <+20>
    0x7fffa5756dd8 <+12>: movq   %rax, %rdi
    0x7fffa5756ddb <+15>: jmp    0x7fffa574fcdf            ; cerror_nocancel
    0x7fffa5756de0 <+20>: retq
(lldb) bt all
warning: could not load any Objective-C class information. This will significantly reduce the quality of type information available.
* thread #1: tid = 0x6df55a1, 0x00007fffa5756dd6 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fffa5756dd6 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fffa5842787 libsystem_pthread.dylib`pthread_kill + 90
    frame #2: 0x00007fffa56bc420 libsystem_c.dylib`abort + 129
    frame #3: 0x0000000102d09e61 ghc-stage2`rtsFatalInternalErrorFn(s="ASSERTION FAILED: file %s, line %u\n", ap=0x00007fff5fbfefe0) + 273 at RtsMessages.c:182
    frame #4: 0x0000000102d0a16a ghc-stage2`barf(s="ASSERTION FAILED: file %s, line %u\n") + 346 at RtsMessages.c:46
    frame #5: 0x0000000102d0a1a7 ghc-stage2`_assertFail(filename="rts/sm/Sanity.c", linenum=88) + 39 at RtsMessages.c:61
    frame #6: 0x0000000102d3358e ghc-stage2`checkClosureShallow(p=0x0000000103412930) + 62 at Sanity.c:88
    frame #7: 0x0000000102d31422 ghc-stage2`checkSmallBitmap(payload=0x0000000105c05368, bitmap=0, size=1) + 66 at Sanity.c:53
    frame #8: 0x0000000102d31181 ghc-stage2`checkStackFrame(c=0x0000000105c05360) + 161 at Sanity.c:114
    frame #9: 0x0000000102d3157b ghc-stage2`checkStackChunk(sp=0x0000000105c05360, stack_end=0x0000000105c05388) + 43 at Sanity.c:171
    frame #10: 0x0000000102d321d4 ghc-stage2`checkSTACK(stack=0x0000000105c05000) + 116 at Sanity.c:515
    frame #11: 0x0000000102d32154 ghc-stage2`checkTSO(tso=0x0000000105c05388) + 372 at Sanity.c:553
    frame #12: 0x0000000102d10edd ghc-stage2`schedule(initialCapability=0x000000010353b640, task=0x0000000105900c30) + 461 at Schedule.c:323
    frame #13: 0x0000000102d10b7b ghc-stage2`scheduleWaitThread(tso=0x0000000105c05388, ret=0x0000000000000000, pcap=0x00007fff5fbff328) + 203 at Schedule.c:2552
    frame #14: 0x0000000102d06655 ghc-stage2`rts_evalIO(cap=0x00007fff5fbff328, p=0x0000000103412930, ret=0x0000000000000000) + 69 at RtsAPI.c:460
    frame #15: 0x0000000102d46860 ghc-stage2`ioManagerStartCap(cap=0x00007fff5fbff328) + 32 at Signals.c:211
    frame #16: 0x0000000102d4689e ghc-stage2`ioManagerStart + 46 at Signals.c:221
    frame #17: 0x0000000102d0a9cb ghc-stage2`hs_init_ghc(argc=0x00007fff5fbff558, argv=0x00007fff5fbff550, rts_config=RtsConfig @ 0x00007fff5fbff4c0) + 843 at RtsStartup.c:290
    frame #18: 0x0000000102d09c8a ghc-stage2`hs_main(argc=1, argv=0x00007fff5fbff690, main_closure=0x00000001030fd720, rts_config=RtsConfig @ 0x00007fff5fbff570) + 58 at RtsMain.c:51
    frame #19: 0x00000001000c2b9c ghc-stage2`main + 188
    frame #20: 0x00007fffa5628255 libdyld.dylib`start + 1

  thread #2: tid = 0x6df560a, 0x00007fffa5756fda libsystem_kernel.dylib`__semwait_signal + 10
    frame #0: 0x00007fffa5756fda libsystem_kernel.dylib`__semwait_signal + 10
    frame #1: 0x00007fffa56ddb72 libsystem_c.dylib`nanosleep + 199
    frame #2: 0x00007fffa56dda66 libsystem_c.dylib`usleep + 54
    frame #3: 0x0000000102d45a02 ghc-stage2`itimer_thread_func(_handle_tick=0x0000000102d1dc00) + 82 at Pthread.c:132
    frame #4: 0x00007fffa583faab libsystem_pthread.dylib`_pthread_body + 180
    frame #5: 0x00007fffa583f9f7 libsystem_pthread.dylib`_pthread_start + 286
    frame #6: 0x00007fffa583f1fd libsystem_pthread.dylib`thread_start + 13
(lldb) dis -s 0x0000000103412930
ghc-stage2`base_GHCziConcziIO_ensureIOManagerIsRunning_closure:
    0x103412930 <+0>:  andb   %cl, %al
    0x103412932 <+2>:  wait
    0x103412933 <+3>:  addb   (%rcx), %al
    0x103412935 <+5>:  addb   %al, (%rax)
    0x103412937 <+7>:  addb   %al, (%rax)
    0x103412939 <+9>:  addb   %al, (%rax)
    0x10341293b <+11>: addb   %al, (%rax)
    0x10341293d <+13>: addb   %al, (%rax)
    0x10341293f <+15>: addb   %dl, -0x38(%rax)

ghc-stage2`base_GHCziConcziIO_ioManagerCapabilitiesChanged_closure:
    0x103412942 <+2>:  wait
    0x103412943 <+3>:  addb   (%rcx), %al
    0x103412945 <+5>:  addb   %al, (%rax)
    0x103412947 <+7>:  addb   %al, (%rax)
    0x103412949 <+9>:  addb   %al, (%rax)
    0x10341294b <+11>: addb   %al, (%rax)
    0x10341294d <+13>: addb   %al, (%rax)
Trac metadata
Trac field Value
Version
Type Bug
TypeOfFailure OtherFailure
Priority highest
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC bgamari, rwbarton
Operating system
Architecture
Edited by rwbarton
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information