[GHC] #16063: ghc-8.6.3 + Mac OSX + FFI dependency causes 'impossible happened' compiler failure

#16063: ghc-8.6.3 + Mac OSX + FFI dependency causes 'impossible happened' compiler failure -------------------------------------+------------------------------------- Reporter: benselfridge | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Keywords: | Operating System: MacOS X Architecture: x86_64 | Type of failure: Compile-time (amd64) | crash or panic Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I am trying to build this library: https://github.com/GaloisInc/grift The build works perfectly on my Mac OS X system under ghc-8.4.4 via the README instructions. However, if I update to ghc-8.6.3, I get the following error: {{{ Building library for bv-sized-float-0.1.0.. [1 of 2] Compiling Data.BitVector.Sized.Float ( src/Data/BitVector/Sized/Float.hs, /Users/benselfridge/grift/dist- newstyle/build/x86_64-osx/ghc-8.6.3/bv-sized- float-0.1.0/build/Data/BitVector/Sized/Float.o ) [2 of 2] Compiling Data.BitVector.Sized.Float.App ( src/Data/BitVector/Sized/Float/App.hs, /Users/benselfridge/grift/dist- newstyle/build/x86_64-osx/ghc-8.6.3/bv-sized- float-0.1.0/build/Data/BitVector/Sized/Float/App.o ) ghc: loadArchive: Failed reading header from `/Users/benselfridge/grift /dist-newstyle/build/x86_64-osx/ghc-8.6.3/softfloat- hs-0.1.0/build/SoftFloat' ghc: panic! (the 'impossible' happened) (GHC version 8.6.3 for x86_64-apple-darwin): loadArchive "/Users/benselfridge/grift/dist- newstyle/build/x86_64-osx/ghc-8.6.3/softfloat-hs-0.1.0/build/SoftFloat": failed Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} The library "softfloat-hs" is a Haskell library that calls C functions that are dynamically linked. If I try to run it within this project via "cabal new-repl softfloat-hs", the dependency works fine. It's only when I try to build "bv-sized-float", which depends on softfloat-hs, that I get the above error. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16063 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16063: ghc-8.6.3 + Mac OSX + FFI dependency causes 'impossible happened' compiler failure -------------------------------------+------------------------------------- Reporter: benselfridge | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Hmmm, that archive name doesn't look quite right. I tried to reproduce this but ran into two issues: * I do not have root access to a macOS box; can you modify the `install` rule of `softfloat-hs` to accomodate non-root users? * the commit 1d4010468c307c7262fc66c3d1caeb3b3d468640 of `test/riscv- tests` is not reachable via any branch: {{{ $ git submodule update error: Server does not allow request for unadvertised object 1d4010468c307c7262fc66c3d1caeb3b3d468640 Fetched in submodule path 'test/riscv-tests', but it did not contain 1d4010468c307c7262fc66c3d1caeb3b3d468640. Direct fetching of that commit failed. }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16063#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16063: ghc-8.6.3 + Mac OSX + FFI dependency causes 'impossible happened' compiler failure -------------------------------------+------------------------------------- Reporter: benselfridge | Owner: (none) Type: bug | Status: infoneeded Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => infoneeded -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16063#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16063: ghc-8.6.3 + Mac OSX + FFI dependency causes 'impossible happened' compiler failure -------------------------------------+------------------------------------- Reporter: benselfridge | Owner: (none) Type: bug | Status: infoneeded Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by benselfridge): Removed the riscv-tests submodule, so that shouldn't be an issue anymore if you clone grift again. I removed the sudo calls in the Makefile (they probably shouldn't have been there anyway), but I'm not sure if that will do the trick for you -- softfloat-hs needs to dynamically link against pre-compiled C libraries in /usr/lib or /usr/local/lib, and they have to be installed there or runtime will crash. Is there no way for you to run make install inside softfloat- hs? -Ben -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16063#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16063: ghc-8.6.3 + Mac OSX + FFI dependency causes 'impossible happened' compiler failure -------------------------------------+------------------------------------- Reporter: benselfridge | Owner: (none) Type: bug | Status: infoneeded Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by harpocrates): * cc: harpocrates (added) Comment: I can replicate and have a story for what is going wrong here, which involves 3d17f1f10fc00540ac052f2fd03182906aa47e35. I'll prepare a patch shortly, but testing it might be a bit frustrating (I doubt `grift`'s dependencies all easily build on HEAD). I'll try to put together a more minimal test case too. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16063#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16063: ghc-8.6.3 + Mac OSX + FFI dependency causes 'impossible happened' compiler failure -------------------------------------+------------------------------------- Reporter: benselfridge | Owner: (none) Type: bug | Status: infoneeded Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by benselfridge): Cool, thank you! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16063#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16063: ghc-8.6.3 + Mac OSX + FFI dependency causes 'impossible happened' compiler failure -------------------------------------+------------------------------------- Reporter: benselfridge | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5462 Wiki Page: | -------------------------------------+------------------------------------- Changes (by harpocrates): * status: infoneeded => patch * differential: => Phab:D5462 Comment: Here's what I think is happening: starting in 3d17f1f10fc00540ac052f2fd03182906aa47e35, when told to find an archive for `softfloat`, GHC no longer looks for just `libsoftfloat.a` and `softfloat.a`, it also looks for `libsoftfloat` and `softfloat`. GHC's method for "looking" for an archive is to make a bunch of calls to GCC. Something like {{{ gcc -fno-stack-protector -DTABLES_NEXT_TO_CODE -B/Users/atheriault/Code/grift/dist-newstyle/build/x86_64-osx/ghc-8.6.3 /softfloat-hs-0.1.0/build --print-file-name libsoftfloat.a ... gcc -fno-stack-protector -DTABLES_NEXT_TO_CODE -B/Users/atheriault/Code/grift/dist-newstyle/build/x86_64-osx/ghc-8.6.3 /softfloat-hs-0.1.0/build --print-file-name softfloat }}} We "find" a library when the path that GCC prints out is a full path (instead of just the path we pass in). And there's the problem: GCC will print out a full path to a //folder// if an appropriately named folder is found in the base location. In this case, GHC ends up finding the `Users/atheriault/Code/grift/dist-newstyle/build/x86_64-osx/ghc-8.6.3 /softfloat-hs-0.1.0/build/SoftFloat` folder and thinking that this is the `softfloat` library it has been asked to find. One workaround is to name the `softfloat` library to `softfloat1`. Or rename the `SoftFloat` directory. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16063#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16063: ghc-8.6.3 + Mac OSX + FFI dependency causes 'impossible happened' compiler failure -------------------------------------+------------------------------------- Reporter: benselfridge | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Compile-time | (amd64) crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5462 Wiki Page: | -------------------------------------+------------------------------------- Comment (by benselfridge): Okay -- I'll do something like that for now. Thanks, Alec. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16063#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16063: ghc-8.6.3 + Mac OSX + FFI dependency causes 'impossible happened' compiler
failure
-------------------------------------+-------------------------------------
Reporter: benselfridge | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 8.6.3
Resolution: | Keywords:
Operating System: MacOS X | Architecture: x86_64
Type of failure: Compile-time | (amd64)
crash or panic | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D5462
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Alec Theriault
participants (1)
-
GHC