Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gmp requires --disable-assembly to static link #19407

Closed
5 tasks done
jeroen opened this issue Oct 13, 2017 · 4 comments
Closed
5 tasks done

gmp requires --disable-assembly to static link #19407

jeroen opened this issue Oct 13, 2017 · 4 comments

Comments

@jeroen
Copy link
Contributor

jeroen commented Oct 13, 2017

  • Confirmed this is a problem with brew installing one, specific Homebrew/homebrew-core formula (not cask or tap) and not every time you run brew? If it's a general brew problem please file this issue at https://github.com/Homebrew/brew/issues/new. If it's a brew cask problem please file this issue at https://github.com/caskroom/homebrew-cask/issues/new. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap.
  • Ran brew update and retried your prior step?
  • Ran brew doctor, fixed all issues and retried your prior step?
  • Ran brew gist-logs <formula> (where <formula> is the name of the formula that failed) and included the output link?
  • If brew gist-logs didn't work: ran brew config and brew doctor and included their output with your issue?

Static linking to libgmp.a from the gmp package fails with:

illegal text-relocation to '___gmpn_mul_1' in /usr/local/lib/libgmp.a(mul_1.o) from '___gmpn_mul_1' in /usr/local/lib/libgmp.a(mul_1.o) for architecture x86_64

A similar warning (though no error) appears when static linking test.c from the formula.

cc test.c /usr/local/opt/gmp/lib/libgmp.a
ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in ___gmpn_mul_1 from /usr/local/opt/gmp/lib/libgmp.a(mul_1.o). To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie

The solution from the gmp forums is to compile with --disable-assembly on MacOS. I confirmed this works and it does not seem to have any side effects. Can I file a PR to add an option for this?

@ilovezfs
Copy link
Contributor

Please check if this works as expected:

iMac-TMP:homebrew-core joe$ git diff -- Formula/gmp.rb 
diff --git a/Formula/gmp.rb b/Formula/gmp.rb
index 55379c3..2652f6d 100644
--- a/Formula/gmp.rb
+++ b/Formula/gmp.rb
@@ -20,10 +20,14 @@ class Gmp < Formula
     ENV.cxx11 if build.cxx11?
     args = %W[--prefix=#{prefix} --enable-cxx]
     args << "--build=core2-apple-darwin#{`uname -r`.to_i}" if build.bottle?
-    system "./configure", *args
+    system "./configure", "--disable-static", *args
     system "make"
     system "make", "check"
     system "make", "install"
+    system "make", "clean"
+    system "./configure", "--disable-shared", "--disable-assembly", *args
+    system "make"
+    lib.install Dir[".libs/*.a"]
   end
 
   test do

@jeroen
Copy link
Contributor Author

jeroen commented Oct 13, 2017

Yes this works, thanks!

@jeroen
Copy link
Contributor Author

jeroen commented Oct 13, 2017

Should I prepare a PR with that patch?

@fxcoudert
Copy link
Member

FWIW: --with-pic is a better solution to that problem, that does not disable the fast assembler code paths.

@Homebrew Homebrew locked and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants