Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#5382 closed bug (fixed)

strip: Cannot manipulate object-file created with ghc-7.2.0.20110728 under solaris

Reported by: maeder Owned by: simonmar
Priority: normal Milestone: 7.4.1
Component: Compiler Version: 7.1
Keywords: Cc: viskovatoff@…
Operating System: Solaris Architecture: x86
Type of failure: None/Unknown Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

When I try to strip a binary created with ghc-7.2.0.20110728 under solaris I get:

-bash-3.00$ strip H
strip: H: Warning: Cannot delete section (.debug-ghc-link-info)
                from a segment.
H: WARNING: strip: Cannot manipulate file.

This causes any installation of binaries using cabal to fail:

...
Linking dist/build/scan/scan ...
Installing executable(s) in /local/home/maeder/bin
/usr/ccs/bin/strip: /local/home/maeder/bin/scan: Warning: Cannot delete section (.debug-ghc-link-info)
                from a segment.
/local/home/maeder/bin/scan: WARNING: /usr/ccs/bin/strip: Cannot manipulate file.
cabal: Error: some packages failed to install:
scan-0.1.0.6 failed during the final install step. The exception was:
ExitFailure 1

Change History (8)

comment:1 Changed 3 years ago by igloo

This section was added as part of #4451, changeset:814edf44433801e37318ce79082ac6991dbc87dd

Is /usr/ccs/bin/strip a GNU strip? If not, do you have a GNU strip, and does using that instead work?

You should be able to work around the problem by setting --disable-executable-stripping in your .cabal config file.

comment:2 Changed 3 years ago by maeder

I was not able to fully install binutils-2.21 (building "ld" failed), but "strip" was installed and this GNU strip command could remove the .debug-ghc-link-info section.

parts of the man page for our solaris strip say:

SYNOPSIS
     /usr/ccs/bin/strip [-lVx] file...

DESCRIPTION
     The strip command removes the symbol  table  SHT_SYMTAB  and
     its associated string table, debugging information, and line
     number information from ELF object files. That  is,  besides
     the  symbol table and associated string table, the following
     sections are removed:

     .line
     .debug*
     .stab*
OPTIONS
     The amount of information stripped from the  ELF object file
     can be controlled by using any of the following options:

     -l       Strip line number information only.Does  not  strip
              the symbol table or debugging information.



     -V       Prints, on standard error, the  version  number  of
              strip.



     -x       Does not strip the symbol table. Debugging and line
              number information may be stripped.
-bash-3.00$ strip -V
strip: Software Generation Utilities (SGU) Solaris-ELF (4.0)

Also "ghc -optl-s" (going via gcc) did not remove the .debug-ghc-link-info section, but did not fail and considerably reduced the object size. (4194076 unstripped, 2745692 "ghc -optl-s", 2743564 GNU stripped)

comment:3 Changed 3 years ago by simonmar

I don't know why strip is failing, but it's easy enough to disable this stuff and the consequences aren't bad (basically reverting to the GHC 7.0 behaviour, where GHC sometimes omits linking when it shouldn't - see #4451).

You'll need to add an exception for Solaris to two places in DriverPipeline.hs, where we already have exceptions for Windows and OS X (Darwin). See mkExtraObjToLinkIntoBinary and checkLinkInfo. Incedentally it would be better to abstract that check into one place, call it "platformSupportsLinkInfo" or something.

comment:4 Changed 3 years ago by simonmar

  • Owner set to simonmar

comment:5 Changed 3 years ago by marlowsd@…

commit d7ca829ec8b1507a47f89e1d2f1d45c26d15e406

Author: Simon Marlow <marlowsd@gmail.com>
Date:   Wed Aug 10 10:01:44 2011 +0100

    Disable saving the linker options in the binary on Solaris (#5382).
    Also refactor the check into one place.

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

comment:6 Changed 3 years ago by simonmar

  • Resolution set to fixed
  • Status changed from new to closed

Should be fixed, although I've not tested it. Reopen if you still have problems.

comment:7 Changed 3 years ago by simonmar

  • Milestone set to 7.4.1

comment:8 Changed 3 years ago by herzen

  • Cc viskovatoff@… added

Disabling stripping on Solaris seems like a drastic solution, given that GNU strip is found in a standard location under Solaris 11, /usr/gnu/bin/strip.

The problem goes away for me when I remove the Sun strip that's in /usr/bin, so that Gnu strip gets used.

Unfortunately, users cannot solve this problem by placing /usr/gnu/bin in front of /usr/bin in their PATH, since GNU ld also resides in /usr/gnu/bin, and I don't think we want that to get used.

GNU strip is in the gnu-binutils package, which anyone using Haskell would probably have installed.

Note: See TracTickets for help on using tickets.