Ticket #5407 (closed bug: fixed)

Opened 22 months ago

Last modified 6 months ago

ghc-7.2.1 build failed on sparc solaris with non-GNU linker

Reported by: maeder Owned by: igloo
Priority: high Milestone: 7.6.2
Component: Compiler Version: 7.6.1
Keywords: Cc:
Operating System: Solaris Architecture: sparc
Type of failure: Building GHC failed Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

"inplace/bin/ghc-stage1"   -H32m -O    -package-name ghc-prim-0.2.0.0 -hide-all-packages -i -ilibraries/ghc-prim/. -ilibraries/ghc-prim/dist-install/build -ilibraries/ghc-prim/dist-install/build/autogen -Ilibraries/ghc-prim/dist-install/build -Ilibraries/ghc-prim/dist-install/build/autogen -Ilibraries/ghc-prim/.    -optP-include -optPlibraries/ghc-prim/dist-install/build/autogen/cabal_macros.h -package rts-1.0 -split-objs -package-name ghc-prim -XHaskell98 -XCPP -XMagicHash -XForeignFunctionInterface -XUnliftedFFITypes -XUnboxedTuples -XEmptyDataDecls -XNoImplicitPrelude -O2 -no-user-package-conf -rtsopts     -odir libraries/ghc-prim/dist-install/build -hidir libraries/ghc-prim/dist-install/build -stubdir libraries/ghc-prim/dist-install/build -hisuf hi -osuf  o -hcsuf hc -c libraries/ghc-prim/./GHC/CString.hs -o libraries/ghc-prim/dist-install/build/GHC/CString.o

libraries/ghc-prim/GHC/CString.hs:19:16:
    Warning: -XNoGenerics is deprecated: it does nothing; look into -XDefaultSignatures and -XDeriveGeneric for generic programming support.
/usr/ccs/bin/ld: illegal option -- n
ld: warning: option -o appears more than once, first setting taken
usage: ld [-6:abc:d:e:f:h:il:mo:p:rstu:z:B:CD:F:GI:L:M:N:P:Q:R:S:VY:?] file(s)
        [-64]           enforce a 64-bit link-edit
...
collect2: ld returned 1 exit status

Change History

Changed 19 months ago by maeder

This failure (also present in ghc-7.2.1.20111103) is caused by the -no-relax flag set in compiler/main/DriverPipeline.hs (line 2000)

                            -- gcc on sparc sets -Wl,--relax implicitly, but
                            -- -r and --relax are incompatible for ld, so
                            -- disable --relax explicitly.
                         ++ (if platformArch (targetPlatform dflags) == ArchSPARC
                                then [SysTools.Option "-Wl,-no-relax"]
                                else [])

I don't know if it would work if gcc used a gnu-linker. Currently I'm trying without this flag and get:

"inplace/bin/ghc-stage1"   -H32m -O    -package-name base-4.4.1.0 -hide-all-packages -i -ilibraries/base/. -ilibraries/base/dist-install/build -ilibraries/base/dist-install/build/autogen -Ilibraries/base/dist-install/build -Ilibraries/base/dist-install/build/autogen -Ilibraries/base/include   -optP-DOPTIMISE_INTEGER_GCD_LCM -optP-include -optPlibraries/base/dist-install/build/autogen/cabal_macros.h -package ghc-prim-0.2.0.0 -package integer-gmp-0.3.0.0 -package rts-1.0 -split-objs -package-name base -XHaskell98 -XCPP -O2 -no-user-package-conf -rtsopts     -odir libraries/base/dist-install/build -hidir libraries/base/dist-install/build -stubdir libraries/base/dist-install/build -hisuf hi -osuf  o -hcsuf hc -c libraries/base/./GHC/Exception.lhs -o libraries/base/dist-install/build/GHC/Exception.o
ghc-stage1: panic! (the 'impossible' happened)
  (GHC version 7.2.1.20111103 for sparc-sun-solaris2):
        iselExpr64(sparc) 13419740508176834782 :: W64

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

gmake[1]: *** [libraries/base/dist-install/build/GHC/Exception.o] Fehler 1
gmake: *** [all] Fehler 2

which looks like a 32 vs. 64 bit mismatch wrt GMP.

Changed 19 months ago by maeder

I've no idea how to tackle this panic. SPARC.CodeGen?.Gen32 depends on SPARC.CodeGen?.Gen64 which eventually panics (last code line).

Changed 19 months ago by maeder

This number appears in output using -v4:

  instance
    Data.Typeable.Internal.Typeable GHC.Exception.SomeException where
    { Data.Typeable.Internal.typeOf _
        = Data.Typeable.Internal.mkTyConApp
            (Data.Typeable.Internal.mkTyCon
               8610171299581312226L##
               13419740508176834782L##
               "base"
               "GHC.Exception"
               "SomeException")
            [] }

and is one digit longer than other numbers (but works under x86 solaris)

Changed 19 months ago by maeder

This number is greater maxBound :: Data.Data.Int64 but smaller than maxBound :: Data.Word.Word64

Changed 19 months ago by maeder

By changing code I was able to get failing smaller values. Therefore I assume that there is just code missing in SPARC.CodeGen.Gen64.iselExpr64 for CmmLit.

Changed 19 months ago by igloo

  • milestone set to _|_

Changed 12 months ago by maeder

  • version changed from 7.0.4 to 7.4.2-rc1

I was able to build ghc-7.4.2 (I did not try ghc-7.4.1) now by omitting the -no-relax flag set in compiler/main/DriverPipeline.hs (line 2089)

Maybe someone can add && cLdIsGNULd == "YES" to the test "platformArch (targetPlatform dflags) == ArchSPARC" and close this ticket. cLdIsGNULd == "YES" is tested later so maybe a local (let) variable should be used.

Changed 11 months ago by igloo

  • priority changed from normal to high
  • difficulty set to Unknown
  • milestone changed from _|_ to 7.6.1

Changed 9 months ago by maeder

  • version changed from 7.4.2-rc1 to 7.6.1

This (trivial) problem is still not fixed in ghc-7.6.1

--- compiler/main/DriverPipeline.hs~    Di Sep  4 19:10:14 2012
+++ compiler/main/DriverPipeline.hs     Mo Sep 10 11:00:43 2012
@@ -2106,6 +2106,7 @@
                             -- -r and --relax are incompatible for ld, so
                             -- disable --relax explicitly.
                          ++ (if platformArch (targetPlatform dflags) == ArchSPARC
+                                && isGNULd
                                 then [SysTools.Option "-Wl,-no-relax"]
                                 else [])
                          ++ [
@@ -2126,10 +2127,11 @@
       -- suppress the generation of the .note.gnu.build-id section,
       -- which we don't need and sometimes causes ld to emit a
       -- warning:
+      isGNULd = cLdIsGNULd == "YES"
       ld_build_id | cLdHasBuildId == "YES"  = "-Wl,--build-id=none"
                   | otherwise               = ""
 
-  if cLdIsGNULd == "YES"
+  if isGNULd
      then do
           script <- newTempName dflags "ldscript"
           writeFile script $ "INPUT(" ++ unwords o_files ++ ")"

Changed 9 months ago by igloo

  • status changed from new to patch
  • milestone changed from 7.6.1 to 7.6.2

thanks for the patch

Changed 6 months ago by igloo

  • owner set to igloo

Changed 6 months ago by ian@…

commit 9ef4d48e296d4b96492a839f9ee569f8f90c617b

Author: Ian Lynagh <ian@well-typed.com>
Date:   Fri Nov 23 16:54:15 2012 +0000

    Fix building on Sparc/Solaris with non-GNU linker; fixes #5407
    
    Patch from maeder.

 compiler/main/DriverPipeline.hs |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

Changed 6 months ago by igloo

  • status changed from patch to merge

Applied, thanks!

Changed 6 months ago by igloo

  • status changed from merge to closed
  • resolution set to fixed

Merged as 09894b0af6569ebb19ddaa16dd1bc564b46d7959.

Note: See TracTickets for help on using tickets.