Opened 4 years ago

Closed 2 years ago

#5407 closed bug (fixed)

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 Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

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 (14)

comment:1 Changed 3 years 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.

comment:2 Changed 3 years 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).

comment:3 Changed 3 years 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)

comment:4 Changed 3 years ago by maeder

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

comment:5 Changed 3 years 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.

comment:6 Changed 3 years ago by igloo

  • Milestone set to _|_

comment:7 Changed 3 years 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.

comment:8 Changed 3 years ago by igloo

  • difficulty set to Unknown
  • Milestone changed from _|_ to 7.6.1
  • Priority changed from normal to high

comment:9 Changed 3 years 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 ++ ")"

comment:10 Changed 3 years ago by igloo

  • Milestone changed from 7.6.1 to 7.6.2
  • Status changed from new to patch

thanks for the patch

comment:11 Changed 2 years ago by igloo

  • Owner set to igloo

comment:12 Changed 2 years ago by ian@…

commit 9ef4d48e296d4b96492a839f9ee569f8f90c617b

Author: Ian Lynagh <[email protected]>
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(-)

comment:13 Changed 2 years ago by igloo

  • Status changed from patch to merge

Applied, thanks!

comment:14 Changed 2 years ago by igloo

  • Resolution set to fixed
  • Status changed from merge to closed
Note: See TracTickets for help on using tickets.