Ticket #5293 (closed bug: fixed)

Opened 23 months ago

Last modified 22 months ago

Linker error from integer-gmp (OS X 10.7)

Reported by: jhenahan Owned by: chak
Priority: highest Milestone: 7.4.1
Component: Compiler Version: 7.0.4
Keywords: Cc: pho@…
Operating System: MacOS X Architecture: x86_64 (amd64)
Type of failure: GHC doesn't work at all Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I recently upgraded to the latest dev build of OS X Lion and Xcode 4.2, and I've been having some linking issues related to integer-gmp. I installed ghc-7.0.4-x86_64 from the .pkg with no apparent problems, but running ghc --make test.hs (where test.hs is simply main = print "Hello, World!" (attached, for convenience)) produces the following:

Linking test ...
ld: warning: could not create compact unwind for _ffi_call_unix64: does not use RBP or
RSP based frame
ld: illegal text reloc to ___gmp_modlimb_invert_table from
/Library/Frameworks/GHC.framework/Versions/7.0.4-x86_64/usr/lib/ghc-
7.0.4/integer-gmp-0.2.0.3/libHSinteger-gmp-0.2.0.3.a(mp_minv_tab.o) in 
___gmpn_modexact_1c_odd for architecture x86_64
collect2: ld returned 1 exit status

The bit about the unwind was present on my Snow Leopard install with Xcode 4.0.2, and there were never any problems. What is new is the illegal text reloc error. What little I've been able to find online seems to suggest that this is due to Xcode's linker now being a bit safer (read pickier) and giving errors where once it might have given warnings.

I considered building ghc HEAD, but of course without a working ghc that's a bit of a futile effort.

I understand that Dan Knapp (dankna) has also moved up to Lion and is having no such issue, so I am particularly curious about our differing experiences. It may be that the picky linker is only a product of the most recent dev build of Xcode, but I can't be sure.

Any thoughts or pointers would be greatly appreciated. Also, apologies if I've put the ticket together incorrectly.

Attachments

test.hs Download (28 bytes) - added by jhenahan 23 months ago.
test file

Change History

Changed 23 months ago by jhenahan

test file

  Changed 23 months ago by igloo

  • priority changed from normal to highest
  • milestone set to 7.2.1

in reply to: ↑ description   Changed 23 months ago by jhenahan

For clarity's sake, here are some symlinks, just in case they prove useful:

readlink /usr/bin/{gcc,cc,g++,c++}
llvm-gcc-4.2
llvm-gcc-4.2
llvm-g++-4.2
llvm-g++-4.2

And some other info

ld -v
@(#)PROGRAM:ld  PROJECT:ld64-123.4.1
llvm version 3.0svn, from Apple Clang 3.0 (build 209.9.2)

gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gcc-4.2 --version
i686-apple-darwin11-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  Changed 23 months ago by PHO

  • cc pho@… added

  Changed 23 months ago by igloo

  • milestone changed from 7.2.1 to 7.4.1

punting until after the 10.7 release, so we can reproduce it

  Changed 22 months ago by chak

This same issue generates a warning in Xcode 4.1. To work around it until GHC gets fixed, add the option -optl-Wl,-no_pie when linking.

  Changed 22 months ago by chak

  • status changed from new to closed
  • resolution set to duplicate

Duplicate of #5019

follow-up: ↓ 8   Changed 22 months ago by chak

  • status changed from closed to new
  • resolution duplicate deleted

I spoke too quickly. The warning is still a warning. The fatal error is new with Xcode 4.2 and seems to be in the GNU gmp library. Is there a newer version of the library that works with Xcode 4.2?

in reply to: ↑ 7   Changed 22 months ago by jhenahan

Replying to chak:

I spoke too quickly. The warning is still a warning. The fatal error is new with Xcode 4.2 and seems to be in the GNU gmp library. Is there a newer version of the library that works with Xcode 4.2?

I tried building libgmp 5.0.2 (the latest stable release) through homebrew and I wasn't able to get GHC to compile with it. I may just not have set the right flags, though. If you've got any pointers, I can certainly try them out. I'm not sure what version of GMP is currently distributed with Xcode 4.2. I can also attempt to compile GMP from source, if that might make a difference. I've since switched back to Snow Leopard to continue working with GHC, but I've heard that GHC is functional with Xcode 4.1 on Lion, so I may be switching up again in the near future so more germane prodding can continue.

  Changed 22 months ago by chak

You can use GHC with Xcode 4.1 on Lion. That's what I am using.

  Changed 22 months ago by chak

  • status changed from new to merge

I just pushed

commit 30ccc9f39dd2cf1ad14e6116778aa1fd94526c19
Author: Manuel M T Chakravarty <chak@cse.unsw.edu.au>
Date:   Wed Jul 27 23:05:01 2011 +1000

   On OS X x86_64, use "-Wl,-no_pie" and "-Wl,-no_compact_unwind" to avoid linker warnings

   - "-Wl,-no_pie" can be removed once GMP gets updated

This fixes the problem on Lion (x86_64) with Xcode 4.1.

If anybody has Xcode 4.2 lying around, let me know if it fixes the fatal error as well. (I'm not keen on the dance with two simultaneous Xcode installations and don't want to remove 4.1.)

A better fix would be to update gmp (and to remove "-Wl,-no_pie" again). Hence, I leave this bug open.

** PLEASE MERGE TO 7.2 **

  Changed 22 months ago by igloo@…

commit 4e044840808ffac427582d288f6de07e2cdd544d

Author: Ian Lynagh <igloo@earth.li>
Date:   Wed Aug 3 20:25:52 2011 +0100

    Stop using -Wl,-no_pie on OS X
    
    Now that the in-tree gmp has been upgraded, it should no longer be
    necessary, according to #5293.

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

  Changed 22 months ago by igloo

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

Merged as changeset:62f215934742f283798e843193eee64abf75636a and changeset:d02a1979d5c5eacd2c5daea7f5852a98988b4d97

  Changed 22 months ago by chak

  • status changed from closed to new
  • resolution fixed deleted

Unfortunately, the new GMP by itself isn't sufficient to fix the PIC-related problem. GMP uses m4 scripts to pre-process the code written in assembly and there appears to be a bug in the m4 configuration. I am on it.

  Changed 22 months ago by chak

  • status changed from new to merge
commit 82b8576c040e2d8fa5f524624478ac0effe18753
Author: Manuel M T Chakravarty <chak@cse.unsw.edu.au>
Date:   Fri Aug 5 00:17:14 2011 +1000

   This should finally fix #5293 by fixing two bugs in GMP's configuration setup

   * GMP uses m4 scripts to pre-process hand coded assembly routines
   * These didn't properly account for OS X/i86_64 always using PIC

follow-up: ↓ 17   Changed 22 months ago by igloo

  • status changed from merge to new

I've reinstated the workaround on the 7.2 branch.

Manuel, have you sent your patch to the GMP developers? If not, could you do so please?

  Changed 22 months ago by igloo

  • owner set to chak

in reply to: ↑ 15 ; follow-up: ↓ 18   Changed 22 months ago by chak

Replying to igloo:

I've reinstated the workaround on the 7.2 branch.

To be able to cope with pre-installed GMPs? Even if you leave the linker option in, I would suggest to merge commit 82b8576c040e2d8fa5f524624478ac0effe18753 (to integer-gmp) in 7.2. Then, people can at least generate PIC if they want to.

Personally, I would even omit the linker option and have people with a broken, pre-installed GMP get the warnings. They are only warnings and don't break the install and they are there for a good reason (i.e., they are accurate warnings).

Manuel, have you sent your patch to the GMP developers? If not, could you do so please?

I just sent it.

in reply to: ↑ 17   Changed 22 months ago by igloo

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

Replying to chak:

Replying to igloo:

I've reinstated the workaround on the 7.2 branch.

To be able to cope with pre-installed GMPs?

Because it seemed like the safest change at this stage of the release process.

Manuel, have you sent your patch to the GMP developers? If not, could you do so please?

I just sent it.

Great, thanks. For future reference: "Broken PIC support in OS X"  http://gmplib.org/list-archives/gmp-bugs/2011-August/002316.html

Note: See TracTickets for help on using tickets.