Opened 8 years ago

Closed 8 years ago

#53361 closed defect (invalid)

libgmp gives illegal text-relocation error when linking with other programs in Sierra

Reported by: cytan299 Owned by: MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc:
Port:

Description

libgmp @6.1.2_0 when linking with other programs in Sierra I get the following error:

ld: illegal text-relocation to '_gmp_binvert_limb_table' in /opt/local/lib/libgmp.a(mp_minv_tab.o) from '_gmpn_divexact_1' in /opt/local/lib/libgmp.a(dive_1.o) for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I fixed this by downloading the gmp source and during configure using:

configure --with-pic

After doing this, and overwriting the libgmp.a and libgmp.10.dylib in /opt/local/lib, llinking with other programs does not give above error.

The above fix came from:

https://github.com/Homebrew/legacy-homebrew/issues/12946

I am running: MacOSX 10.12.2 Sierra with:

gcc -v Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 8.0.0 (clang-800.0.42.1) Target: x86_64-apple-darwin16.3.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Change History (4)

comment:1 Changed 8 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Owner: set to MarcusCalhoun-Lopez
Status: newaccepted

comment:2 Changed 8 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

According to the GMP mailing list, libgmp.a should not be PIC.
The advice is to use libgmp.dylib if PIC is needed.
Is that an option for you?

You seem to be using quite a few customizations (including a custom GCC).
This is probably going to make it difficult to determine if --with-pic is correct for everyone.

comment:3 Changed 8 years ago by cytan299

Hi,

I relinked using libgmp.dylib rather than libgmp.a and the error went away. So perhaps that's the right way to do this.

I'm not sure what you mean about a customized gcc. I believe I am using the standard install.

cytan

comment:4 in reply to:  3 Changed 8 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Resolution: invalid
Status: acceptedclosed

Replying to cytan299:

I relinked using libgmp.dylib rather than libgmp.a and the error went away. So perhaps that's the right way to do this.

If this works for you, then I would rather follow the advice of the upstream developers and leave things the way they are.

I'm not sure what you mean about a customized gcc. I believe I am using the standard install.

Sorry, I meant a non-MacPorts version of GCC.

Thank you for the report.
If non-PIC code is an issue in the future, we can use this as a starting point.

Note: See TracTickets for help on using tickets.