[GHC] #11981: unknown symbol `__udivti3' when BuildFlavour = perf-llvm

#11981: unknown symbol `__udivti3' when BuildFlavour = perf-llvm -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Other Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Building git HEAD with `BuildFlavour = perf-llvm` and then running the tests results in 500+ tests failing, all with the same error: {{{ ghc-stage2: /xxx/libraries/ghc-prim/dist-install/build/HSghc- prim-0.5.0.0.o: unknown symbol `__udivti3' ghc-stage2: unable to load package `ghc-prim-0.5.0.0' }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11981 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11981: unknown symbol `__udivti3' when BuildFlavour = perf-llvm -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by carter): @erik what does the ldd / Otool output say ithr ghc-prim dylib/so depends on? That sounds like one of the Symbols eg gcc puts into its libgcc library. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11981#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11981: unknown symbol `__udivti3' when BuildFlavour = perf-llvm -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): Further examination shows that this only happens when `DYNAMIC_GHC_PROGRAMS = NO` in `mk/build/mk`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11981#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11981: unknown symbol `__udivti3' when BuildFlavour = perf-llvm -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): The update is that this now happens with `DYNAMIC_GHC_PROGRAMS = YES`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11981#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11981: unknown symbol `__udivti3' when BuildFlavour = perf-llvm -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): Searching for this on the web and all I can find is links to implementation like https://searchcode.com/codesearch/view/29840070/ is is amazing un-informative. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11981#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11981: unknown symbol `__udivti3' when BuildFlavour = perf-llvm -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): The function `__udivti3` seems to be a 128 bit `div` operation that is implemented in LLVM's "compiler-rt" library and in gcc "libgcc". Going to try and see if I can link libgcc. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11981#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11981: unknown symbol `__udivti3' when BuildFlavour = perf-llvm -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): On my Debian system, the symbol `__udivti3` seems to be provided by `/lib/x86_64-linux-gnu/libgcc_s.so.1` Easiest way to trigger the problem is to build with `BuildFlavour = perf- llvm` and then run: {{{ $ inplace/bin/ghc-stage2 --interactive GHCi, version 8.1.20160802: http://www.haskell.org/ghc/ :? for help ghc-stage2: /home/erikd/Git/ghc-upstream/libraries/ghc-prim/dist- install/build/HSghc-prim-0.5.0.0.o: unknown symbol `__udivti3' ghc-stage2: unable to load package `ghc-prim-0.5.0.0' }}} Not sure how to add this to the build system, but I was able to hack something together to test using the following steps. * Full build with `BuildFlavour = perf-llvm`. * Edit `ghc/stage2/package-data.mk` and add `gcc_s` to the `ghc_stage2_DEP_EXTRA_LIBS` line. * Edit `mk/build.mk` and uncomment `stage=2` so we only build the stage 2 compiler. * `touch compiler/main/GHC.hs` to force a rebuild. * Run `make`. Now when I run `inplace/bin/ghc-stage2 --interactive` it works correctly. @thomie Any idea on how this could be fixed in the build system? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11981#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11981: unknown symbol `__udivti3' when BuildFlavour = perf-llvm -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): ON IRC, @slyfox said: {{{ <slyfox> i guess you need another entry for exported symbols from rts <slyfox> ./RtsSymbols.c: SymI_NeedsProto(__divdi3) \ <slyfox> like this one }}} I will try that. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11981#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11981: unknown symbol `__udivti3' when BuildFlavour = perf-llvm -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Phyx-): @erikd you could probably just add it to `extra-libraries` in `libraries \ghc-prim\ghc-prim.cabal`. This would pass it on when linking against `ghc-prim` both interpreted and compiled. However this won't work on Windows because on Windows `gcc_s` is an import library with a non-standard name (.a instead of .dll.a), and we can't identify these properly yet. So I think your fix of adding them to `RtsSymbols.c` is good enough for now. I created #12486 for a way to not need to re-export these symbols from the RTS. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11981#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11981: unknown symbol `__udivti3' when BuildFlavour = perf-llvm
-------------------------------------+-------------------------------------
Reporter: erikd | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 8.0.2
Component: Compiler | Version: 8.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Other | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Erik de Castro Lopo

#11981: unknown symbol `__udivti3' when BuildFlavour = perf-llvm -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): Before commit [changeset:"bd0c31063551744d00796219174739216c398da5/ghc" bd0c3106/ghc] there were over 400 failing tests, and after its less than 50, but the reamaining 50 all seem `ghc-iserv` related. Two examples: {{{ ghc-stage2: ghc-iserv terminated (-11) *** unexpected failure for TH_reifyLocalDefs(ext-interp) }}} {{{ T2700.hs:1:1: error: Exception when trying to run compile-time code: ghc-stage2: ghc-iserv terminated (-11) Code: do { d <- sigD (mkName "foo") [t| (Int -> Bool) -> Bool |]; runIO (hPutStrLn stderr (pprint d)); return [] } }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11981#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11981: unknown symbol `__udivti3' when BuildFlavour = perf-llvm -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): Running `inplace/bin/ghc-stage2 --interactive -fexternal-interpreter` seems to work as it should. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11981#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11981: unknown symbol `__udivti3' when BuildFlavour = perf-llvm -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): If I move `inplace/lib/bin/ghc-iserv` to `inplace/lib/bin/ghc-iserv.exe` and then created shell script at `inplace/lib/bin/ghc-iserv` containing: {{{ #!/bin/bash gdb --args inplace/lib/bin/ghc-iserv.exe $@ }}} Then I can run `ghc-iserv` under gdb and get a backtrace: {{{ Thread 1 "ghc-iserv.exe" received signal SIGSEGV, Segmentation fault. 0x0000000040aba3ff in ?? () (gdb) bt #0 0x0000000040aba3ff in ?? () #1 0x0000000040dbcf52 in ?? () #2 0x0000000040112d81 in ?? () #3 0x0000000001345e18 in MainCapability () #4 0x0000000200098eb8 in ?? () #5 0x00000002000910c0 in ?? () #6 0x0000000000000000 in ?? () (gdb) quit }}} which tells me very little. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11981#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11981: unknown symbol `__udivti3' when BuildFlavour = perf-llvm -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: merge Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => merge Comment: comment:9 could be merged for 8.0.2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11981#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11981: unknown symbol `__udivti3' when BuildFlavour = perf-llvm -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged in 676efb9f00d14c7f4bad7160d270c1292dd9b436. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11981#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC